Nested Command Buttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sefrank
    New Member
    • Aug 2006
    • 2

    Nested Command Buttons

    Hi,
    I'm fairly new to VB6 but have programmed in Pascal for years. I have an application which has a start and stop command button. When the start putton is clicked it sets a boolean flag, and starts a while loop until the flag is reset. The reset of the flag comes from the stop command button. Everything I've tried results in the system hanging. How can I perform this function.

    Regards
    Scott
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    I am not a VB expert, but I do know how windows works.

    The problem you have is that your program can only handle 1 message at a time, until you return from the message handler for the Start button no other buttons can be pushed so you will not be able to press the reset button if the loop you are trying to stop is in the context of Start button and UI thread.

    The solution is reasonably simple, when the Start button is pushed start a new thread to perform the operation required, then you can return from the Start button handler and the Stop button will be available to push when you want that operation to finish (or at least that's how I'd do it in C I am fairly sure you can do a similar thing in VB).

    Comment

    • sefrank
      New Member
      • Aug 2006
      • 2

      #3
      Thank you for the input. I was told of a VB6 function called DoEvents. By adding this function into the do loop, the system goes out and checks for events which have occured and processes them. This function is exactly what I was looking for.

      Thank you for your time

      Regards
      Scott

      Comment

      Working...