Results 1 to 2 of 2

Thread: Gdi+

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870

    Gdi+

    Hi.

    just got .net game programming with DirectX9 and trying to do a simple bit of code drawing a rectangle in a picture box. I've got the following code in the forms paint event.
    Code:
    Dim graph As Graphics
            Dim rectSquare As Rectangle
            Dim graphPath As Drawing2D.GraphicsPath
            Dim brushSquare As Drawing2D.PathGradientBrush
    
            graph = Graphics.FromHwnd(PictureBox1.Handle)
    
            'create a path consisting of one rectangle
            graphPath = New Drawing2D.GraphicsPath()
            rectSquare = New Rectangle(10, 20, 23, 27)
            graphPath.AddRectangle(rectSquare)
            brushSquare = New Drawing2D.PathGradientBrush(graphPath)
            brushSquare.CenterColor = Color.FromArgb(255, 0, 255, 0)
            brushSquare.SurroundColors = New Color() {Color.FromArgb(255, 0, 0, 255)}
    
            'create the rectangle from the path
            graph.FillPath(brushSquare, graphPath)
    if you're quick you can see the rectangle but then the picture box is draw over it! I've tried putting this code in the paint event of the picture box but to no avail.

    Please help! Simple example and I can't get it to work!!!

    Nick
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  2. #2
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    Hi nswan

    I've got that book too, very nice especially the tiled game "River Plan.NET"

    If you look in the book the code your using isn't meant to go in a paint event just put it in a Public Sub Show and call it. Have a look at the code for that bit on the CD and you'll see what i mean.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width