Announcement

Collapse
No announcement yet.

Maximize weirdness..

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

  • Maximize weirdness..

    Maybe it's just in my system, but - always when I maximize a program,
    bottom ends up two pixels below taskbar top. Same for all app's, except
    one, a 16-bit Word Processor I once wrote. That one resizes properly
    on maximize and leaves a clear 3D border against taskbar. Weird..

    So I tried to fix my 32-bit PB app's by trapping %WM_GETMINMAXINFO and
    decrease ptMaxSize. Looked at given values and discovered ptMaxSize.y
    is set to screen height + 8. However, nothing changes until I reset it
    to a value below screen height - taskbar height.

    Then it works, but now I suddenly get a max that is a couple of pixels
    above taskbar? Tried to do same stunt in %WM_WINDOWPOSCHANGING and
    %WM_WINDOWPOSCHANGED, but same result - either a couple of pixels below
    or above, never exact.

    Seems like Windows does additional calculation after all messages are
    sent and then misses 2 pixels. Funny that my 16-bit app' manages to
    fool Windows - indicates it's a 32-bit "issue". Even funnier is that
    not all 16-bit app's handles it properly, only that one. Indicates it
    isn't just a 32-bit issue after all. Sigh..

    Maybe it is a Win95/98 thing only? Not really important, but would be
    fun to find a fix for it. Made a small test if anyone is interested.
    Taskbar needs to be at bottom for this one..
    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' DDT TEMPLARE
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    DECLARE CALLBACK FUNCTION DlgCallback()
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' PBMAIN - build dialog and controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN
      LOCAL hDlg AS LONG
      DIALOG NEW 0, "Maximize test",,, 240, 100, %WS_OVERLAPPEDWINDOW TO hDlg
      DIALOG SHOW MODAL hDlg CALL DlgCallback
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' MAIN DIALOG'S CALLBACK PROCEDURE
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgCallback()
       SELECT CASE CBMSG
        CASE %WM_GETMINMAXINFO
            LOCAL rc AS RECT, mmi AS MINMAXINFO PTR
            SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(rc), 0
            mmi = CBLPARAM
            MSGBOX "@mmi.ptMaxSize.y =" + STR$(@mmi.ptMaxSize.y) + $CRLF + _
                   "rc.nBottom =" + STR$(rc.nBottom)
            @mmi.ptMaxSize.y = rc.nBottom - 1 'change to -0 and see what happens, in spite the
                                              'fact that rc.nBottom is much less that mmi value..
     
       END SELECT
    END FUNCTION

    ------------------

  • #2
    I've never noticed anything weird, but I'd be willing to give it a shot..
    This is what Winlog does on WM_SIZE:

    Code:
        Case %WM_SIZE
            Local Xsize           As Long
            Local Ysize           As Long
            GetClientRect g_hWndMain, WndRect
            Xsize = WndRect.nRight - WndRect.nLeft
            Ysize = WndRect.nBottom - WndRect.nTop
            If IsWindowVisible(g_hStatus) Then
                SendMessage g_hStatus, %WM_SIZE, wParam, lParam
                ShowWindow g_hStatus, %SW_NORMAL
                If IsWindowVisible(g_hListView) Then SetWindowPos g_hListView, 0, 0, 0, XSize, YSize-20, %SWP_NOMOVE Or %SWP_NOZORDER Or %SWP_DRAWFRAME
            Else
                If IsWindowVisible(g_hListView) Then SetWindowPos g_hListView, 0, 0, 0, XSize, YSize, %SWP_NOMOVE Or %SWP_NOZORDER Or %SWP_DRAWFRAME
            End If
            Function = 0
            Exit Function
    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    http://www.tngbbs.com/ccs
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      Borje --
      "Maximized" is enough specific everywhere.
      In 'serious' apps I do something like this
      Code:
         #Compile Exe
         #Register None
         #Dim All
         #Include "WIN32API.INC"
      
         CallBack Function DlgProc
            Static mState As Long, rcNormal As RECT
            Select Case CbMsg
               Case %WM_SYSCOMMAND
                  Local rc As RECT
                  If (CbWparam And &HFFF0) = %SC_MAXIMIZE Then
                     If mState = 0 Then GetWindowRect CbHndl, rcNormal: _
                        SystemParametersInfo %SPI_GETWORKAREA, 0, ByVal VarPtr(rc), 0 Else rc = rcNormal
                     mState = 1 - mState
                     SetWindowPos CbHndl, 0, rc.nLeft, rc.nTop, rc.nRight - rc.nLeft, rc.nBottom - rc.nTop, _
                        %SWP_NOZORDER Or %SWP_NOACTIVATE
                     Function = 1
                  End If
            End Select
         End Function
      
         Function PbMain
            Local hDlg As Long
            Dialog New 0, "Maximize test",,, 240, 100, %WS_OVERLAPPEDWINDOW  To hDlg
            Dialog Show Modal hDlg Call DlgProc
         End Function
      Actually I use owner-drawn buttons for caption, so show "maximize/restore" button correctly (unlike this sample).



      ------------------
      E-MAIL: [email protected]

      Comment


      • #4
        Semen - have said it before, but worth repeating: You sir, are a true genious!
        Works exactly as I want. Changed left, top and right slightly to exactly mimic
        Windows original there (-4) and can set bottom so 3D border is shown. Woaw,
        not even MS app's handles this correctly, but now my/our PB app's can do. Neat!

        Here's what I will use - THANK YOU!
        Code:
               Case %WM_SYSCOMMAND
                  Local rc As RECT : STATIC rcNormal AS RECT, mState AS LONG
                  If (CbWparam And &HFFF0) = %SC_MAXIMIZE Then
                     If mState = 0 Then
                        GetWindowRect CbHndl, rcNormal
                        SystemParametersInfo %SPI_GETWORKAREA, 0, ByVal VarPtr(rc), 0
                        rc.nLeft = rc.nLeft - 4    'Windows defaults -4, to avoid showing borders..
                        rc.nTop = rc.nTop - 4
                        rc.nRight = rc.nRight + 4
                        rc.nBottom = rc.nBottom + 1 'should be no increase, but this gives neater look..
                      Else
                         rc = rcNormal
                      END IF
                     mState = 1 - mState
                     SetWindowPos CbHndl, 0, rc.nLeft, rc.nTop, _
                                  rc.nRight - rc.nLeft, rc.nBottom - rc.nTop, _
                                  %SWP_NOZORDER Or %SWP_NOACTIVATE
                     Function = 1
                  End If

        ------------------

        Comment


        • #5
          Think I understand why Windows hides 3D border against taskbar. Is
          probably because MS think maximize *is* maximize and should never
          be possible to resize. If border is visible, possible to resize.
          Must be why they also set other borders outside screen (-4).

          Probably just lazy MS - they could have solved this better. Also found
          that 16-bit app's talk another dialect and can fool 32-bit system. In
          my 16-bit code, I do WM_MDIMAXIMIZE on MDI parent in WM_SIZE, and that
          gives same result as Semen's solution, but with similar 32-bit code,
          it does not.

          One backside of Semen's solution is visible sizegrips. System must be told
          window is maximized, but then system overrides resize and sets own maximize
          again. Don't understand Windows, so think I'll skip it, at least for now.
          Not really important..

          BTW, here's more complete code that handles different taskbar positions.
          Code:
                 Case %WM_SYSCOMMAND
                    If (CbWparam And &HFFF0) = %SC_MAXIMIZE Then
                       Local rc As RECT : STATIC rcNormal AS RECT, mState AS LONG
                       If mState = 0 Then
                          GetWindowRect CbHndl, rcNormal
                          SystemParametersInfo %SPI_GETWORKAREA, 0, ByVal VarPtr(rc), 0
                          rc.nLeft = rc.nLeft - 4
                          rc.nTop = rc.nTop - 4
                          rc.nRight = rc.nRight + 4
                          rc.nBottom = rc.nBottom + 4
           
                          IF rc.nBottom - 4 < GetSystemMetrics(%SM_CYSCREEN) THEN
                             rc.nBottom = rc.nBottom - 3
                          ELSEIF rc.nRight - 4 < GetSystemMetrics(%SM_CXSCREEN) THEN
                             rc.nRight = rc.nRight - 3
                          ELSEIF rc.nTop + 4 > 0 THEN
                             rc.nTop = rc.nTop + 3
                             rc.nBottom = rc.nBottom - 4
                          ELSEIF rc.nLeft + 4 > 0 THEN
                             rc.nLeft = rc.nLeft + 3
                          END IF
           
                        Else
                           rc = rcNormal
                        END IF
                       mState = 1 - mState
                       SetWindowPos CbHndl, 0, rc.nLeft, rc.nTop, _
                                    rc.nRight - rc.nLeft, rc.nBottom - rc.nTop, _
                                    %SWP_NOZORDER Or %SWP_NOACTIVATE
                       Function = 1
                    End If

          ------------------

          Comment

          Working...
          X