Results 1 to 4 of 4

Thread: OnPaint

Threaded View

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved OnPaint

    I have a problem here. Something I don't understand.

    Well isn't OnPaint only called when there is something to paint? But how can you paint something when you don't have the PaintEventArgs. Well this is my OnPint right now. And I need it to be called every time I have moved the ojects on the screen:

    Code:
    protected override void OnPaint(PaintEventArgs e) 
    {
    
        // Set the atributes for the graphics object
        g = e.Graphics;
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
    
        // Draw a circle
        g.FillRectangle( new SolidBrush(Color.Black), ClientRectangle);
    
        g.DrawString("Solsystem", new Font("Courier",32), new SolidBrush(Color.DarkRed), 10,10);
    
        foreach (Himmellegeme spaceObject in skyObjects)
             spaceObject.draw(g);
    But as you see in the last line, I have to call my draw function and pass it the g (the Graphics object to be able to use FillElipse and DrawString.


    Code:
    public override void draw(Graphics g) {
    
        g.FillEllipse(new SolidBrush(farge),(float)xpos,(float)ypos,radius*2,radius*2);
        g.DrawString(name, new Font("Courier",8), new SolidBrush(Color.White),origox+avstand,origoy+radius);
    }

    How am I supposed to think here?
    Last edited by NoteMe; Nov 23rd, 2004 at 07:03 AM.

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