Announcement

Collapse
No announcement yet.

[Win+D] without %WS_MINIMIZEBOX

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

    [Win+D] without %WS_MINIMIZEBOX

    Hello everyone,
    the situation is as follows:
    I have a Dialog Box with style constant %WS_MINIMIZEBOX. After pressing the Windows hotkey [Win Logo + D] expectedly causes the messages:
    %WM_SIZE (lParam)
    or
    %WM_SYSCOMMAND (wParam)
    This allows control of the dialog when hiding and/or showing on the screen.

    The same dialog WITHOUT the %WS_MINIMIZEBOX constant hides after [Win Logo + D], but I can't intercept (control) it by hiding and/or showing it on the screen because the above messages are not generated.

    Any ideas on the matter?​

    #2
    That is exactly correct operation for with, and without, %WS_MINIMIZEBOX. That is what that style is for.

    Small note - minimize is not "hiding". DIALOG HIDE is a separate statement. (so also see DIALOG NORMALIZE)

    added - Is hide what you want to do?

    more added - Here [Win + D] minimizes all program's windows, another [Win + D] restores "normalizes" all the program's windows. If window without %WS_MINIMIZEBOX was behind before, it will be behind after. If you want to do something to a particular window you'll need a different hot-key.

    Cheers,
    Dale

    Comment


      #3
      WIn+D is actually a system registered shortcut key to WIndows Explorer which responds by minimising or restoring all visible windows unchanged.

      IMNSHO, interfering with this standard Windows behaviour is a "bad thing"™
      =========================
      https://camcopng.com
      =========================

      Comment


        #4
        Dale Yarker,
        Thanks for the reply.
        Sorry, I'm not precise "hide" and "show" are "minimize" and "restore" - of course in this case.

        Stuart McLachlan,
        That's exactly what it's about.
        I don't want to change the action of the system Win+D:
        Step 1 - Minimize;
        Step 2 - Restore.
        I would like to control the result of its action for dialogs in my application.
        Control means, for example, the delay in the appearance of dialogs in my application during "restore" (Step 2) for 1 second. This works fine (see Post #1) for dialogs in my application with style constant %WS_MINIMIZEBOX.
        THE PROBLEM is how to do the same (delay the appearance on "restore" (Step 2) of the dialogs in my application by 1 sec.) for dialogs without the style constant %WS_MINIMIZEBOX.​

        Comment


          #5
          I figured there must be a message so tried WM_RESTORE at Google. Apparently there is no such message, but top return was:
          WM_SHOWWINDOW message (Winuser.h) - Win32 apps | Microsoft Learn
          Maybe a delay exiting your callback for that message will delay the "showing" of the window.
          Or add -
          DIALOG HIDE
          SLEEP 1000
          DIALOG NORMALIZE
          (in the case of whatever message is correct)
          ((on second thought- if HIDE and NORMALIZE cause windows to send the same message, an infinite loop is created))

          Something to think about till something better is posted.

          Cheers,
          Last edited by Dale Yarker; 3 May 2023, 02:02 AM.
          Dale

          Comment


            #6
            Is possible to trap %WM_ACTIVATEAPP and restore dialog, but quick test shows dialog need %WS_MINIMIZEBOX style so we need to use GetWindowLong/SetWindowLong to add and remove %WS_MINIMIZEBOX style during operation. But there are issues with %WM_ACTIVATEAPP, like it is triggered also when clicking outside dialog. This works (but I would not use it...)
            '
            Code:
            '====================================================================
            #COMPILE EXE
            #DIM ALL
            #INCLUDE "WIN32API.INC"
            
            '====================================================================
            FUNCTION PBMAIN () AS LONG
              LOCAL hDlg AS DWORD
              DIALOG NEW 0, "No System Minimize Test",,, 220, 140, _
                         %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
              '------------------------------------------------------------------
              DIALOG SHOW MODAL hDlg CALL DlgProc
            END FUNCTION
            
            '====================================================================
            CALLBACK FUNCTION DlgProc() AS LONG
            
              SELECT CASE AS LONG CB.MSG
              CASE %WM_ACTIVATEAPP
                 IF CB.WPARAM = 0 THEN
                    LOCAL dwRes AS DWORD
                    dwRes = GetWindowLong(CB.HNDL, %GWL_STYLE)  ' grab style
                    SetWindowLong(CB.HNDL, %GWL_STYLE, dwRes OR %WS_MINIMIZEBOX)      ' add minimizebox
                    ShowWindow CB.HNDL, %SW_MINIMIZE   ' repeat
                    ShowWindow CB.HNDL, %SW_SHOWNORMAL ' and restore
                    SetWindowLong(CB.HNDL, %GWL_STYLE, dwRes AND NOT %WS_MINIMIZEBOX) ' remove box
                    PostMessage CB.HNDL, %WM_USER, CB.WPARAM, CB.LPARAM
                 END IF
            
              CASE %WM_USER  ' need a PostMessage stunt to return focus to dialog...
                 SetFocus CB.HNDL
            
              END SELECT
            END FUNCTION
            '

            Comment


              #7
              Borje Hagsten, thank you!
              I don't want to ban Step 1 - minimize. In Step 2 - normalize to delay the eventual appearance of these dialogs without the style constant %WS_MINIMIZEBOX.

              Some test results...
              Trapped messages: %WM_SIZE, %WM_SHOWWINDOW, %WM_WINDOWPOSCHANGING

              Test with Dialog with the style constant %WS_MINIMIZEBOX.
              Win+D - Step 1
              1. %WM_WINDOWPOSCHANGING > Flag (%SWP_NOACTIVATE OR %SWP_DRAWFRAME OR %SWP_SHOWWINDOW OR %SWP_NOCOPYBITS
              2. %WM_SIZE > Minimize
              ​Win+D - Step 2
              3. %WM_WINDOWPOSCHANGING > Flag (%SWP_NOSIZE OR %SWP_NOMOVE OR %SWP_NOACTIVATE)
              4. %WM_WINDOWPOSCHANGING > Flag (%SWP_NOACTIVATE OR %SWP_DRAWFRAME OR %SWP_NOCOPYBITS)
              5. %WM_SIZE > Size

              With the messages in this case, I am fine - I achieve the desired effect!

              Test with Dialog without the style constant %WS_MINIMIZEBOX.
              Win+D - Step 1
              ... nothing ...
              Win+D - Step 2
              ... nothing ...

              Is this style of dialogue the problem?!

              Comment


                #8
                If you want your dialog to be invisible, you can just move it off screen, to something like -900,-900.
                The world is strange and wonderful.*
                I reserve the right to be horrifically wrong.
                Please maintain a safe following distance.
                *wonderful sold separately.

                Comment


                  #9
                  Kurt Kuzba,
                  This is how the delay works when styled with constant %WS_MINIMIZEBOX.
                  With a style without constant %WS_MINIMIZEBOX I can't catch an event (message) to do this.​

                  Comment


                    #10
                    Originally posted by Plamen Chobanov View Post
                    Kurt Kuzba,
                    This is how the delay works when styled with constant %WS_MINIMIZEBOX.
                    With a style without constant %WS_MINIMIZEBOX I can't catch an event (message) to do this.​
                    Since DDT is proprietary, we have no idea how BOB designed it to work when different styles are applied. Apparently it discards those events before they get to the callback.
                    =========================
                    https://camcopng.com
                    =========================

                    Comment


                      #11
                      Stuart McLachlan,
                      ... above the results are for API style (dialogs read from RC file).

                      p.s. I thought the same thing and changed the approach (from DDT to API) in my test app.​​

                      Comment


                        #12
                        Originally posted by Plamen Chobanov View Post
                        Kurt Kuzba,
                        This is how the delay works when styled with constant %WS_MINIMIZEBOX.
                        With a style without constant %WS_MINIMIZEBOX I can't catch an event (message) to do this.​
                        Sure. But if you want, as it seems from the discussion above,
                        to have it only seen on the taskbar, and not to have a screen presence,
                        then just making it not have a screen presence would seem to be the
                        easiest way to go about it, rather than enforced minimization.
                        The world is strange and wonderful.*
                        I reserve the right to be horrifically wrong.
                        Please maintain a safe following distance.
                        *wonderful sold separately.

                        Comment


                          #13
                          DDT "eats" some messages, but solution is usually by subclassing a dialog. Don't know if it can be used to solve this problem, but SetWindowLong() and a SubClassProc...

                          Comment


                            #14
                            There is a subclass demo in PB's \samples\ folder.
                            Dale

                            Comment

                            Working...
                            X
                            😀
                            🥰
                            🤢
                            😎
                            😡
                            👍
                            👎