News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

can we make static window?

Started by elmo, October 29, 2010, 02:35:15 AM

Previous topic - Next topic

elmo

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
be the king of accounting programmer world!

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jj2007

Normally I would suggest you can stop any window from moving by capturing the WM_MOVING 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


hutch--

 :bg

Whats wrong with not putting a title bar on it ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

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.