PDA

Click to See Complete Forum and Search --> : clearing a picture box area


chander
Jan 8th, 2002, 12:47 AM
is there any API / method to clear a particular area of a picture box .. I have the start and end co-ordinate and i want to clear that particular area of a picture . i think some API like sendmessage can do it by taking pictrue box handle.Write now i m using another pic box and placing it above that area to clear that area but it is causing some problem for other operation ..
is there any way to do it by coding ??

thanks in advance ..

Hack
Jan 8th, 2002, 06:19 AM
I'm not sure that you would necessarily need to use an API call. I think using the Pictures build in Line property and its Backcolor might do the trick for you.

chander
Jan 8th, 2002, 07:46 AM
ya i got .. i think showing a fill rectangle will do ..

Hack
Jan 8th, 2002, 09:28 AM
When you get it all worked out, why don't you post the code your wrote here. It might help someone else. :D

Hack
Jan 8th, 2002, 06:30 PM
But, Picture1.Cls would clear everything. I think chander only wants to clear a certain portion of the Picture box. Is that correct, chander, or no?

beachbum
Jan 8th, 2002, 07:24 PM
Hi Hack
The qtn was posted twice and already answered in the General forum. Private Sub Command1_Click()
'x1,y1 to x2, y2, req'd colour, B for box and F for fill
Picture1.Line (0, 0)-(500, 500), Picture1.BackColor, BF
End Sub

http://www.vbforums.com/showthread.php?s=&threadid=132356
Regards
Stuart

chander
Jan 8th, 2002, 11:56 PM
ya hack its right i asked for clearing a portion only and it is best with rectangle . The code is same as beachbum wrote just instead of x,y and x1,y1 u can give ur own co-ordinates . My code use a Shape rectangle and when mouse is up its co-ordinates are trapped and rectable is made by same code as beachbum wrote.

In mouse down of pic

tX = x
tY = y

in mouse up

picMain.Line (tX, tY)-(tX + w, tY + h), ForeCol, B

where w and h are width and height calculated from size of rectangle and it forms the ending co-ordinates . thats it .. or u can take x1,y1 in mouse up and draw . Use forecolor and fill color white so that portion can be seen as clear.