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

focusing messagebox

Scheduled Pinned Locked Moved C / C++ / MFC
c++
10 Posts 5 Posters 1 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.
  • G Offline
    G Offline
    gamefreak2291
    wrote on last edited by
    #1

    I'm trying to force a message box to keep keyboard and mouse focus at all times that way the user cannot do anything else until they finish with my program. The console window is hidden and only message boxes are the only thing visible. I'm using Dev-Cpp 4.9.9.2 and Windows XP and sometimes Vista.

    enhzflepE R 2 Replies Last reply
    0
    • G gamefreak2291

      I'm trying to force a message box to keep keyboard and mouse focus at all times that way the user cannot do anything else until they finish with my program. The console window is hidden and only message boxes are the only thing visible. I'm using Dev-Cpp 4.9.9.2 and Windows XP and sometimes Vista.

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      Hint: look into modal dialog boxes.

      G 1 Reply Last reply
      0
      • enhzflepE enhzflep

        Hint: look into modal dialog boxes.

        G Offline
        G Offline
        gamefreak2291
        wrote on last edited by
        #3

        "There used to be a dialog box style (DS_SYSMODAL) that created a dialog box in system modal mode. But it is only there for compatibility with 16bit windows and doesn't prevent the user from clicking other items on the desktop. So I guess you will have to intercept the mouse messages. But even then the user will be able to move through dialogs using the Alt+Tab combination. So you better look at How to Disable Task Switching." Judging from that bit of information Modal dialog boxes would not work effectively.

        _ E 2 Replies Last reply
        0
        • G gamefreak2291

          "There used to be a dialog box style (DS_SYSMODAL) that created a dialog box in system modal mode. But it is only there for compatibility with 16bit windows and doesn't prevent the user from clicking other items on the desktop. So I guess you will have to intercept the mouse messages. But even then the user will be able to move through dialogs using the Alt+Tab combination. So you better look at How to Disable Task Switching." Judging from that bit of information Modal dialog boxes would not work effectively.

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          You can never block Ctrl+Alt+Delete.

          «_Superman_» I love work. It gives me something to do between weekends.

          G 1 Reply Last reply
          0
          • _ _Superman_

            You can never block Ctrl+Alt+Delete.

            «_Superman_» I love work. It gives me something to do between weekends.

            G Offline
            G Offline
            gamefreak2291
            wrote on last edited by
            #5

            No, but I can use BlockInput() to stop all keyboard and mouse use except Ctrl+Alt+Del. I have also been able to have a program repeatedly use BlockInput() so even if the user opens task manager they still can't do anything. But that is besides the point

            _ 1 Reply Last reply
            0
            • G gamefreak2291

              No, but I can use BlockInput() to stop all keyboard and mouse use except Ctrl+Alt+Del. I have also been able to have a program repeatedly use BlockInput() so even if the user opens task manager they still can't do anything. But that is besides the point

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              I don't think that is a good idea. My first thought would be to uninstall the application.

              «_Superman_» I love work. It gives me something to do between weekends.

              1 Reply Last reply
              0
              • G gamefreak2291

                "There used to be a dialog box style (DS_SYSMODAL) that created a dialog box in system modal mode. But it is only there for compatibility with 16bit windows and doesn't prevent the user from clicking other items on the desktop. So I guess you will have to intercept the mouse messages. But even then the user will be able to move through dialogs using the Alt+Tab combination. So you better look at How to Disable Task Switching." Judging from that bit of information Modal dialog boxes would not work effectively.

                E Offline
                E Offline
                Eytukan
                wrote on last edited by
                #7

                I remember that long before I've done that in VB but that's a decade before :P. System-Modal concept is obsolete now in the 32Bit world. You cannot do that. MSDN: NOTE: An equivalent Win32 API function for SetSysModalWindow does not exist. System modal windows contradict the concept of multitasking and thus are not implemented in Win32. May be you can maximize your app screen & make that stay on top of every window.

                SetWindowPos(&this->wndTopMost..

                He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                1 Reply Last reply
                0
                • G gamefreak2291

                  I'm trying to force a message box to keep keyboard and mouse focus at all times that way the user cannot do anything else until they finish with my program. The console window is hidden and only message boxes are the only thing visible. I'm using Dev-Cpp 4.9.9.2 and Windows XP and sometimes Vista.

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #8

                  I don't think you can "keep" the keyboard and mouse focus all times, but you can however keep your message-box on top of other windows by displaying it as system-modal.

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  G 1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    I don't think you can "keep" the keyboard and mouse focus all times, but you can however keep your message-box on top of other windows by displaying it as system-modal.

                    It is a crappy thing, but it's life -^ Carlo Pallini

                    G Offline
                    G Offline
                    gamefreak2291
                    wrote on last edited by
                    #9

                    Well I haven't actually taken any classes so I don't know how to define all the parameters to make a modal box. If you would be so gracious as to get me going feel free.

                    R 1 Reply Last reply
                    0
                    • G gamefreak2291

                      Well I haven't actually taken any classes so I don't know how to define all the parameters to make a modal box. If you would be so gracious as to get me going feel free.

                      R Offline
                      R Offline
                      Rajesh R Subramanian
                      wrote on last edited by
                      #10

                      Well, I am not sure if you just need a modal message box[^] or you would want to keep your application window system modal. If you just need a system modal message box:

                      ::MessageBox(NULL, _T("Message text goes here"), _T("Messagebox Title"), MB_SYSTEMMODAL);

                      The MB_SYSTEMMODAL flag specify that the message box should be system modal (on top of all other windows, until dismissed). If it's your application that you want to set on top of other windows, you could call SetWindowPos()[^] and pass HWND_TOPMOST as the second parameter.

                      It is a crappy thing, but it's life -^ Carlo Pallini

                      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