hello!
I know that api is to prevent resize a window
or style to be set (using radasm editor )
thanks :bg
well - there are a few things to work with
first, the window style
if you use WS_OVERLAPPEDWINDOW, that includes the WS_THICKFRAME style bit
WS_THICKFRAME (aka WS_SIZEBOX) creates a window with a sizing border
you can use WS_BORDER or WS_DLGFRAME (or no border) to create a window of fixed size
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx
another way to go is to answer WM_GETMINMAXINFO messages and limit or force the size
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632626%28v=vs.85%29.aspx
dedndave but that styles take away some features to the window and I do not want that.
I just want to prevent changing the window size : P
PD: sorry lol I could do :) thanks u!
in that case, handle the WM_GETMINMAXINFO messages
for example, if you want to force the window to be 400 x 300...
.if uMsg==WM_GETMINMAXINFO
mov edx,lParam
mov ecx,400
mov eax,300
mov [edx].MINMAXINFO.ptMinTrackSize.x,ecx
mov [edx].MINMAXINFO.ptMinTrackSize.y,eax
mov [edx].MINMAXINFO.ptMaxTrackSize.x,ecx
mov [edx].MINMAXINFO.ptMaxTrackSize.y,eax
xor eax,eax
ret
.elseif uMsg==............
if you only set the Min values, they won't be able to make the window smaller than that size
if you only set the Max values, they won't be able to make the window larger than that size
One way to do it would be to handle the WM_SIZING message, change the members of the RECT structure pointed to by lParam to the size you want to maintain, and indicate that the message has been handled by returning TRUE.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
hwndButton HWND 0
fLock dd 0
rc RECT <>
.code
;==============================================================================
DlgProc proc uses ebx hwndDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
SWITCH uMsg
CASE WM_INITDIALOG
invoke GetDlgItem, hwndDlg, 1001
mov hwndButton, eax
;------------------------------------
; Get the current size and store it.
;------------------------------------
invoke GetWindowRect, hwndDlg, ADDR rc
CASE WM_COMMAND
SWITCH wParam
CASE 1001
.IF fLock
invoke SetWindowText, hwndButton, chr$(" Lock Sizing ")
mov fLock, 0
.ELSE
invoke SetWindowText, hwndButton, chr$("Unlock Sizing")
mov fLock, 1
.ENDIF
CASE IDCANCEL
invoke EndDialog, hwndDlg, 0
ENDSW
CASE WM_SIZING
mov edx, lParam
.IF fLock
;-------------------------------------------------------
; Sizing is locked, so copy our stored size to the RECT
; structure pointed to by lParam and indicate that the
; message has been processed by returning TRUE.
;-------------------------------------------------------
push rc.left
pop [edx].RECT.left
push rc.top
pop [edx].RECT.top
push rc.right
pop [edx].RECT.right
push rc.bottom
pop [edx].RECT.bottom
return TRUE
.ELSE
;--------------------------------------------------
; Sizing is not locked, so update our stored size.
;--------------------------------------------------
push [edx].RECT.left
pop rc.left
push [edx].RECT.top
pop rc.top
push [edx].RECT.right
pop rc.right
push [edx].RECT.bottom
pop rc.bottom
.ENDIF
CASE WM_CLOSE
invoke EndDialog, hwndDlg, 0
ENDSW
return FALSE
DlgProc endp
;==============================================================================
start:
;==============================================================================
Dialog "Test", "MS Sans Serif",10, \
WS_OVERLAPPEDWINDOW or DS_CENTER, \
1,0,0,80,63,1024
DlgButton " Lock Sizing ",WS_TABSTOP,0,0,50,15,1001
invoke GetModuleHandle, NULL
CallModalDialog eax,0,DlgProc,NULL
exit
;==============================================================================
end start
I have posted this code before somewhere :-
This creates a window 800 by 600 that cannot be resized.
Main proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hWnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+4
mov wc.lpszMenuName,OFFSET MenuName
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,500
mov wc.hIcon,eax
mov wc.hIconSm,NULL
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE,\
CW_USEDEFAULT,CW_USEDEFAULT,800,600,NULL,NULL,hInst,NULL
mov hWnd,eax
DisplayMenu hWnd,600
DisplayWindow hWnd,SW_SHOWNORMAL
INVOKE UpdateWindow, hWnd
The parameters can be changed to suit.