how to do this?

imnew
01-24-2005, 11:38 AM
i have a picturebox, and when i click on it, it will display an small dot on the picturebox. but how can i continusly click on it, while it only display the latest clicked point, the previous ones all disappear?

this is my program which can display the small dot when clicking:

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Picture1.CurrentX = X
Picture1.CurrentY = Y
Picture1.Line Step(-0.5, -0.5)-Step(0.5, 0.5), &HFF&, BF
Picture1.DrawWidth = 2

End sub

:huh:

loquin
01-24-2005, 11:48 AM
Try setting the autoredraw property of the picture box to true.

imnew
01-24-2005, 11:56 AM
yes, i did, it can display the small dot on the picture, but if i click 10 times, then it will display 10 dots on the picture. but what i want is it only display the dot of last click, which means no matter i click how many times, it only display 1 dot. how to achieve this?

Diurnal
01-24-2005, 12:24 PM
Before you draw your dot, use the object's .Cls method.

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Picture1.CurrentX = X
Picture1.CurrentY = Y
Picture1.DrawWidth = 2

'Clear the screen before the draw.
Picture1.Cls

Picture1.Line Step(-0.5, -0.5)-Step(0.5, 0.5), &HFF&, BF

End sub

imnew
01-24-2005, 12:37 PM
why after i add "picture1.cls", when i click, there is not dot any more?

passel
01-24-2005, 12:45 PM
The Cls will reset CurrentX, and CurrentY

Put the Cls before setting the CurrentX and CurrentY

passel
01-24-2005, 12:52 PM
Or you could change the Code so you don't set CurrentX and CurrentY


Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Picture1.DrawWidth = 2
'Clear the screen before the draw.
Picture1.Cls
Picture1.Line (X - 0.5, Y - 0.5) - Step(1, 1), &HFF&, BF
End Sub

imnew
01-24-2005, 01:07 PM
tks!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum