Calling function that PaintEventArgs and other parameters C++?

Hi Everyone, I have the following code...

Private: System::Void formPaint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e, int intValue){

}

private: System::Void drawPoints(){
panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &MyForm::formPaint(1234));

}

I want to pass some variables across like the one above. The function 'formPaint' will be used to paint onto a panel on a form but it won't work, can someone show me how?

cheers
Last edited on
You can't pass your own variables to an PaintEventHandler. The PaintEventHandler only accepts an Object^ and an PaintEventArgs^ argument.

Try this:
1
2
3
4
5
6
7
8
9
10
11
12
System::Void panel1_Paint(Object^ sender, PaintEventArgs^  e) 
   {
     formPaint(sender, e, 1234);
   }
   System::Void Form1_Load(Object^ sender, EventArgs^  e) 
   {
     panel1->Paint += gcnew PaintEventHandler(this, &Form1::panel1_Paint);
   }
   System::Void formPaint(Object^ sender, PaintEventArgs^ e, int intValue)
   {
    // TODO do your painting here
   }


Cool thanks Thomas1965! :)
Topic archived. No new replies allowed.