By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,885 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,885 IT Pros & Developers. It's quick & easy.

Help Displaying & Stabilizing PictureBox Contents

P: n/a
(ellipses in place of code sections which do not deviate from defaults)

Private Sub Form_Main_Load(...) Handles MyBase.Load
For A = 0 To 16
For B = 0 To 14
PictureBox_MapEditor_Map.CreateGraphics.DrawImage
(System.Drawing.Image.FromFile("C:\The RPG Project\Test 2.bmp"), A * 40,
B * 40)
Next
Next
End Sub

First:

The preceeding code tiles a PictureBox with 17 Columns by 15 Rows of what
will eventually be varying graphics (as befits a Final Fantasy IV-style
visual presentation)...

At least it does in theory. In actuality, nothing happens unless I tie
the tiling to a post-Form.Load event.

But I'd *really* like it to execute absent at program start absent user
input. Any way to do this?

Second:

How do I stabilize the contents of the PictureBox, so it won't be
affected by alt/tabbing, moving a window on top of it, or other such
annoyances?

Third:

The PictureBox is contained (eventually with several other controls) in a
Panel. Is there any way that I can force references to the control to
also reference the panel, as in Panel.PictureBox.CreateGraphics?

Will this also allow me to have two same-named component controls in the
form, as long as they are members of different panels?

Thanks in advance for any assistance,

The Confessor

Feb 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
CMM
AFAIK the .NET picturebox doesn't have an autoredraw property but it's easy
to simulate:

Dim bmp As New Bitmap(width, height)
Dim gr As Graphics = Graphics.FromImage(bmp)
'draw as before
PictureBox_MapEditor_Map.Image = bmp

That works... but, personally, I don't see why not just put drawing code in
the PictureBox's Paint event. Drawing is extremely fast in .NET... and sorta
makes "autoredraw" obsolete.

P.S.
Oh yeah and I think you're supposed to do gr.Dispose() on manually created
gr objects... or else they'll go into garbage collection land still holding
on to GDI resources until the GC finally destroys it (whenever that is... if
ever).
"The Confessor" <in*****@reply.to.group> wrote in message
news:Xn*********************************@130.81.64 .196...
(ellipses in place of code sections which do not deviate from defaults)

Private Sub Form_Main_Load(...) Handles MyBase.Load
For A = 0 To 16
For B = 0 To 14
PictureBox_MapEditor_Map.CreateGraphics.DrawImage
(System.Drawing.Image.FromFile("C:\The RPG Project\Test 2.bmp"), A * 40,
B * 40)
Next
Next
End Sub

First:

The preceeding code tiles a PictureBox with 17 Columns by 15 Rows of what
will eventually be varying graphics (as befits a Final Fantasy IV-style
visual presentation)...

At least it does in theory. In actuality, nothing happens unless I tie
the tiling to a post-Form.Load event.

But I'd *really* like it to execute absent at program start absent user
input. Any way to do this?

Second:

How do I stabilize the contents of the PictureBox, so it won't be
affected by alt/tabbing, moving a window on top of it, or other such
annoyances?

Third:

The PictureBox is contained (eventually with several other controls) in a
Panel. Is there any way that I can force references to the control to
also reference the panel, as in Panel.PictureBox.CreateGraphics?

Will this also allow me to have two same-named component controls in the
form, as long as they are members of different panels?

Thanks in advance for any assistance,

The Confessor

Feb 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.