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?

restabroAsked:
Who is Participating?
 
AlexFMCommented:
I don't see any problem in this code, possibly it is somewhere in etc. part.
Does drawPart2 work when called without drawPart1 ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.