473,513 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing in VB

14 New Member
so im making a project in VB like MS paint. and i want to be able to switch between say push the mouse down to make a dot and draging the mouse to draw a line. and i can get the program to do both i understand that but i am not sure on how to get the program to switch between the two by the push of a button, so if someone could lend me a hand that would be great
thanks a lot
Oct 7 '08 #1
7 1797
debasisdas
8,127 Recognized Expert Expert
you need to handle mouseup, mouse down and mouse move events.
Oct 8 '08 #2
vdraceil
236 New Member
In the mouse down event write code to set the pixel clicked to black color(or any other pen color) by using pset() method..
Oct 8 '08 #3
gwbob
14 New Member
ok i might not have been to clear thats my fault. or maybe i just dont understand... i dont know but i know how to get the program to draw dots and stuff with the mouse but i want to switch between clicking the mouse to put dots, to moving the mouse to draw a line, with the push of a button on the form and the push button event sub is different from the mouse down sub or move mouse sub and i dont think you can put both in the same sub. thats my problem.
thanks a lot
Oct 8 '08 #4
vdraceil
236 New Member
So you have 2 buttons.The first one when pressed must enable the user to draw freely(dots and irregular shapes) and when the other button is pressed the user must be able to draw only lines.
Is this what you want to do?
Oct 9 '08 #5
gwbob
14 New Member
ya pretty much one button will let me click to make dots and the other one will let me draw lines.
thanks a lot
Oct 9 '08 #6
vdraceil
236 New Member
when the first button's click event write flag=1 and in second button's click event write flag=2...flag enables you to know which button was pressed last.
then,

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_MouseDown(...)
  2. If flag=1 Then
  3.  'here write code for dots
  4. Else
  5.  'here code for lines
  6.  'on this mousedown event save the coordinates(x,y) clicked to x1,y1
  7.  'on the next mousedown event you'll get another pair of coordinates x2,y2
  8.  'draw line using line(x1,y1,x2,y2) method
  9.  'then transfer x2,y2 to x1,y1,so that x2,y2 becomes free for next input
  10. End If
  11. End Sub
Is that of any help?
Oct 13 '08 #7
gwbob
14 New Member
ok i understand that but i think my code is set up in a way where thats not working here is my code:
-------------------------------------------------
Dim drawing

Private Sub Command1_Click()
Picture1.Cls
End Sub

Private Sub cmdclear_Click()
Picture1.Cls
End Sub

Private Sub cmddots_Click()
flag = 1
End Sub

Private Sub cmdline_Click()
flag = 2
End Sub

Private Sub Form_Load()
drawing = False
End Sub

Private Sub mnufileexit_Click()
End
End Sub

Private Sub mnufilenew_Click()
Picture1.Cls
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag = 1 Then
drawing = True
PSet (X, Y), vbBlack
End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
drawing = True
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
drawing = False
End Sub
------------------------------------------------------------------------
i think im doing something wrong maybe not, but if there is theres my code and you should b able to find it or show me where in the code i have a problem
thanks a lot again
Oct 14 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2743
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
2
12293
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
1
3213
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
7
8689
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as...
2
6677
by: active | last post by:
I find Bitmap.Save works for WMF files but Bitmap.FromFile does not. If I use FromFile on a WMF file that came with VS I get an exception. If I use it on a WMF file created with Bitmap.Save I...
3
2594
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a specific color. I have so far discovered that...
5
3340
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
1
3938
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the...
2
2312
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
7
3540
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.