Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalmultiply displays Pin
Shotgun3-Feb-03 12:38
Shotgun3-Feb-03 12:38 
GeneralRe: multiply displays Pin
Michael Dunn3-Feb-03 12:49
sitebuilderMichael Dunn3-Feb-03 12:49 
GeneralControl Loop.. Pin
JamesLaing3-Feb-03 12:26
JamesLaing3-Feb-03 12:26 
GeneralRe: Control Loop.. Pin
LiquidKnight3-Feb-03 12:47
LiquidKnight3-Feb-03 12:47 
GeneralRe: Control Loop.. Pin
Brad Jennings3-Feb-03 17:58
Brad Jennings3-Feb-03 17:58 
GeneralRe: Control Loop.. Pin
Brad Jennings3-Feb-03 18:04
Brad Jennings3-Feb-03 18:04 
GeneralRe: Control Loop.. Pin
JamesLaing4-Feb-03 1:02
JamesLaing4-Feb-03 1:02 
GeneralRe: Control Loop.. Pin
Paul M Watt4-Feb-03 21:09
mentorPaul M Watt4-Feb-03 21:09 
The trick is for a game processing loop, is that you want to update your graphics after all of the input has been processed.

In MFC, the processing loop is hidden from you, but you could always override the PretranslateMessage function, but that could get a little messy. Other than that, I am not an MFC guru so I do not know the simple way to change the message processing loop in MFC.

If you go for a plain Win32 implementation, that would be a lot easier. Your message pump should look something like this:
while (TRUE)
{

    if (PeekMessage( &m_msg, NULL, 0, 0, PM_REMOVE))
    {
        //C: Check for the WM_QUIT message to exit the loop.
        if (WM_QUIT == m_msg.message)
        {
            break;      // WM_QUIT, exit message loop
        }
        //C: Attmpt to translate and dispatch the messages.
        if(!PreTranslateMessage(&m_msg))
        {
            ::TranslateMessage(&m_msg);
            ::DispatchMessage(&m_msg);
        }
    }
    else
    {
        OnUpdateFrame();
    }


You should use PeekMessage because GetMessage blocks until a message becomes available. There are other things that I omitted from this loop that will help your idle processing and when the game is paused.

If you are adventurous, and understand C++ templates, you may want to checkout WTL. I wrote a full version of Tetris in DirectX for this, and there is a base window that you could use to start your version.

I also wrote a class that is a modified gameloop for WTL, so you would not have to mess with this. This code can be found here: WTL GameLoop[^], and my Tetris game can be found here: Tetris[^]

Good Luck


Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!

QuestionWhat would be "about" the starting salary of someone Pin
LiquidKnight3-Feb-03 12:18
LiquidKnight3-Feb-03 12:18 
AnswerRe: What would be "about" the starting salary of someone Pin
Benny R3-Feb-03 12:33
sussBenny R3-Feb-03 12:33 
GeneralRe: What would be "about" the starting salary of someone Pin
LiquidKnight3-Feb-03 12:37
LiquidKnight3-Feb-03 12:37 
GeneralRe: What would be "about" the starting salary of someone Pin
Steve Mayfield3-Feb-03 13:16
Steve Mayfield3-Feb-03 13:16 
GeneralRe: What would be "about" the starting salary of someone Pin
Michael P Butler4-Feb-03 1:49
Michael P Butler4-Feb-03 1:49 
AnswerRe: What would be "about" the starting salary of someone Pin
Paul M Watt3-Feb-03 13:24
mentorPaul M Watt3-Feb-03 13:24 
AnswerRe: What would be "about" the starting salary of someone Pin
Michael P Butler4-Feb-03 1:07
Michael P Butler4-Feb-03 1:07 
GeneralDoes anyone have an tutorials on using SQL and C++.. Pin
IrishSonic3-Feb-03 11:12
IrishSonic3-Feb-03 11:12 
GeneralRe: Does anyone have an tutorials on using SQL and C++.. Pin
Chris Losinger3-Feb-03 11:37
professionalChris Losinger3-Feb-03 11:37 
QuestionSDI / MDI superclass? Pin
brigham_young3-Feb-03 11:05
brigham_young3-Feb-03 11:05 
Generalmdi help Pin
Michael Shuster3-Feb-03 10:54
Michael Shuster3-Feb-03 10:54 
GeneralRe: mdi help Pin
AlexO3-Feb-03 10:57
AlexO3-Feb-03 10:57 
GeneralRe: mdi help Pin
Michael Shuster3-Feb-03 11:07
Michael Shuster3-Feb-03 11:07 
GeneralRe: mdi help Pin
Chris Richardson3-Feb-03 11:35
Chris Richardson3-Feb-03 11:35 
GeneralRe: mdi help Pin
Michael Shuster3-Feb-03 13:13
Michael Shuster3-Feb-03 13:13 
GeneralRe: mdi help Pin
Roger Allen4-Feb-03 3:15
Roger Allen4-Feb-03 3:15 
QuestionOwnerdraw and white border on XP? Pin
Moak3-Feb-03 8:39
Moak3-Feb-03 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.