conflict in windows focus - float menu involved
-
(The title may not be very appropriate to summarise the problem..) 1) I have an little application that checks some stuff on timer. If something occurs, it creates a topmost dialogbox and display certain info (let's call it MyAlarmBox). 2) a control in the application can create a float menu if user R-clicks the mouse.(I use TrackPopupMenu) Usually everythings works fine. But in the following circumstance: 1) user R-clicks the control to get the float menu. 2) before user selects a command, the MyAlarmBox goes off. I end up with the MyAlarmBox on top being not able to receive any mouse click. The workaround is to click any non-this-window area, then come back clicking on the dialog box, the dialog box 'comes alive' again. In short, the float menu and the dialog box are in conflict -- the float menu grabs the 'focus' (this may not be the correct word, please correct me if you could) and does not release it to the newly popped-up dialog box. Anyone can help me solve this???...
-
(The title may not be very appropriate to summarise the problem..) 1) I have an little application that checks some stuff on timer. If something occurs, it creates a topmost dialogbox and display certain info (let's call it MyAlarmBox). 2) a control in the application can create a float menu if user R-clicks the mouse.(I use TrackPopupMenu) Usually everythings works fine. But in the following circumstance: 1) user R-clicks the control to get the float menu. 2) before user selects a command, the MyAlarmBox goes off. I end up with the MyAlarmBox on top being not able to receive any mouse click. The workaround is to click any non-this-window area, then come back clicking on the dialog box, the dialog box 'comes alive' again. In short, the float menu and the dialog box are in conflict -- the float menu grabs the 'focus' (this may not be the correct word, please correct me if you could) and does not release it to the newly popped-up dialog box. Anyone can help me solve this???...
The optimal solution would be to cancel the popup menu when the dialog is displayed, but I cannot find any way of cancelling a menu from the app. Instead, I would block the display of the dialog while you're tracking the menu.
// in response to right clicl bTracking = TRUE; cmd = TrackPopupMenu(...); bTracking = FALSE; // in OnTimer: if (!bTracking) dlg.DoModal(...)
Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music" -
(The title may not be very appropriate to summarise the problem..) 1) I have an little application that checks some stuff on timer. If something occurs, it creates a topmost dialogbox and display certain info (let's call it MyAlarmBox). 2) a control in the application can create a float menu if user R-clicks the mouse.(I use TrackPopupMenu) Usually everythings works fine. But in the following circumstance: 1) user R-clicks the control to get the float menu. 2) before user selects a command, the MyAlarmBox goes off. I end up with the MyAlarmBox on top being not able to receive any mouse click. The workaround is to click any non-this-window area, then come back clicking on the dialog box, the dialog box 'comes alive' again. In short, the float menu and the dialog box are in conflict -- the float menu grabs the 'focus' (this may not be the correct word, please correct me if you could) and does not release it to the newly popped-up dialog box. Anyone can help me solve this???...
-
The optimal solution would be to cancel the popup menu when the dialog is displayed, but I cannot find any way of cancelling a menu from the app. Instead, I would block the display of the dialog while you're tracking the menu.
// in response to right clicl bTracking = TRUE; cmd = TrackPopupMenu(...); bTracking = FALSE; // in OnTimer: if (!bTracking) dlg.DoModal(...)
Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"Thanks! That works. At first I want to find a way to cancel the popmenu but just could not. I was thinking to use event synchronisation (menu and dlg are in different threads) but this seems a simpler solution. It will still be the best way to cancel the menu, because for my case I cannot permanently block the alarm dialog (the user may just pop up the float menu then get distracted, leaving the menu floating there for a long period of time). I am thinking to wait for a few seconds and fire the dialog anyway (the alarm dialog plays sound/music on creating) so that if the user is nearby he/she will be alerted. But so far, I will have to go with the solution you suggested. Thx again pal...
-
Thanks! That works. At first I want to find a way to cancel the popmenu but just could not. I was thinking to use event synchronisation (menu and dlg are in different threads) but this seems a simpler solution. It will still be the best way to cancel the menu, because for my case I cannot permanently block the alarm dialog (the user may just pop up the float menu then get distracted, leaving the menu floating there for a long period of time). I am thinking to wait for a few seconds and fire the dialog anyway (the alarm dialog plays sound/music on creating) so that if the user is nearby he/she will be alerted. But so far, I will have to go with the solution you suggested. Thx again pal...
Hmmm... does this mean the you display UI stuff from two threads? I'm no expert on multithreading, but according to Joseph Newcomer (http://www.flounder.com/workerthreads.htm[^] (who seems to be an expert) you should never ever touch the UI from a worker thread. Instead, you should post a message from the worker thread to the main thread and have the main (UI) thread display the dialog. If you for some reason don't want to change your design you should at least protect the access to the bool variable with a mutex (see http://www.flounder.com/semaphores.htm[^]) Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-
Hmmm... does this mean the you display UI stuff from two threads? I'm no expert on multithreading, but according to Joseph Newcomer (http://www.flounder.com/workerthreads.htm[^] (who seems to be an expert) you should never ever touch the UI from a worker thread. Instead, you should post a message from the worker thread to the main thread and have the main (UI) thread display the dialog. If you for some reason don't want to change your design you should at least protect the access to the bool variable with a mutex (see http://www.flounder.com/semaphores.htm[^]) Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
Actually, I guess you could use the mutex itself in place of the boolean. Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-
How about creating the topmost dialog with GetCapture!!
- Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw