Announcement

Collapse
No announcement yet.

Alt-F4 to get out of an example DIALOG

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

  • Alt-F4 to get out of an example DIALOG

    Here's a newbie tip I learned the hard way. When testing the DIALOG statements I created several apps which had no way to close the Dialog with a mouse.

    Like this:
    Code:
       #Compile Exe
       Global hDlg As Dword
       Function PBMain() As Long
          Dialog New Pixels, 0, "",300,300,200,200 To hDlg
          Dialog Show Modal hDlg
       End Function
    I had to remember that Alt-F4 would close the window for me.

    Is there a PBWin compiler way to close a window with no mouse exit options?

  • #2
    Patient ---> "Doc, my arm hurts when I do this"
    Doc ---> "Well don't do that then"


    Honestly though interesting question, but one that could lead to knowledge, often overlooked by just adding "Default" properties to the dialog

    (By "Default" I mean, you can normally see "Hide/Maximize/Close" if the properties are set....but somewhere (not the docs I have found) show how each of these are added, just that they are used))

    A PB key combination would be lesser-known, but interesting if one existed or if you would have to code one yourself (and if coding one yourself, then you would have to be the one to add the code to recognize the key combination)
    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


    • #3
      You can process %WM_SYSCOMMAND in your dialog's callback function:
      Code:
         CASE %WM_SYSCOMMAND
            IF (CB.WPARAM AND &HFFF0) = %SC_CLOSE THEN
               IF MSGBOX( "Do you want to close the window?", %MB_YESNO, "App Name") = %IDNO THEN FUNCTION = %True
            END IF
      Bernard Ertl
      InterPlan Systems

      Comment


      • #4
        "Alt+F4 = Exit" s considered part of the 'standard Windows user interface' so you'd better get used to it.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Remembering that Alt-F4 can be used to close the active window isn't so hard with a little practice..(smile).

          One alternate strategy is to use a standard template for your test programs.
          If the template includes a style of %WS_SYSMENU, the [X] close button is available (well ok, that's a mouse
          option so you'd have to remember that Alt-Space opens the system menu for a keyboard solution!)

          Another (no style?) option is to include a minimal CallBack Function so that the Escape button can close the dialog ..
          '
          Code:
          #Compile Exe
          #Dim All
           
          CallBack Function DlgProc()
            If CbMsg = &h111 then       ' %WM_COMMAND equate is built-in to PBWin90 but earlier versions need Win32API.inc
              If CbCtl = 2 Then         ' %IDCANCEL, also built-in to PBWin90, is sent to a dialog when the Esc key is pressed
                Dialog End CbHndl       ' (like %IDOK is sent when the Enter key is pressed)
              End If
            End If
          End Function                  
          '------------------/DlgProc
           
           Global hDlg As Dword
          Function PBMain() As Long
            Dialog New Pixels, 0, "Alt-F4 or Esc to exit",300,300,200,200 To hDlg
            Dialog Show Modal hDlg, Call DlgProc
          End Function
          '------------------/PbMain
          '
          Rgds, Dave

          Comment


          • #6
            Originally posted by Gary Beene View Post
            Is there a PBWin compiler way to close a window with no mouse exit options?
            I misread the question. In your callback function, you can also use:
            Code:
            CASE %WM_COMMAND
               SELECT CASE AS LONG CB.CTL
                  CASE %IDCANCEL
                     DIALOG END CB.HNDL, 0   'Process Esc key
            Bernard Ertl
            InterPlan Systems

            Comment


            • #7
              Exit without the mouse...

              If the window/dialog has a system menu, Alt+Spacebar, C


              FWIW:in Windows' (XP) "help and support" type in "keyboard shortcuts" and you will find a VERY long list of same... both to use yourself and to be prepared to have your users employ.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment

              Working...
              X