PhilH Posted August 23, 2003 Posted August 23, 2003 When I set the backcolor property of my pictureBox to transparent, the backcolor of the underlying form shows through, but not squares etc drawn onto the surface of the form. Is this how it is meant to work? Quote
*Experts* Volte Posted August 23, 2003 *Experts* Posted August 23, 2003 No. It simply takes the background image/color of the form and paints it on the picture box. You'll probably need to draw the contents of the picture box directly on the form manually usings its OnPaint event. Quote
PhilH Posted August 23, 2003 Author Posted August 23, 2003 Thanks , you solved my problem. Knowing what was meant to happen I had another look at my code. I actually don't have anything in the PictureBox, I just wanted its 3d border to provide a frame around something I am drawing onto the form. In the form paint event I had (I'm new at this!): Dim g As Graphics = Me.CreateGraphics g.DrawRectangle(Pens.Blue, New Rectangle(50, 50, 100, 100)) The square dosen't show through. When I changed it to: e. DrawRectangle(Pens.Blue, New Rectangle(50, 50, 100, 100)) The square shows through! Quote
ThePentiumGuy Posted August 25, 2003 Posted August 25, 2003 what do u mean ' the square shows through' ? Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
PhilH Posted August 27, 2003 Author Posted August 27, 2003 There is a PictureBox sitting over the area of the form where the square is drawn. The PictureBox backcolor is set to transparent . When I used : Dim g As Graphics = Me.CreateGraphics g.DrawRectangle(Pens.Blue, New Rectangle(50, 50, 100, 100)) in the form paint event, the square was not visable through the PictureBox. But when I used: e. DrawRectangle(Pens.Blue, New Rectangle(50, 50, 100, 100)) in the form paint event the square is visable. Quote
aewarnick Posted August 28, 2003 Posted August 28, 2003 That is probably becuase this.CreateGraphics makes temporary graphics that aren't updated when the form is redrawn. Therefore, the picturebox was drawn and the that part of the form was Invalidated causing redraw. When you draw in OnPaint directly, it is drawn every time Invalidate is called. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.