can't get the WM_CREATE message.
.686
.model flat,stdcall
option casemap:none
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\masm32.inc
include \masm32\include\debug.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\debug.lib
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\macros\macros.asm
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
cdXPos EQU 0
cdYPos EQU 0
cdYSize EQU 200
cdXSize EQU 420
ID_TIMER1 EQU 1500
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
.DATA
dwIndx_DZ dd 0
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
.DATA?
CommandLine DD ?
hInstance dd ?
hStatic dd ?
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
.CODE
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
CenterScreen PROC USES ebx esi edi hWnd:DWORD
LOCAL wRect:RECT
invoke GetWindowRect,hWnd,addr wRect
mov esi, wRect.bottom
sub esi, wRect.top
mov edi, wRect.right
sub edi, wRect.left
invoke GetSystemMetrics,SM_CYSCREEN
shr eax, 1
mov ecx,esi
shr ecx,1
sub eax, ecx
mov ebx, eax
invoke GetSystemMetrics,SM_CXSCREEN
shr eax, 1
mov ecx,edi
shr ecx,1
sub eax, ecx
invoke MoveWindow,hWnd,eax,ebx,edi,esi,FALSE
ret
CenterScreen ENDP
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
StcProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ps:PAINTSTRUCT
.if uMsg == WM_CREATE
PrintHex ecx
invoke SetTimer,hWin,ID_TIMER1,2*1000,NULL
xor eax,eax
ret
.elseif uMsg == WM_TIMER
cmp dwIndx_DZ,200
jne @f
mov dwIndx_DZ,0
@@:
invoke InvalidateRect,hWin,NULL,NULL
add dwIndx_DZ,10
xor eax,eax
ret
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWin,addr ps
invoke SetTextColor,ps.hdc,0FF00ffh
invoke SetBkMode,ps.hdc,TRANSPARENT
invoke lstrlen, CTXT("This is a test")
mov ecx,eax
invoke TextOut,ps.hdc,dwIndx_DZ,15,CTXT("This is a test"),ecx
invoke EndPaint,hWin,addr ps
xor eax,eax
ret
.endif
invoke GetWindowLong,hStatic,GWL_USERDATA
invoke CallWindowProc,eax,hWin,uMsg,wParam,lParam
ret
StcProc endp
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
WndProc PROC hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax,uMsg
.if eax == WM_DESTROY
invoke PostQuitMessage, NULL
.elseif eax == WM_CREATE
invoke CenterScreen, hWnd
invoke CreateWindowEx,WS_EX_CLIENTEDGE,CTXT("STATIC"),NULL,\
WS_CHILD+WS_VISIBLE+WS_BORDER,4,4,405,66,hWnd,1014,hInstance,NULL
mov hStatic,eax
invoke SetWindowLong,hStatic,GWL_WNDPROC,offset StcProc
invoke SetWindowLong,hStatic,GWL_USERDATA,eax
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax, eax
ret
WndProc ENDP
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
WinMain PROC hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov eax, hInstance
mov wc.hInstance, eax
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
mov wc.hbrBackground,COLOR_BACKGROUND
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, CTXT("test")
invoke LoadIcon, NULL, IDC_ARROW
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDI_APPLICATION
mov wc.hCursor, eax
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL, CTXT("test"), CTXT("test"),\
WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU ,cdXPos, cdYPos, cdXSize, cdYSize,\
NULL,NULL,hInstance,NULL
mov hwnd, eax
invoke ShowWindow, hwnd, SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, ADDR msg, NULL, 0, 0
.break .if (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endw
mov eax, msg.wParam
ret
WinMain ENDP
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
start:
invoke GetModuleHandle, NULL
mov hInstance, EAX
invoke GetCommandLine
mov CommandLine, EAX
invoke WinMain,hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, EAX
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end start
Hi
I simply soultuion is use SendMessages
Quoteinvoke SetWindowLong,hStatic,GWL_WNDPROC,offset StcProc
invoke SetWindowLong,hStatic,GWL_USERDATA,eax
invoke SetTimer,hStatic,ID_TIMER1,1000,NULL
What is you goal to make a Text scroller?
the static control has already been created (WM_CREATE finished) before you get to subclass it
You don't need to access a WM_CREATE, place any startup code just after the CreateWindowEx() function call but before ShowWindow().
thanks your help.
QuoteWhat is you goal to make a Text scroller?
for testing,if get the WM_TIMER message, the text will move.
Quotethe static control has already been created (WM_CREATE finished) before you get to subclass it.
right, Not all message it can be processed itself. maybe use the superclass better.
QuoteYou don't need to access a WM_CREATE, place any startup code just after the CreateWindowEx() function call but before ShowWindow().
the window subclassing can't finish the Independent function, it need the help of main code.
QuoteQuote
What is you goal to make a Text scroller?
for testing,if get the WM_TIMER message, the text will move.
Yes i have see it it works with this code without Wm_CREATE
invoke SetWindowLong,hStatic,GWL_WNDPROC,offset StcProc
invoke SetWindowLong,hStatic,GWL_USERDATA,eax
invoke SetTimer,hStatic,ID_TIMER1,1000,NULL
hi,ragdog
thanks.