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. Help de-activating system menu in window

Help de-activating system menu in window

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 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.
  • P Offline
    P Offline
    Peter Sjostrom
    wrote on last edited by
    #1

    I've got a problem. Our software processes some messages in a CPropertySheet derived main window class. When a user presses "ALT" key, the system menu is activated, same thing when user click on the top left window icon, the system menu drops down. At this stage, when menu is active/down, the window doesn't process any incoming messages. I have written a separate thread that sends heartbeats to check if this state happens and now want to do somthing to de-activate the menu automatically wthout user intervention. How? I know that if I click somewhere in the window with the mouse, it de-activates the menu and messages gets processed again. (Assume this software is run 24 hours a day and operator forgets to check it. By accident an operator press ALT and leaves. Now I want to detect this and fix the state to normal)

    S 1 Reply Last reply
    0
    • P Peter Sjostrom

      I've got a problem. Our software processes some messages in a CPropertySheet derived main window class. When a user presses "ALT" key, the system menu is activated, same thing when user click on the top left window icon, the system menu drops down. At this stage, when menu is active/down, the window doesn't process any incoming messages. I have written a separate thread that sends heartbeats to check if this state happens and now want to do somthing to de-activate the menu automatically wthout user intervention. How? I know that if I click somewhere in the window with the mouse, it de-activates the menu and messages gets processed again. (Assume this software is run 24 hours a day and operator forgets to check it. By accident an operator press ALT and leaves. Now I want to detect this and fix the state to normal)

      S Offline
      S Offline
      Sir Gras of Berger
      wrote on last edited by
      #2

      IMHO, stuff that needs to be running 24h a day shouldn't be in a UI thread at all. (It probably shouldn't even be in a process that has a UI thread, but in a service.) So put that stuff in a background thread and leave the UI thread to do UI processing only. If you can't because the messages you need to process are real windows messages (and you can't change that), process them with a different, hidden window -- which you could put in a different UI thread, though I'm not sure that's necessary. If you take the approach that you want to detect a stalled situation and terminate it, you have to make sure you identify all possible stall situations ahead of time. You've identified one already, and even if there aren't any others now, you or someone else might add one in the future. By using a different thread and/or window, you're more likely to be able to handle all possible stall situations without failing to process the incoming messages. The UI will get out of sync with data perhaps, but the messages will still be processed.

      P 1 Reply Last reply
      0
      • S Sir Gras of Berger

        IMHO, stuff that needs to be running 24h a day shouldn't be in a UI thread at all. (It probably shouldn't even be in a process that has a UI thread, but in a service.) So put that stuff in a background thread and leave the UI thread to do UI processing only. If you can't because the messages you need to process are real windows messages (and you can't change that), process them with a different, hidden window -- which you could put in a different UI thread, though I'm not sure that's necessary. If you take the approach that you want to detect a stalled situation and terminate it, you have to make sure you identify all possible stall situations ahead of time. You've identified one already, and even if there aren't any others now, you or someone else might add one in the future. By using a different thread and/or window, you're more likely to be able to handle all possible stall situations without failing to process the incoming messages. The UI will get out of sync with data perhaps, but the messages will still be processed.

        P Offline
        P Offline
        Peter Sjostrom
        wrote on last edited by
        #3

        You are right and I agree. However, the code is 6 years old and very complex (read bad). I was just hoping someone had a solution so I won't have to re-write all this code, also risking introducing bugs. Oh, well, off we go...

        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