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. How do I stop a do/while loop using a toolbar

How do I stop a do/while loop using a toolbar

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 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.
  • R Offline
    R Offline
    Rno35
    wrote on last edited by
    #1

    Hi, My program needs to stop a do/while loop when the user decides it. I first use a progress dialog bar which works great but it is not convinient. I would like to stop a do/while loop using a button of my toolbar. How can I tell the program to spend sometime checking on the toolbars and menu while it is running within the loop? Thanks, :confused:RNO

    J M 2 Replies Last reply
    0
    • R Rno35

      Hi, My program needs to stop a do/while loop when the user decides it. I first use a progress dialog bar which works great but it is not convinient. I would like to stop a do/while loop using a button of my toolbar. How can I tell the program to spend sometime checking on the toolbars and menu while it is running within the loop? Thanks, :confused:RNO

      J Offline
      J Offline
      jhaga
      wrote on last edited by
      #2

      I use something like this to detect if the user presses a button inside a loop: MSG msg; while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } jhaga --------------------------------- Do not hire a man who does your work for money, but him who does it for love of it. Go confidently in the direction of your dreams! Live the life you've imagined. As you simplify your life, the laws of the universe will be simpler. Do not be too moral. You may cheat yourself out of much life. Aim above morality. Be not simply good; be good for something. -Henry David Thoreau-

      1 Reply Last reply
      0
      • R Rno35

        Hi, My program needs to stop a do/while loop when the user decides it. I first use a progress dialog bar which works great but it is not convinient. I would like to stop a do/while loop using a button of my toolbar. How can I tell the program to spend sometime checking on the toolbars and menu while it is running within the loop? Thanks, :confused:RNO

        M Offline
        M Offline
        MAAK
        wrote on last edited by
        #3

        I think the normal thing to be done in this case is running your do/while loop in a separate thread so you can handle all the messages, including toolbar notifications, from the main application thread normally. Your while loop condition should check on a global variable that is to be changed by the toolbar message to fail the condition.

        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