|
Here is an example that should work. You just need a form with a picturebox. Copy the code into your project and start drawing.
Public Class Form1
Private IsDrawing As Boolean = False
Private StartPoint As Point
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
IsDrawing = True
StartPoint = e.Location
End If
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If IsDrawing Then
PictureBox1.CreateGraphics.DrawLine(Pens.Black, StartPoint, e.Location)
StartPoint = e.Location
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
IsDrawing = False
End Sub
End Class
|
|
|
|
|
The example you've been given won't work properly. Once you have drawn your image, if you move another window over it, it will disappear. This is why you shouldn't use CreateGraphics for anything except very temporary drawing.
A picturebox is a picturebox, a tool for quickly throwing a bitmap onto a form. It's not a paint program, it's not Powerpoint. If you want to draw on an image, you should draw the image yourself, in your paint handler. You should track mouse movement and mouse events, and use the Invalidate() function to force paint events, your paint event will draw your bitmap, which gets drawn to as you move the mouse.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
hi,
Could you give me the code snippet to do thin in paint event.
Be simple and Be sample.
|
|
|
|
|
Well, the paint event will just draw the image. The code you were shown is basically what I'm talking about, except you should handle mouse move for the form, and when the mouse moves, draw on a bitmap and call Invalidate(), your paint method just draws the bitmap.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Iam using VB2005 on Windows XP. In my Application
I have one child form merged with the parent form menu items.
Both the forms have Toolbar.
On load of the parent form along with the child form at runtime select at some
menu and release the menu.
This selected menu image is overlapping on the toolbar of the parent form and hides the toolbar buttons.This continues on click of each and every menu.
Please, tell me the solution for this
Rekha
|
|
|
|
|
How i can export data from grid to excel
|
|
|
|
|
you can use componentOne tools.I think these r the best tools for this.
Lxcite's Planet
... the ultimate solution
|
|
|
|
|
|
instead of inheritting button class i want to create a button in component class. in that class where i can call pen and brush to make button ?
|
|
|
|
|
dim mybutton as new Button
mybotton.Text="button"
sk.haneef@gmail.com
this is haneef
|
|
|
|
|
I don't think that you understood the question at all...
---
Year happy = new Year(2007);
|
|
|
|
|
Use the Paint event. The EventArgs contains a Graphics object that you can use for the drawing.
---
Year happy = new Year(2007);
|
|
|
|
|
Thanks for the reply.but where i will call the paint method in my component class
|
|
|
|
|
Imports System.Windows.Forms
Imports System.Drawing
Public Class FlatButton
Public Sub Onpaint()
Dim obj As Graphics
obj.DrawRectangle(New Pen(Color.DarkOliveGreen), New Rectangle(0, 0, 100, 100))
obj.FillRectangle(New SolidBrush(Color.DarkRed), New Rectangle(0, 0, 100, 100))
End Sub
This is my class .now i don't want to enter events and properties.just i want to create one outline of my button.please give me a reply. i want to make dll file of this component in one project and i want to add this button to my form.please anyone give a reply
|
|
|
|
|
anujose wrote: but where i will call the paint method in my component class
You don't. The event will be called whenever the control needs to be drawn. That is the way that you provide the code that the system uses to draw your control.
---
Year happy = new Year(2007);
|
|
|
|
|
I have a form which is a loading form. I would like it to close and remove itself from memory before the next form (Login form) LGNFRM loads.
The problem is, is that the form hides itself rather than closes as when I press ALT-TAB to change windows, the form that should have closed is till open, but you cannot access it unless you close the login form. Could anyone help?
Using VB.net 2005
In the end we're all just the same
|
|
|
|
|
Hi Dave,
I am going to assume that you want to remove the first form from memory because it uses a lot of resources itself.
In this case you have to "cheat". Make a new completely empty starting form, have its load event open your second (loading) form, and then hide itself. Then make your second form open the third one in its disposed event, and use me.dispose , instead of me.close .
Et voila.
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
vhuynh View profile
More options Dec 30 2006, 9:32 am
From: "vhuynh" <huynhthanhv...@gmail.com>
Date: Fri, 29 Dec 2006 18:32:12 -0800
I write a sale form using datagrid with it detail:
Item_Code Item_Name Quantity Price Total
HH01 ? ? ?
?
When I input item_code, I want to automatically change item_name, price, and calulate
total
Can anyone help me?
Viet, Huynh
|
|
|
|
|
Hello,
I want to add Image in MDI Form.
How it i Can do. Plz Help me.
Thanks & Regards
Form :-
Vikash Yadav
|
|
|
|
|
you can get The MdiClient Control of your form and set background image for it:
Private Sub MyMDIForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For Each c As Control In Me.Controls
If c.GetType Is GetType(MdiClient) Then
c.BackgroundImage = Image.FromFile(ADDRESS_OF_IMAGE)
Exit For
End If
Next
End Sub
|
|
|
|
|
Thanks Boss
It was Success.
I want more help with you. It was Tiles, not Stretch. How it will be. & How i will do if i want to set any colour in Background. I am using VB.Net 2005. and colour is in code which i am ussing "255, 224, 192" that is this, How i can use this colour in MDI form as a Background.
Thanks again For help.
Thanks & Regards
Form :-
Vikash Yadav
|
|
|
|
|
Thanks Boss
It was Success.
I want more help with you. It was Tiles, not Stretch. How it will be. & How i will do if i want to set any colour in Background. I am using VB.Net 2005. and colour is in code which i am ussing "255, 224, 192" that is this, How i can use this colour in MDI form as a Background.
Thanks again For help.
Thanks & Regards
Form :-
Vikash Yadav
|
|
|
|
|
1-MdiClent control has properties such as other controls; u can use BackgroundImageLayout property to set background image layout , use BackColor Property to set Back color , ...
2-by using Color.FromARGB you can create your custom colors and assign it to backcolor property
|
|
|
|
|
i have developed a "Voice Based Messenger" which user could record voice and send it to another user. i found difficulty in coding part to record,stop, playback and save it as an audio(.wav) file.
ill appreciate..thanks
|
|
|
|
|
Your program will be useless if it saves wav, that's raw data. You want to save as mp3.
You need the platform SDK to look at DirectShow.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|