Announcement

Collapse
No announcement yet.

Limitation to resize my window

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

  • Limitation to resize my window

    Hello

    My window start-size is 640*480 pixel and i like to make sure that it is not possible to resize it more then up to 800*600.
    What do i have to do ???

    Thanks....Michael

  • #2
    Michael;

    Process the %WM_SIZING (not WM_SIZE) message in your Dialog procedure. This message is sent during the resizing of the Window so you can control how far a window is sized.


    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      Michael;

      Actually, there is a more efficient method (sorry I forgot about it in the last message). You can process the %WM_GETMINMAXINFO message. This message is where Windows will poll the Dialog procedure for the Minimum and the maximum sizes the window can be sized to.



      ------------------
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        Hello Chris.

        I couldn't find nothing in my (Petzolds) Windows95 programming book about %WM_GetMINMAXINFO OR %WM_SIZING ????

        ....Michael

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


        [This message has been edited by Michael Rosner (edited March 29, 2000).]

        Comment


        • #5
          Michael;

          The code would look something like this:

          (I modified it a bit and haven't tested it though. I was using similiar code in a subclass procedure for a control, not a window. I think this should work as is.)

          Code:
                CASE %WM_GETMINMAXINFO
                    ' TYPE MINMAXINFO
                    '    ptReserved AS POINTAPI
                    '    ptMaxSize AS POINTAPI
                    '    ptMaxPosition AS POINTAPI
                    '    ptMinTrackSize AS POINTAPI
                    '    ptMaxTrackSize AS POINTAPI
                    ' END TYPE
                    RV&=DefWindowProc(hDlg, Msg, wParam, lParam)
                    DIM MM AS MINMAXINFO PTR
                    MM=lParam
                    @MM.ptMinTrackSize.x=640
                    @MM.ptMinTrackSize.y=480
                    @MM.ptMaxSize.x=800
                    @MM.ptMaxSize.y=600
                    FUNCTION=0
                    EXIT FUNCTION


          ------------------
          Chris Boss
          Computer Workshop
          Developer of "EZGUI"
          http://cwsof.com
          http://twitter.com/EZGUIProGuy

          Comment


          • #6
            To process %WM_SIZING also not a problem.

            Code:
            ' This sample demonstrates, how to restrict dialog's resizing and movement
            '
            ' Based on ideas of Lance Edmonds (subclassing) and
            '                   Chris Boss (usage of %WM_SIZING)
            ' Tasks for this sample: width  = minX .. maxX %%
            '                        height = minY .. maxY %%
            '                        autocenter
            #Compile Exe
            #Dim All
            #Register None
            #Include "win32api.INC"
            
            Global oldproc As Long
            CallBack Function DlgProc
              Select Case CbMsg
                 Case %WM_DESTROY: SetWindowLong CbHndl, %GWL_WNDPROC, oldproc ' Important
              End Select
            End Function
            
            CallBack Function subclass
               %minX = 20: %maxX = 80: %minY = 25: %maxY = 75 ' in %% of whole screen
               If CbMsg = %WM_SIZING Or CbMsg = %WM_MOVING Then
                  Local tRect As Rect Ptr, x As Long, xx As Long, y As Long, yy As Long
                  tRect = CbLparam
                  xx = GetSystemMetrics(%SM_CXSCREEN): yy = GetSystemMetrics(%SM_CYSCREEN)
                  x = Min(%maxX / 100 * xx, @tRect.nRight - @tRect.nLeft): x = Max(%minX / 100 * xx, x)
                  y = Min(%maxY / 100 * yy, @tRect.nBottom - @tRect.nTop): y = Max(%minY / 100 * yy, y)
                  @tRect.nLeft = (xx - x) / 2: @tRect.nRight = @tRect.nLeft + x
                  @tRect.nTop = (yy - y) / 2: @tRect.nBottom = @tRect.nTop + y
               End If
               Function = CallWindowProc(oldproc, CbHndl, CbMsg, CbWparam, CbLparam)
            End Function
            
            Function PbMain
               Local hDlg As Long
               Dialog New 0, "Resizing's restrictions", , , 200, 200, %WS_SYSMENU Or %WS_THICKFRAME To hDlg
               OldProc = SetWindowLong(hDlg, %GWL_WNDPROC, CodePtr(subclass))
               Dialog Show Modal hDlg, Call DlgProc
            End Function

            [This message has been edited by Semen Matusovski (edited March 29, 2000).]

            Comment

            Working...
            X