Link to home
Start Free TrialLog in
Avatar of restabro
restabroFlag for United States of America

asked on

Error passing PaintEventArgs to functions

My program captures a Paint event then passes the PaintEventArg to several graphics functions to perform various drawing tasks. When I only use one function, the program works. As soon as I try to string more than one function together in the calling function, I get a run time error stating "Invalid Parameter Used". Here is a code sample:

//graphicForm.h=============================

void drawPart1(PaintEventArgs * e);
void drawPart2(PaintEventArgs * e);
.....
private: System::Void tabPage1_Paint(System::Object *  sender, System::Windows::Forms::PaintEventArgs *  e)
{
        drawPart1(e);  //works fine when this is the only call
        drawPart2(e);  //crashes when I include this one
}

//graphicForm.cpp=======================
void graphicForm::drawPart1(PaintEventArgs * e)
{
      graphics* pg = e->graphics;
      pg->DrawLine.....(etc.)
}

void graphicForm::drawPart2(PaintEventArgs * e)
{
      graphics* pg = e->graphics;
      pg->DrawLine....(etc.)
}
 

Any ideas as to what is wrong?

ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial