Announcement

Collapse
No announcement yet.

Modal "MsgBox"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Modal "MsgBox"

    Is there a API-function that displays a system modal "MsgBox"? There should be only one OK-button exist. All open programs should can no longer be activated.

  • #2
    Yes and no.
    Code:
    int MessageBox(         
        HWND hWnd,
        LPCTSTR lpText,
        LPCTSTR lpCaption,
        UINT uType
    None of the flags offered will prevent the user from activating another window.

    The use of MB_SYSTEMMODAL flag will make the window TOPMOST, but you can still use windows from other applications.

    If you want to prevent the user from using other applications, I'd consider a design change. Maybe you need to make your own "message screen" which is full-screen, not resizeable and topmost. You can still go to another window using <Alt+Tab> but not all users know that.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Is there a possibility the key combination (ALT+TAB) to disable?

      Comment


      • #4
        From Win32 Programmer's Reference:
        MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level windows belonging to the current task are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the current application without suspending other applications.
        Blocking other applications in Windows (which could include Windows itself (like Task Manager)) would be a bad idea. You could get caught in a situation where pulling the power cord is the recourse. Protecting applications from one-another is major difference between NT/2K/XP/Vista and Win 3.x/95/98. One app crashing doesn't lock the system causing loss of unsaved data/corrupted files in other apps.

        Cheers,
        Dale

        Comment


        • #5
          Originally posted by Bernhard Fomm View Post
          Is there a possibility the key combination (ALT+TAB) to disable?
          You could install a keyboard hook using SetWindowsHookEx and checking the virtual keycodes for the keys being pressed. If you're looking at building some kind of kiosk type program, then you'd want to check for ALT+TAB, CTRL+ESC and both the left and right Windows keys (VK_LWIN and VK_RWIN).

          It's also possible to disable task-switching system wide, Google the registry entry under HKEY_CURRENT_USER\Control Panel\Desktop named "Coolswitch".
          Mike Stefanik
          sockettools.com

          Comment


          • #6
            Thanks for helps.

            Can the entire keyboard lock? Only ESC and ENTER should work.

            Comment


            • #7
              Woo. Double post.

              Didn't think that was possible.

              Well, this one can go....
              Last edited by Michael Mattias; 25 Jun 2008, 02:39 PM.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                >Can the entire keyboard lock? Only ESC and ENTER should work

                I hope you are not looking for volunteer testers for this.

                But seriously...

                What are you doing that you think you need to take over the entire machine like this?

                I mean, if this is supposed to be a 'dedicated purpose' machine (like a kiosk) that's fine, but surely there are ways to accomplish that short of the drastic ...

                ...but you already have an answer for that courtesy of Mr. Stefanik.

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  You could remap all your keys in the registry (Really Dumb Idea), or maybe buy a keyboard with only the keys you want...or at least maybe a numpad only model, etc...many better ways to do this.
                  sigpic
                  Mobile Solutions
                  Sys Analyst and Development

                  Comment


                  • #10
                    One thing you could do, is detect your app losing focus (I think....not sure about the app itself, but in a MDI situation you are notified if losing focus), and then restore focus if you lost focus

                    Just a idea....not thought out...just tossing it out there
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment


                    • #11
                      @Cliff

                      Good idea!

                      Comment

                      Working...
                      X