I've figured out how to use the Application.Idle event handler. The only problem I am having is that the application is by default *waiting* for messages before going to idle like usual. When I used the Win32 API i alwasy made my program bypass to idle time if there was no message by using PeekMessage(). How do I get my C# application to behave this way. I can't hope to make a game function properly if it *waits* for messages before idling. Any help would be appreciated
Also to note, I just recently adopted C#. I'm a diehard C++ guy. Hate some of it's limitations (no default parameters ) but I like it's demand for cleanliness.
Color is an integer that starts off at 0 and is supposed to cycle to white. so the window should be very colorful and changing with each idle loop.
Code used to tranform and integer into a Color:
Color
IntToColor(int c){
int r, g, b; r = c >> 16; g = (c >> 8) - (r << 8); b = c - (g << 8) - (r << 16); return Color.FromArgb(0, r, g, b);}
My code:
Application.Idle += new EventHandler(MainForm_Idle);
// As stated above this handler won't execute until some sort of other event raises (mouse, keyboard, etc)
void
MainForm_Idle(object sender, EventArgs e){
gfx.Clear(color); gfx.Swap(); if(color < 0xffffff) color++;}