Jaws's picture

how to use the Application.Idle in windows forms application??

Hello guys:

because the Application.Idle in C# is ok, but how to use it in the windows forms application.

look at the code:

Application::Idle+=gcnew EventHandler(Application1_Idle);

and the error

1>c:\users\bureautique\documents\visual studio 2010\projects\otk\otk\Form1.h(135): error C3867: &'OTK::Form1::Application1_Idle' : liste d'arguments manquante dans l'appel de fonction ; utilisez 'OTK::Form1::Application1_Idle' pour créer un pointeur vers membre

can anyone give me a hand?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

I'm not very familiar with C++/CLI, but I *think* you need to pass the instance of the class explicitly when creating a delegate (unlike C#). Assuming your class is named "Form1" and you are hooking Application::Idle from inside that class, you'd need something like:

Application::Idle += gcnew EventHandler(this, &Form1::Application1_Idle);
Enthused_Dragon's picture

Hi seem to have the same problem in C++/CLI.

//Game Screen OPENTK LOAD
	private: System::Void GameScreen_Load(System::Object^  sender, System::EventArgs^  e) 
			 {
				 loaded = true;
				 //sets screen to named color
				 GL::ClearColor(Color::SkyBlue);
				 //setup view port
				 SetupViewport();
				 //making the "loop"
				 Application::Idle +=  gcnew EventHandler(this, &Form1::Application_Idle);
			 }
 
			 //IDLE FUNCTION
	private: void Application_Idle(System::Object sender, System::EventArgs e)
			 {
				 while(GameScreen->IsIdle)
				 {
					 rotation += 1;
					 Render();
				 }
			 }

I only get this error message:
Error 1 error C3352: 'void OpenTKTest::Form1::Application_Idle(System::Object,System::EventArgs)' : the specified function does not match the delegate type 'void (System::Object ^,System::EventArgs ^)' c:\users\enthused dragon\desktop\opentk test\opentk test\Form1.h 112

Has anyone encountered this before?

EDIT:
Got it working just as I posted. Sorry noob error. :-P