Prev: Is this Regular Expression for UTF-8 Correct??
Next: Newcomer's CAsyncSocket example: trouble connecting with other clients
From: Eddards on 13 May 2010 16:31 I have an application which when you click one button it goes into a closed loop routine which updates a graph until it finishes its action. I want to disable any mouse clicks during this time because when the operator inadvertently clicks something before the routine finsihes, the display stops updating and an hourglass stays up until the routine finishes. This routine can take as long as 5 minutes. How do I disable mouse clicks during this? Thanks in advance
From: David Ching on 13 May 2010 16:52 "Eddards" <eddards(a)verizon.net> wrote in message news:0ImdnTHYtLoo_HHWnZ2dnUVZ_umdnZ2d(a)giganews.com... > I have an application which when you click one button it goes > into a closed loop routine which updates a graph until it > finishes its action. I want to disable any mouse clicks > during this time because when the operator inadvertently > clicks something before the routine finsihes, the display > stops updating and an hourglass stays up until the routine > finishes. This routine can take as long as 5 minutes. How do > I disable mouse clicks during this? EnableWindow (FALSE); However, the user experience will be just as bad as current. The window is unresponsive regardless. Why don't you do the right thing and move the graph updating to a separate thread or at least pump messages while it is updating so that the window stays responsive? -- David
From: Joseph M. Newcomer on 13 May 2010 18:37 See below... On Thu, 13 May 2010 16:31:50 -0400, "Eddards" <eddards(a)verizon.net> wrote: >I have an application which when you click one button it goes >into a closed loop routine which updates a graph until it >finishes its action. **** Let me say that this is an exceptionally poor design choice. You should not write code that works this way **** >I want to disable any mouse clicks >during this time because when the operator inadvertently >clicks something before the routine finsihes, the display >stops updating and an hourglass stays up until the routine >finishes. **** Write the code so it does not work as you describe. You should not be searching for workarounds for what are actually exceptionally poor design choices. You should redesign the code to work properly in the Windows environment, and you are asking for an impossible workaround kludge to get you around a Really Bad Design Choice. **** >This routine can take as long as 5 minutes. How do >I disable mouse clicks during this? **** You don't. This would be an exceptionally bad design. Run the computation in a thread, and let the thread send notifications about the updates to the main GUI thread, and disable any controls/menu items/toolbar items that are inappropriate. THAT is the correct design! What you have here is a Fundamentally Bad Design, and you should fix it. joe **** >Thanks in advance > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Goran on 14 May 2010 06:09
On May 13, 10:31 pm, "Eddards" <edda...(a)verizon.net> wrote: > I have an application which when you click one button it goes > into a closed loop routine which updates a graph until it > finishes its action. I want to disable any mouse clicks > during this time because when the operator inadvertently > clicks something before the routine finsihes, the display > stops updating and an hourglass stays up until the routine > finishes. This routine can take as long as 5 minutes. How do > I disable mouse clicks during this? As others have said, you are doing it wrong. Mouse clicks are not your problems. The problem is that your message pump, which is what keeps UI alive, is blocked waiting for your routine to finish. Sure, while computing, you are updating a graph (I guess, by forcing it to repaint in some way or another; if this is a third-party graph control, then it might repaint itself when you add data to it, or whatever you do). But any messages that might be sent to your ptogram are blocked, and that is the cause of all sorts of grief. Move computation to another thread. In said thread, post messages to UI thread with whatever partial computation results you might have. When you receive messages in the UI thread, update UI. That's the only correct way to do it. Any other approach is a bigger cludge. Goran. |