Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Finding a location for a function that would cause it to get called on a constant basis

Finding a location for a function that would cause it to get called on a constant basis

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 2 Posters 33 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Calin Negru
    wrote on last edited by
    #1

    I tried placing the UpdateGame() function inside the window message processing loop but the execution never reaches that spot

    while (WM_QUIT != msg.message)
    {
    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);

    }
    else
    {
    	 UpdateGame();
    }
    

    }

    I`m trying to mix code from two different tutorials which might be the cause of the problem. Bellow is what the initial message processing loop looked like.

    while (GetMessage(&msg, nullptr, 0, 0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);

    }

    K 1 Reply Last reply
    0
    • C Calin Negru

      I tried placing the UpdateGame() function inside the window message processing loop but the execution never reaches that spot

      while (WM_QUIT != msg.message)
      {
      if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);

      }
      else
      {
      	 UpdateGame();
      }
      

      }

      I`m trying to mix code from two different tutorials which might be the cause of the problem. Bellow is what the initial message processing loop looked like.

      while (GetMessage(&msg, nullptr, 0, 0))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);

      }

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      At a guess PeekMessage() is always returning true. If you want UpdateGame() to always be called then remove it from the else block:

      while (WM_QUIT != msg.message)
      {
      if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);

      }
      UpdateGame();
      

      }

      "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

      C 1 Reply Last reply
      0
      • K k5054

        At a guess PeekMessage() is always returning true. If you want UpdateGame() to always be called then remove it from the else block:

        while (WM_QUIT != msg.message)
        {
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
        TranslateMessage(&msg);
        DispatchMessage(&msg);

        }
        UpdateGame();
        

        }

        "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

        C Offline
        C Offline
        Calin Negru
        wrote on last edited by
        #3

        Thanks for advice, I’ll give it a try

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups