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. conflict in windows focus - float menu involved

conflict in windows focus - float menu involved

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
7 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.
  • L Offline
    L Offline
    Laffis
    wrote on last edited by
    #1

    (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???...

    S N 2 Replies Last reply
    0
    • L Laffis

      (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???...

      S Offline
      S Offline
      Steen Krogsgaard
      wrote on last edited by
      #2

      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"

      L 1 Reply Last reply
      0
      • L Laffis

        (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???...

        N Offline
        N Offline
        Nilesh K
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • S Steen Krogsgaard

          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"

          L Offline
          L Offline
          Laffis
          wrote on last edited by
          #4

          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...

          S 1 Reply Last reply
          0
          • L Laffis

            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...

            S Offline
            S Offline
            Steen Krogsgaard
            wrote on last edited by
            #5

            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"

            S 1 Reply Last reply
            0
            • S Steen Krogsgaard

              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"

              S Offline
              S Offline
              Steen Krogsgaard
              wrote on last edited by
              #6

              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"

              1 Reply Last reply
              0
              • N Nilesh K

                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

                L Offline
                L Offline
                Laffis
                wrote on last edited by
                #7

                I guess you mean SetCapture. Does it work for you? It does not for me...

                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