Page 1 of 1
Posted: Sat Feb 22, 2003 7:50 pm
by BackupUser
Restored from previous forum. Originally posted by GPI.
How can i set the minimum size of a window, so the user can't resize the window smaller than the given size?
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
Posted: Sat Feb 22, 2003 9:24 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
You'll have to check the #WM_SIZING Message. With it's lParam, you get a Pointer to a RECT Structure. If you modify this Structure, you can set Minimum Values.
I think, this is the way it should be done.
Here's some code from on of my apps:
Code: Select all
#MinX = 220
#MinY = 250
; This Code must be in the WindowCallback Procedure
If Message = #WM_SIZING
*Size.RECT = lParam
If *Size\right - *Size\left < #MinX
If wParam = #WMSZ_BOTTOMRIGHT Or wParam = #WMSZ_TOPRIGHT Or wParam = #WMSZ_RIGHT
*Size\right = *Size\left + #MinX
Else
*Size\left = *Size\right - #MinX
EndIf
EndIf
If *Size\bottom - *Size\top < #MinY
If wParam = #WMSZ_BOTTOMLEFT Or wParam = #WMSZ_BOTTOMRIGHT Or wParam = #WMSZ_BOTTOM
*Size\bottom = *Size\top + #MinY
Else
*Size\top = *Size\bottom - #MinY
EndIf
EndIf
result = #True
Endif
That's it...
Timo
Posted: Sat Feb 22, 2003 9:31 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Fred posted a snippet that processes #WM_GETMINMAXINFO long ago to achieve that, but I guess processing #WM_SIZING works ok too.
El_Choni
Posted: Sat Feb 22, 2003 10:45 pm
by BackupUser
Restored from previous forum. Originally posted by GPI.
Thanks.
Needed const:
#WMSZ_BOTTOMRIGHT = 8
#WMSZ_TOPRIGHT = 5
#WMSZ_RIGHT = 2
#WMSZ_BOTTOMLEFT = 7
#WMSZ_BOTTOM = 6
and freak's methode need the complete window size.
To convert the inner-size of a window to the complete size:
min_main_width=100
min_main_height=100
rec\left=10:rec\top=10
rec\right=10+min_main_width
rec\bottom=10+min_main_height
adjustWindowrect_(@rec.rect,style,0);0=no Menu / 1=menu
min_main_width=rec\right-rec\left
min_main_height=rec\bottom-rec\top
debug min_main_width
debug min_main_height
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
Posted: Sat Feb 22, 2003 11:28 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Oops, sorry I forgot about the constants. (defined them at the start of my source)
Posted: Sat Feb 22, 2003 11:46 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
i think it's easier to use the WM_GETMINMAXINFO message in the window callback, something like this would work:
Code: Select all
; code below should be in your window callback procedure
...
If message = #WM_GETMINMAXINFO
result = 0
*ptr.MINMAXINFO = lParam
*ptr\ptMinTrackSize\x = #WINDOW_WIDTH ; your min width
*ptr\ptMinTrackSize\y = #WINDOW_HEIGHT ; your min height
...
EndIf
...
Posted: Sun Feb 23, 2003 12:05 am
by BackupUser
Restored from previous forum. Originally posted by GPI.
Jup, #wm_getminmaxinfo work.
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB