You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
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.
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.
(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
' 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).]
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment