NTK and The NTK Project
are properties of Jn Dechereux
Home | Documentation | FAQ.

Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorwaltspon
    • CommentTimeApr 11th 2017
     
    Hi forum,
    I have a main window with WS_OVERLAPPEDWINDOW style and was wondering if it is possible to set lo-limits
    under which users could no longer keep on resizing it. Any ideas?
    walter
    •  
      CommentAuthorxbasefan
    • CommentTimeApr 13th 2017 edited
     
    hi walter,
    of course it's possible, see attached.
    MS well known technic consists in handling the WM_GETMINMAXINFO message in the callback wndproc
    of your window and adjust the ptMinTrackSize and ptMaxTrackSize values of the MINMAXINFO structure.
    btw, the MINMAXINFO struct is sent by the os via the nlParam when the WM_GETMINMAXINFO event occurs. learn more:
    https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms632626%28v=vs.85%29.aspx

    with NTK, just attach an event handler function to your window declaration
    // example:
    CREATE WINDOW hWndDemo;
           STYLE WS_OVERLAPPEDWINDOW;
           TITLE "my window resizable";
           AT 0,0 SIZE 800,600;
           ON PAINT DoScrPaint();
           ON MSG DoEventHandler() // <<< sth like that
    

    then insert & adapt code below into your Prg.
    STATIC FUNCTION DoEventHandler(hWnd,nMsg,nwParam,nlParam)
    LOCAL nW, nH, aWndSize, aMinMaxInfo
    LOCAL nMinWndWidth  := 320 // min. w. boundary
    LOCAL nMinWndHeight := 200 // min. h. boundary
    
    DO CASE
    ...
       CASE nMsg == WM_GETMINMAXINFO
            // get the window dimensions in screen coordinates
            aWndSize := NTK_GetWindowRect( hWnd )
    
            // determine the window's actual width and height
            nW := aWndSize[RECT_Right] - aWndSize[RECT_Left]
            nH := aWndSize[RECT_Bottom] - aWndSize[RECT_Top]
    
            // ----------------------------------------------------------------------------
            // prevent user from resizing the window outside the minimum boundaries
            // ----------------------------------------------------------------------------
            IF nW <= nMinWndWidth .OR.  nH <= nMinWndHeight
               // Convert the MINMAXINFO structure into an xhb array
               aMinMaxInfo := NTK_MinMaxInfo2A( nlParam )
    
               If nW <= nMinWndWidth
                  // specify the new minimum width
                  aMinMaxInfo[ MINMAXINFO_ptMinTrackSizeX ] := nMinWndWidth
               EndIf
    
               If nH <= nMinWndHeight
                  // specify the new minimum height
                  aMinMaxInfo[ MINMAXINFO_ptMinTrackSizeY ] := nMinWndHeight
               EndIf
    
               // return the MINMAXINFO structure back to MS-Windows
               NTK_SetMinMaxInfo( nlParam, aMinMaxInfo )
            ENDIF
            // ----------------------------------------------------------------------------
            RETURN( 0 )
    ...
    ENDCASE
    
    RETURN NTK_DefWindowProc(hWnd,nMsg,nwParam,nlParam)
    

    nothing more. hope this helps.
    wilson
    •  
      CommentAuthorwaltspon
    • CommentTimeApr 14th 2017
     
    Wow! works a treat. no ajdustements needed.
    Thanks for this code. Wilson, you are awesome. :)
    Walter