Visual C++ PaintEventArgs
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Visual C++ PaintEventArgs

Threaded View

  1. #1
    Join Date
    Aug 2011
    Posts
    19

    Visual C++ PaintEventArgs

    Hi everyone,
    I followed the example on MSDN, which was very helpful (http://msdn.microsoft.com/en-us/libr...eventargs.aspx).

    However, the problem that I have is that I don't know how to reuse PaintEventArgs over again!

    Once I assigned the "Form" Appearance in its property to have Paint Appearance, then I got the following appeared in my code
    private: void Form1_Paint(System::Object ^ sender, System::Windows::Forms::PaintEventArgs ^ pe)

    And when I followed the example listed on the above link I got it to work.
    But now, I want to define an internal function that keeps doing more stuff, and I did something like this:
    I defined this at a global level:
    Private: System::Windows::Forms::PaintEventArgs my_pe

    And inside the "Form1_paint" function, I added the following line: my_pe = pe

    And then I defined a separate function

    private: void draw_line(double long x, double long y, System::Object ^ sender, System::Windows::Forms::PaintEventArgs ^ pe){
    Pen^ greenPen = gcnew Pen(Color::Green);
    Point startPoint;
    Point endPoint;

    startPoint= Point(20+x, 50+x);
    endPoint = Point(200+y, 300+y);
    pe->Graphics->DrawLine( greenPen, startPoint, endPoint);
    }

    And somewhere else in the code, I am calling the following:

    draw_line(100, 100, sender, my_pe);

    But I get a run time error and doesn't understand (my_pe->Graphics)???


    Can someone please help and tell me how can I actually reuse the PaintEventArgs, such that I can keep calling different function that do different drawings?

    I really appreciate,

    --Rudy
    Last edited by rudy01; January 23rd, 2013 at 10:01 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center