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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
I don't see any problem in this code, possibly it is somewhere in etc. part.
Does drawPart2 work when called without drawPart1 ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.