Paintin on a picturebox

PappaGiorgio
01-03-2005, 07:44 AM
hi ppl happy new year :)!
Well im painting a square on a picturebox like this:

For i=0 to 50
picture1.line (0,i),(50,i)
next i

this works good but it shows a bit of refresh and it look a bit ugly too.
I wanna know if thers a woy to paint a square at once. If anyone knows how ill be really pleased .. :)

noi_max
01-03-2005, 10:20 AM
The .Line method has a way of drawing a box already built in.

If you highlight the word "Line" and hit F1, MSDN should provide you with a list of parameters you can use.

Most notably in this example is the BF at the end of the parameter list. B for 'Box' and F for 'Fill"

Private Sub Command1_Click()

'Draw a 50 X 50 pixel box starting at the top/left
'of the picturebox

Picture1.ScaleMode = vbPixels 'to draw in pixel scale


'The old way using a loop
'Dim i As Integer

'For i = 0 To 50
' Picture1.Line (0, i)-(50, i)
'Next i

'The new way using 'Box' and 'Fill'
Picture1.Line (0, 0)-(50, 50), vbBlack, BF

End Sub


Hope that helps!

PappaGiorgio
01-03-2005, 04:35 PM
hoho! thanks it was really easy :) i saw that BF in help but cuz my english understandin abilities didnt allow my to use it.Thanks ur reply helps me to understand it well. Thanks a lot :)

zelg37
01-03-2005, 08:37 PM
this works good but it shows a bit of refresh and it look a bit ugly too.
I wanna know if thers a woy to paint a square at once. If anyone knows how ill be really pleased .. :)
To get rid of refresh (flicker), just draw on a memoryDC backbuffer and Bitblt the square to picturebox control.

For a demo, please check out the "MemDC_FillRect_example.zip" attachment that I posted:
http://www.xtremevbtalk.com/showpost.php?p=913361

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum