I want to make my window static, so we can't move it.
I put this code on uMsg=WM_CREATE
invoke SetWindowPos,hWin, HWND_TOPMOST,NULL,NULL,NULL,NULL,SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE
but it not work/ fail.
What wrong?
Source: http://win32assembly.online.fr/Win32Api1.htm
SetWindowPos will only resize or move a window, using SWP_NOMOVE just tells the API to ignore certain parameters passed to it, it has nothing to do with how Windows manages the static control. However you can use the example of a splash window to make an unmoveable window (which is essentially what a splash window is). I use this to create splash windows:
Note: I know that some people object to my posting GoAsm code here but I am not really that interested in translating it - Sorry - Donkey
CONST SECTION
ALIGN 4
SplashClassName DB "DonkeySplashClass",0
DATA SECTION
cxDib DD ?
cyDib DD ?
hSplash DD ?
hBmpSplash DD ?
CODE SECTION
RegisterSplash FRAME
LOCAL wc:WNDCLASSEX
mov D[wc.cbSize],sizeof WNDCLASSEX
mov D[wc.style],CS_HREDRAW or CS_VREDRAW
mov D[wc.lpfnWndProc],offset SplashProc
mov D[wc.cbClsExtra],NULL
mov D[wc.cbWndExtra],NULL
push [hInstance]
pop [wc.hInstance]
mov D[wc.hbrBackground],NULL
mov D[wc.lpszMenuName],NULL
mov D[wc.lpszClassName],offset SplashClassName
mov D[wc.hIcon],NULL
mov D[wc.hIconSm],NULL
invoke LoadCursor,NULL,IDC_ARROW
mov D[wc.hCursor],eax
invoke RegisterClassEx,addr wc
RET
ENDF
GetSplash FRAME
LOCAL bmp:BITMAP
invoke LoadImage,NULL,"splash.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE
mov [hBmpSplash],eax
invoke GetObject,[hBmpSplash],SIZEOF BITMAP,offset bmp
mov eax,[bmp.bmWidth]
mov [cxDib],eax
mov eax,[bmp.bmHeight]
mov [cyDib],eax
mov eax,[hBmpSplash]
RET
ENDF
ShowSplash FRAME
LOCAL rect:RECT
invoke GetSplash
test eax,eax
jz >>
invoke GetSystemMetrics,SM_CXFULLSCREEN
mov D[rect.left],0
mov [rect.right],eax
invoke GetSystemMetrics,SM_CYFULLSCREEN
mov D[rect.top],0
mov [rect.bottom],eax
mov eax,[rect.right]
sub eax,[rect.left]
shr eax,1
mov ecx,[cxDib]
shr ecx,1
sub eax,ecx
add [rect.left],eax
mov eax,[rect.bottom]
sub eax,[rect.top]
shr eax,1
mov ecx,[cyDib]
shr ecx,1
sub eax,ecx
add [rect.top],eax
invoke CreateWindowEx,WS_EX_TOPMOST | WS_EX_TOOLWINDOW,addr SplashClassName, \
NULL, WS_POPUP | WS_BORDER, \
[rect.left],[rect.top],[cxDib],[cyDib], \
NULL,NULL,[hInstance],NULL
mov [hSplash],eax
invoke ShowWindow,[hSplash],SW_SHOW ;NOACTIVATE
invoke UpdateWindow,[hSplash]
:
ret
ENDF
SplashProc FRAME hWin,uMsg,wParam,lParam
LOCAL hDC:%HANDLE
LOCAL ps:PAINTSTRUCT
LOCAL memDC:%PTR
cmp D[uMsg], WM_PAINT
jne >>.EXIT
invoke BeginPaint,[hWin],addr ps
mov [hDC],eax
invoke CreateCompatibleDC,[hDC]
mov [memDC],eax
invoke SelectObject,[memDC],[hBmpSplash]
invoke BitBlt,[hDC],0,0,[cxDib],[cyDib],[memDC],0,0,SRCCOPY
invoke EndPaint,[hWin],addr ps
xor eax,eax
ret
.EXIT
invoke DefWindowProc,[hWin],[uMsg],[wParam],[lParam]
ret
ENDF
Normally I would suggest you can stop any window from moving by capturing the WM_MOVING (http://msdn.microsoft.com/en-us/library/ms632632%28VS.85%29.aspx) or the WM_MOVE message. But it seems to be a bit more complex... ::)
Try this:
CASE WM_MOVING
mov eax, lParam
mov [eax.RECT.left], 100
mov [eax.RECT.right], 300
mov [eax.RECT.top], 100
mov [eax.RECT.bottom], 200
xor eax, eax
ret
:bg
Whats wrong with not putting a title bar on it ?
Quote from: hutch-- on October 29, 2010, 07:47:07 AM
Whats wrong with not putting a title bar on it ?
Probably that the title bar will be missing. But anyway, catching the WM_MOVING message works fine.