Announcement

Collapse
No announcement yet.

How to hide a window`s nonclient area?

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

  • How to hide a window`s nonclient area?

    Hellow, well estimated Community,

    my (of course as always) non-expert's question:
    Would there be a convenient way of setting a dialog`s nonclient area into a hidden state for setting it' s application into a certain full -screen mode and for resetting it vice-versa.

    Many thanks for help and
    greetings from Germany,
    Heinz Grandjean
    Heinz Grandjean
    http://www.estwgj.com/

  • #2
    You can *try* (that means I have no clue if it's even do-able or not).....

    ..change the window style (SetWindowLong... %GWL_STYLE) to one without a caption bar ( NOT (%WS_SYSMENU OR %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR {I'm sure I have missed some)) at the point at which you'd like the caption area to disappear, and then resetting when it must appear (for sure you will have to add the caption again).

    You also would need to use SetWindowPos... %SWP_FRAMECHANGED to ensure the changed frame style takes effect next time the window is drawn.

    But me, I think I'd just create fresh windows (dialogs) with the correct style at the appropriate time.

    Or maybe.. not even create a caption bar at all... just add a control which "looks like" a caption bar and hide/show it at the appropriate times.

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

    Comment


    • #3
      Heinz,

      Here is an example that should do it,
      tested only under Windows XP.

      Pierre

      Code:
      #COMPILE EXE '#Win 8.04#
      #DIM ALL
      #REGISTER NONE
      #INCLUDE "Win32Api.inc" '#2005-01-27#
       
      %ButtonExit = 101
      %ButtonFlip = 102
       
      %MenuOpen   = 201
      %MenuExit   = 202
      %MenuHelp   = 203
      %MenuAbout  = 204
       
      %StyleCaption = %WS_POPUP OR %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
                      %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
                      %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %WS_BORDER
       
      %StyleFull    = %WS_POPUP OR %WS_THICKFRAME OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
                      %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT
      '______________________________________________________________________________
       
      CALLBACK FUNCTION DlgProc
       STATIC SizeX     AS LONG
       STATIC SizeY     AS LONG
       STATIC PosX      AS LONG
       STATIC PosY      AS LONG
       STATIC Zoomed    AS LONG
       STATIC hMenu     AS DWORD
       STATIC hMenuFile AS DWORD
       STATIC hMenuHelp AS DWORD
       
       SELECT CASE CBMSG
       
         CASE %WM_INITDIALOG                        'This will execute on dialog creation
           DIALOG GET SIZE CBHNDL TO SizeX, SizeY   'Memorize size for future "normal" use
           DIALOG GET LOC CBHNDL TO PosX, PosY      'Memorize location for future "normal" use
           PostMessage CBHNDL, %WM_USER + 401, 0, 0 'Call the create menu routine
       
         CASE %WM_USER + 401 'Create menu routine
           MENU NEW BAR TO hMenu
           MENU NEW POPUP TO hMenuFile
           MENU ADD STRING, hMenuFile, "&Open", %MenuOpen, %MF_ENABLED
           MENU ADD STRING, hMenuFile, "&Exit", %MenuExit, %MF_ENABLED
           MENU ADD POPUP, hMenu, "&File", hMenuFile, %MF_ENABLED
           MENU NEW POPUP TO hMenuHelp
           MENU ADD STRING, hMenuHelp, "&Help", %MenuHelp, %MF_ENABLED
           MENU ADD STRING, hMenuHelp, "&About", %MenuAbout, %MF_ENABLED
           MENU ADD POPUP, hMenu, "&Help", hMenuHelp, %MF_ENABLED
           MENU ATTACH hMenu, CBHNDL
       
         CASE %WM_EXITSIZEMOVE
           DIALOG GET SIZE CBHNDL TO SizeX, SizeY 'Memorize size for future "normal" use
           DIALOG GET LOC CBHNDL TO PosX, PosY    'Memorize location for future "normal" use
       
         CASE %WM_COMMAND
           SELECT CASE LOWRD(CBWPARAM)
       
             CASE %ButtonFlip
               IF CBCTLMSG = %BN_CLICKED THEN
                 IF (GetWindowLong(CBHNDL, %GWL_STYLE) AND %WS_CAPTION) THEN 'If Window with caption
                   RemoveMenu hMenu, 1, %MF_BYPOSITION             'Remove help menu
                   RemoveMenu hMenu, 0, %MF_BYPOSITION             'Remove file menu
                   DestroyMenu hMenu                               'Free memory
                   Zoomed = IsZoomed(CBHNDL)                       'Memorize zoomed window state
                   CONTROL SET TEXT CBHNDL, %ButtonFlip, "Normal"  'Set button text
                   SetWindowLong CBHNDL, %GWL_STYLE, %StyleFull    'Set style with no caption
                   ShowWindow CBHNDL, %SW_SHOWMAXIMIZED            'Maximize window without caption
                 ELSE                                              'Window was not maximized
                   PostMessage CBHNDL, %WM_USER + 401, 0, 0        'Recreate menu
                   SetWindowLong CBHNDL, %GWL_STYLE, %StyleCaption 'Set style with caption
                   DIALOG SET LOC CBHNDL, PosX, PosY               'Put back to old position
                   DIALOG SET SIZE CBHNDL, SizeX, SizeY            'Set back previous size
                   CONTROL SET TEXT CBHNDL, %ButtonFlip, "Full"    'Set button text
                   IF Zoomed THEN
                     ShowWindow CBHNDL, %SW_MAXIMIZE               'Set back "maximized" with caption
                   ELSE
                     ShowWindow CBHNDL, %SW_SHOWNORMAL             'Set back "normal" with caption
                   END IF
                 END IF
               END IF
       
             CASE %ButtonExit, %MenuExit
               IF CBCTLMSG = %BN_CLICKED THEN
                 DIALOG END CBHNDL, 0
               END IF
       
             CASE %MenuOpen, %MenuHelp, %MenuAbout
               IF CBCTLMSG = %BN_CLICKED THEN
                 MSGBOX "Menu id is" & STR$(LOWRD(CBWPARAM))
               END IF
       
           END SELECT
         END SELECT
       
      END FUNCTION
      '______________________________________________________________________________
       
      FUNCTION PBMAIN()
       LOCAL hDlg AS DWORD
       
       DIALOG NEW %HWND_DESKTOP ,"Full screen", , , 120, 70, %StyleCaption, 0 TO hDlg
       SetClassLong hDlg, %GCL_HICON, LoadIcon(BYVAL %NULL, BYVAL %IDI_INFORMATION) 'Set a nice icon
       CONTROL ADD BUTTON, hDlg, %ButtonFlip, "Full", 30, 10, 55, 15
       CONTROL ADD BUTTON, hDlg, %ButtonExit, "Exit", 30, 35, 55, 15
       DIALOG SHOW MODAL hDlg CALL DlgProc
       
      END FUNCTION
      '______________________________________________________________________________
      Last edited by Pierre Bellisle; 1 Nov 2007, 11:35 PM.

      Comment


      • #4
        It works beautyfully

        Thank You Michael und thank You Pierre.

        The main problem is solved.
        The only additional problem I detekted is the impossibility to hide the dialogs main menu!??

        Greetings from Germany,
        Heinz Grandjean
        Heinz Grandjean
        http://www.estwgj.com/

        Comment


        • #5
          Is this an app you created, or another app that you need to modify while it is running that isn't one you made? If you never made a menu, it shouldn't have one...
          sigpic
          Mobile Solutions
          Sys Analyst and Development

          Comment


          • #6
            I had no idea if changing the style like that would work. (Really!)

            So let's see if maybe we can go two-for-two in the 'good guess' department...

            Remove the menu when you maximize and put it back when you un-maximize?

            In SDK style coding it would be "SetMenu hWnd, %NULL" to remove and "SetMenu hWnd, hMenu" to put it back.

            Don't know how to do in DDT off the top of my head. It's probably one of the "MENU xxxx" statements.

            (Since you did not specify 'SDK' or "DDT" style coding, I assumed the default value of "SDK.")

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

            Comment


            • #7
              Heinz,

              Code above is updated, it will take care of menu...

              Comment


              • #8
                Wow! Pretty cool. Sure beats the way I had done it. -John
                LOCAL MyEMail AS STRING
                MyEmail = STRREVERSE$("53pmohtj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")

                Comment


                • #9
                  Very good 'good guess' - department

                  Thanks again for help.
                  Normally I use a mixture of DDT and SDK and I had had never problems with that (good guess).
                  Pierres's example works fine, but the SetMenu does all the work and
                  (good guess again) allows me to manipulate the menu -entries before
                  reactivating them.
                  I need all that for settimg an application in touch-screen mode and vice versa.
                  Thanks and greetings from Germany
                  Heinz Grandjean
                  Heinz Grandjean
                  http://www.estwgj.com/

                  Comment

                  Working...
                  X