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. Infinite loop ??

Infinite loop ??

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
5 Posts 5 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.
  • S Offline
    S Offline
    Spank me
    wrote on last edited by
    #1

    Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0), but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed Thanks for your help! Loren:

    Z H T G 4 Replies Last reply
    0
    • S Spank me

      Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0), but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed Thanks for your help! Loren:

      Z Offline
      Z Offline
      zarzor
      wrote on last edited by
      #2

      Have you ever seen my article: "Take user's action for loop forever" ? well, you can see it in programming tips. ZARZOR13

      1 Reply Last reply
      0
      • S Spank me

        Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0), but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed Thanks for your help! Loren:

        H Offline
        H Offline
        Henry miller
        wrote on last edited by
        #3

        I'm pretty sure there is something trivial that you are missing, but I don't do windows event loops enough to tell you what. As an alternative, that might be better: have you considered using threads? use one thread to read this message, and when it changes post a message to the main thread. (In some systems you can update the window from that thread, I'm not sure about windows) Threads have their own problems, and are difficult to work with on some levels, but it might be better.

        1 Reply Last reply
        0
        • S Spank me

          Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0), but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed Thanks for your help! Loren:

          T Offline
          T Offline
          Tom Wright
          wrote on last edited by
          #4

          Loren, Have you thought about using the timer event. In the OnInitDlg section of your code you could create a timer that calls the OnTimer event. Have it run every second. Then you can let the rest of your program do what you want it to do. I have this running a clock in a status bar. Work great. Tom Wright tawright915@yahoo.com

          1 Reply Last reply
          0
          • S Spank me

            Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0), but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed Thanks for your help! Loren:

            G Offline
            G Offline
            gamitech
            wrote on last edited by
            #5

            Have you considered using windows hooks ? gabby

            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