| | |
drawing in picturebox
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2006
Posts: 4
Reputation:
Solved Threads: 0
I am a student, and have been working on a program where the user selects a drawing tool, color and line width then draws on a picturebox. I have the mouse coordinates of the picture box, and can draw the lines and rectangles I need. The drawings begin where the mouse button is pressed down and end when the mouse button is released. My problem is that the drawings do not appear until the mouse button is released. I want the drawings to be visible during the draw process. Is there a way I can do this?
Thank you in advance
Thank you in advance
Hi,
Ok.. Yes u can do it. I will Give this For a Line Control.
Keep A Form Level Boolean Variable say LnFlag.
After Selecting Line From Ur Tool Box In Mouse Down of Picture Box,
Load a Line [Say Line1(1)] and Make the LnFlag =True and Make
Line1(1).X1 =X
Line1(1).Y1 =Y
Line1(1).X2 =X
Line1(1).Y3 =Y
In Picture1_MouseMove Event :
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LnFlag Then
Line1(1).X2 = X
Line1(1).Y2 = Y
End If
End Sub
If MouseUp Event make
LnFlag =False
Similarly u can write for other Shapes.
I Hope It is clear.
Regards
Veena
Ok.. Yes u can do it. I will Give this For a Line Control.
Keep A Form Level Boolean Variable say LnFlag.
After Selecting Line From Ur Tool Box In Mouse Down of Picture Box,
Load a Line [Say Line1(1)] and Make the LnFlag =True and Make
Line1(1).X1 =X
Line1(1).Y1 =Y
Line1(1).X2 =X
Line1(1).Y3 =Y
In Picture1_MouseMove Event :
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LnFlag Then
Line1(1).X2 = X
Line1(1).Y2 = Y
End If
End Sub
If MouseUp Event make
LnFlag =False
Similarly u can write for other Shapes.
I Hope It is clear.
Regards
Veena
oooh.. 2003. i've only ever used VB6.
in VB6 there are lots of mouse events (mousemove,mouseup,mousedown,click). usually i use the mousemove event for "drawing" > set a flag "drawing" to true, and while "drawing" is true, draw a line between where the mouse was and where the mouse is; so, similar to QVeen72's idea :- but I'd draw directly to the surface rather than place a line object. check out the lineto() and moveto() API functions..
http://edais.mvps.org/Tutorials/Graphics/GFXch7.html
there may be native "line() or drawLine()" function in a picturebox control (or maybe on a device context if VB2003 has that concept yet).
in VB6 there are lots of mouse events (mousemove,mouseup,mousedown,click). usually i use the mousemove event for "drawing" > set a flag "drawing" to true, and while "drawing" is true, draw a line between where the mouse was and where the mouse is; so, similar to QVeen72's idea :- but I'd draw directly to the surface rather than place a line object. check out the lineto() and moveto() API functions..
http://edais.mvps.org/Tutorials/Graphics/GFXch7.html
there may be native "line() or drawLine()" function in a picturebox control (or maybe on a device context if VB2003 has that concept yet).
Last edited by MattEvans; Dec 6th, 2006 at 4:03 am.
Plato forgot the nullahedron..
![]() |
Similar Threads
- Word 2002 hogs CPU with Visio drawing embedded. (Windows NT / 2000 / XP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Please help me-- from shaji
- Next Thread: Reading a Binary file using Visual Basic
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






