Author Topic: Help with big ass loop and windows messages  (Read 3561 times)

Offline CaptainCPS

  • Administrator
  • *****
  • Posts: 1520
  • Karma: +126/-0
  • FB Alpha Team
    • CaptainCPS's Home
Help with big ass loop and windows messages
« on: September 17, 2008, 02:45:27 am »
Does someone knows how can I make a big ass loop be in sync with an application main message loop ?

My objective is to allow the 'big ass loop' work while checking if the user is moving the window, clicking some button, etc...

The problem I'm having is that if I just call the 'big ass loop' it will go so fast (or slow) that it will not allow the window / application messages to be verified at the correct moment, finally making the window / dialog freeze while the loop finishes.

I managed to find a way to make the loop more flexible with the window using this inside the loop...

UpdateWindow();

but if I click something or at least move another window in front of the working window it will cause a repaint message to be sent and boom the window will freeze while the loops end. If I click somewhere on the window while the loop is going on the window will freeze as well until the loop finishes >___>

If someone know how to make a loop more flexible with window messages I will appreciate the help a lot

I will keep doing my research anyway and if I find a solution and by that time nobody has posted any solution, I will share it so others can learn too ^^.

PS: btw, I think the solution could be making the window an alternate thread so the loop runs separated from it and that way I could probably still be able to send information from inside the loop to the window, like for example update static text controls, etc.

SeeYaa!
 :biggrin:

Offline CaptainCPS

  • Administrator
  • *****
  • Posts: 1520
  • Karma: +126/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Help with big ass loop and windows messages
« Reply #1 on: September 17, 2008, 03:35:39 pm »
I managed to make the big ass loop independent from the window being updated with information, now I can work with the window while the loop is running and it will not freeze or slow down a bit!! ^^...

I don't know if what I did is "proper" coding but I'm sure is damn accurate!  :biggrin:, ...

What I did was basically create a dummy dialog called "IDD_DUMMY" and a process handle for it, then when this message is sent "WM_INITDIALOG", (basically when the window / dialog finish loading) it will call the loop, making it a separate process from the original Dialog!...Oh and the IDD_DUMMY is hidden because nothing has to be displayed or done in there, when the loop finish it will automatically send a "WM_CLOSE" and everything is cool!..I can even use the dummy dialog process for other loops as well, I just have to make a variable switch to know what loop process are we executing ^^

I haven't told what I'm working on but expect something VERY useful for FB Alpha soon!

SeeYaa!
 :biggrin: