Error passing PaintEventArgs to functions

Posted on 2006-04-20
Last Modified: 2012-06-21
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?

Question by:restabro
    1 Comment
    LVL 48

    Accepted Solution

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now