Page 1 of 1

Creating a SketchPad We're goin' to create a basic sketchpad using a picture box it Rate Topic: ***** 1 Votes

#1 Nikhil_07n  Icon User is offline

  • The cheese stands alone..
  • member icon

Reputation: 49
  • View blog
  • Posts: 2,489
  • Joined: 09-January 09

Post icon  Posted 26 January 2009 - 05:46 AM

Intro : This program basically creates a Sketchpad on which lines can be created on clicking and holding mouse button.

Concept : When the mouse_down event of picture box picCanvas is triggered, a dot is created.

When mouse_move event is triggered, a line is created to the current coordinates of the mouse.

Coding:


Private Sub Form_Load()
	picCanvas.AutoRedraw = True
	picCanvas.DrawWidth = 2
	picCanvas.ForeColor = vbBlue
	picCanvas.BackColor = vbWhite
End Sub




Explaination : Not needed, just the basic properties.(Blue line will be created on a white-backgrounded picture box)


Private Sub picCanvas_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
	If Button = 1 Then
		picCanvas.Line (X, Y)-(X, Y)
	End If
End Sub




Explaination : On holding mouse down, a dot is created, i.e., a line with initial and final coordinates SAME.



Private Sub picCanvas_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
	If Button = 1 Then
		picCanvas.Line -(X, Y)
	End If
End Sub




Explaination : The line is extended till the CURRENT coordinates of the mouse.

I think its clear now, for a working sample, download the ATTACHMENT.

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Page 1 of 1