Jump to content
  • Advertisement
Sign in to follow this  
stealth

loop problem

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this is the 3rd post about loop problems but this one is different from the others , I was given examples of how to run a loop even when there arent any messages being sent to a window , but I have a small problem, I wanted the loop to show how many times it was being run but in this code it only shows that the loop runs thru once , I'm trying to make it continuously run until the application has finished

    BOOL isRunning = true;    
    int timer = 0;
    char lc[21];


    while(isRunning)
    {
    
    timer++;    
    itoa(timer,lc,20);
    SetWindowText(hEdit,lc);    
    
    if(messages.message == WM_QUIT)
      {
       MessageBox(NULL,"isRunning set to false","Info",MB_OK);
       isRunning = false;
       PostQuitMessage(0);
      }
    
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);

    }    
    }

Share this post


Link to post
Share on other sites
Advertisement
Try writing out a pseudo code translation of your code, carefully working through it and see whats happening.

If you are more the hands on type, print it out and use a pencil.

If that still is not for you, try setting a break point and stepping through the code.

What better way to learn these skills then with a snippet such as this?

- Jacob

Share this post


Link to post
Share on other sites
thanks , I figured it out , well i didnt , I juss made a WM_PAINT and painted some other stuff , and now it works right , thanks for the advice

Share this post


Link to post
Share on other sites
Perhaps you should lookup PeekMessage (IIRC). It'll check to see if a message is waiting or not, and will tell you right away, unlike GetMessage which waits for a message before returning.

I think. HTH

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!