GDI+ drawing

micon

Member
Joined
Jul 4, 2003
Messages
5
I know i should post this twice, but i got zero feedback from the graphics section. I was wondering if it is possible to call your GDI+ drawing from another class or method? OR..is it possible to create a function that will do the gdi drawing. ie, Draw(x,y,picture)

any help would be very very helpfull.thanks!
 
Originally posted by micon
I know i should post this twice, but i got zero feedback from the graphics section. I was wondering if it is possible to call your GDI+ drawing from another class or method? OR..is it possible to create a function that will do the gdi drawing. ie, Draw(x,y,picture)

Probably no one was quite sure what you were asking. ;) Do you just mean that you want to write a function to make some GDI+ method calls? Maybe you want a generic function that you can call both from OnPaint() and from elsewhere? If so, then of course. Youll need some way for that method to get ahold of a Graphics object -- the easiest way is to pass it as a parameter. For example:

C#:
    private void Draw(Graphics g, int x1, int y1, int x2, int y2)
    {
        g.DrawLine(Pens.Red, x1, y1, x2, y2);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        Draw(e.Graphics, 50, 50, 100, 150);
    }

If youre after something a bit more complicated, then youll have to do a bit more explaining first. ;)
 
Back
Top