Click to See Complete Forum and Search --> : using Graphics class inside a function


rowgram
December 12th, 2005, 11:39 AM
Here's what I have that works fine :

inside abutton click event handler :
Graphics* gr2 = CreateGraphics();
SolidBrush* sb = new SolidBrush(Color::Red);
gr2->FillRectangle(sb, .......);



Now, I try to use this inside a function X :

the function X prototype is changed to :
BOOL X(System:: Drawing::SolidBrush*sb, System:: Drawing::Graphics* gr2, ....);

gr2 is made a private property of the Form :
private: System:: Drawing::Graphics * gr2;


& now inside the function X :
Graphics* gr2 = CreateGraphics();
SolidBrush* sb = new SolidBrush(Color::Red);
gr2->FillRectangle(sb, .......);

I get error C3861 : CreateGraphics identifier not found.

I thought by passing the SolidBrush & Graphics pointers to function X , it would work properly ? It understands the FillRectangle method, so why not the CreateGraphics method ?

Any help would be appreciated - I'm close to getting this to work !

rowgram
December 12th, 2005, 11:47 AM
it seems I need to make CreateGraphics() a static member function, so I can use it throught the project. How can I do this ?

rowgram
December 12th, 2005, 06:19 PM
can anybody help ?

I'm trying to use CreateGraphics outside of a Windows Form & I'm passing
System:: Drawing::Graphics* gr2 to the function in which I want to use it..

ak