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:


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

void graphicForm::drawPart1(PaintEventArgs * e)
      graphics* pg = e->graphics;

void graphicForm::drawPart2(PaintEventArgs * e)
      graphics* pg = e->graphics;

Any ideas as to what is wrong?

Who is Participating?
I don't see any problem in this code, possibly it is somewhere in etc. part.
Does drawPart2 work when called without drawPart1 ?
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.