will I have to place a call to a function that calculates something (for example the next chess move)? Inside the GetMessage Loop? Or will I have to use PeekMessage? Or should I call that chess-function out of WndProc?
This is a discussion on Inside which part of a WinProgramm ... within the Windows Programming forums, part of the Platform Specific Boards category; will I have to place a call to a function that calculates something (for example the next chess move)? Inside ...
will I have to place a call to a function that calculates something (for example the next chess move)? Inside the GetMessage Loop? Or will I have to use PeekMessage? Or should I call that chess-function out of WndProc?
>>Or should I call that chess-function out of WndProc?<<
Yes you should put it there at WndProcThat's the function you should use to handle any events (or commands) in your prog.
Code:LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { /*...other cases here...*/ case WM_COMMAND: switch(wParam) { /*...other cases here too...*/ case ID_CALCULATE_BUTTON: CalculateMove(/*...etc...*/); return 1; /*...you know what comes next...*/ } /*...here too...*/ } }You're making a Chess game?
A chess move will only occur AFTER the users move. Put it in response to the user moving (ie part of the processing of the users move is the computer move).
PeekMessage() will return to the message loop (or pump) if there is no message.
GetMessage() waits until there is a message before returning.
If writing a game like a FPS you need to do things in between the users actions (ie update the monsters actions) so should use PeekMessage()
A chess game can wait until the user responds so I would use GetMessage()
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill