I want to protect a Window to be resized > given MAX and < given MIN.
I tested with :
oWnd:Move and oWnd:Resize, but a oversized Window is not adjusted to the given MIN and MAX
The start Window :
The Image-background stopps Resizing, reaching Max-width or Max-Height
I still have to adjust the Window.
- Code: Select all Expand view
...
...
nMDI := 2 // 1 = Modal
nWStyle := 4 // Image selected
nMINWidth := 300
nMINHeight := 300
nMAXWidth := 800
nMAXHeight := 500
IF nMDI = 1 // Modal
DEFINE WINDOW oWnd TITLE "Window SizeProtection" FROM 100, 100 TO 400, 700 PIXEL MENU TMenu():New()
ELSE
DEFINE WINDOW oWnd TITLE "Window SizeProtection" FROM 100, 100 TO 400, 700 PIXEL MDI
ENDIF
SET MESSAGE OF oWnd TO "Windows Size Protection" ;
CENTERED CLOCK KEYBOARD 2007
ACTIVATE WINDOW oWnd ;
ON INIT IIF( nMDI = 1, W_BACKGRD( oWnd, nWStyle, lWDirect, nWColorF, nWColorB, nWGradPos, cWBrush, cWImage ), ;
W_BACKGRD( oWnd:oWndClient, nWStyle, lWDirect, nWColorF, nWColorB, nWGradPos, cWBrush, cWImage ) ) ;
ON RESIZE IIF( nMDI = 1, SIZE_PROT(oWnd), SIZE_PROT(oWnd:oWndClient) )
SET _3DLOOK OFF
RETURN ( NIL )
// --------------------
FUNCTION SIZE_PROT(oWnd)
LOCAL nWidth, nHeight
oWnd:CoorsUpdate()
nWidth := oWnd:nWidth
nHeight := oWnd:nHeight
W_BACKGRD( oWnd, nWStyle, lWDirect, nWColorF, nWColorB, nWGradPos, cWBrush, cWImage )
lProtect := .F.
IF nWidth > nMAXWidth
nWidth := nMAXWidth
lProtect := .T.
ENDIF
IF nWidth < nMINWidth
nWidth := nMINWidth
lProtect := .T.
ENDIF
IF nHeight > nMAXHeight
nHeight := nMAXHeight
lProtect := .T.
ENDIF
IF nHeight < nMINHeight
nHeight := nMINHeight
lProtect := .T.
ENDIF
IF lProtect = .T. // resize back to MIN or MAX Height/Width
oWnd:ReSize(nWidth, nHeight) // ?????????
// oWnd:Move( , , nWidth, nHeight, .T. ) // ?????????
ENDIF
RETURN ( NIL )
Best Regards
Uwe