Quote:
> In any examples at the end of pixel manipulations, I have noted this
> assignment:
> <PctureBox>.Picture = <PictureBox>.Image
> It is really necessary? The code works the same correctly!
What this does is to 'lock' the picture box's picture to the background
image (So to speak).
Try this:
'***
With Picture1
.AutoRedraw = True
'Display the form
Form1.Show
DoEvents
'Draw rectangle
Picture1.Line (0, 0)-(1000, 1400), vbGreen, BF
MsgBox "Rectangle drawn"
.Cls 'Clear to background
MsgBox "Without .Picture = .Image"
'Draw rectangle
Picture1.Line (0, 0)-(1000, 1400), vbGreen, BF
.Picture = .Image
MsgBox "Rectangle drawn and locked"
.Cls 'Clear to background
MsgBox "With .Picture = .Image"
End With
'***
The first rectangle is drawn but not locked then when .Cls is called it is
lost. The second rectangle is drawn and locked then when .Cls if called we
see that the rectangle has been locked to the 'background' graphic.
This shows that a picture box actually has multiple images stored within it
which is why it's very memory intensive, especially when set to AutoRedraw.
If you don't need to lock the background image then you don't have to, in
some cases though it's very useful.
Hope this helps,
Mike
-- EDais --
- Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/