.386
.model flat,stdcall
option casemap:none

include windows.inc
include kernel32.inc
include user32.inc

includelib kernel32.lib
includelib user32.lib

.data
_title db 'First Window',0
_class db 'first',0
sectitle db 'second Window',0
secclass db 'sec',0
ButtonClass db 'button',0
ButtonText db 'OPEN',0


.data?
msg MSG <?>
wc WNDCLASS <?>

hWnd dd ?
hwndButton dd ?
hSecWnd dd ?
hInstance HINSTANCE ?

.const
ButtonID equ 401

.code
start:
push 0
call GetModuleHandle
mov hInstance,eax

mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
mov eax,hInstance
mov wc.hInstance,eax
mov wc.hbrBackground,COLOR_WINDOW
mov wc.lpszMenuName,0
mov wc.lpszClassName,offset _class

push IDI_WINLOGO
push 0
call LoadIcon
mov wc.hIcon,eax

push IDC_ARROW
push 0
call LoadCursor
mov wc.hCursor,eax

push offset wc
call RegisterClass

mov wc.lpszClassName,offset secclass
mov wc.lpfnWndProc,offset SecWndProc
push offset wc
call RegisterClass

push 0
push hInstance
push 0
push 0
push 200
push 300
push CW_USEDEFAULT
push CW_USEDEFAULT
push WS_OVERLAPPEDWINDOW
push offset _title
push offset _class
push 0
call CreateWindowEx
mov hWnd,eax

push 0
push hInstance
push 0
push 0
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push offset sectitle
push offset secclass
push 0
call CreateWindowEx
mov hSecWnd,eax

push SW_SHOW
push hWnd
call ShowWindow

push SW_SHOW
push hSecWnd
call ShowWindow

push hWnd
call UpdateWindow

push hSecWnd
call UpdateWindow

msg_loop:
push 0
push 0
push 0
push offset msg
call GetMessage
cmp ax,0
jz msg_end

push offset msg
call TranslateMessage

push offset msg
call DispatchMessage

jmp msg_loop

msg_end:
push msg.wParam
call ExitProcess

WndProc Proc uses ebx edi esi,hwnd:DWORD ,umsg:DWORD,wparam:DWORD,lparam:DWORD
mov eax,umsg
cmp eax,WM_DESTROY
jz wm_destroy
cmp eax,WM_COMMAND
jz wm_command
cmp eax,WM_CREATE
jz wm_create

push lparam
push wparam
push umsg
push hwnd
call DefWindowProc
ret

wm_create:
push 0
push hInstance
push ButtonID
push hwnd
push 25
push 80
push 70
push 100
push WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON
push offset ButtonText
push offset ButtonClass
push 0
call CreateWindowEx
mov hwndButton,eax
xor eax,eax
ret

wm_command:
mov eax,wparam
cmp ax,ButtonID
jz buttonid

wm_destroy:
push 0
call PostQuitMessage
xor eax,eax
ret

buttonid:
mov eax,wparam
shr eax,16
cmp ax,BN_CLICKED
jz bn_clicked

bn_clicked:
push SW_SHOW
push hSecWnd
call ShowWindow

push hSecWnd
call UpdateWindow
ret

WndProc endp

SecWndProc Proc uses ebx edi esi,secwnd:DWORD,secmsg:DWORD,secwparam:DWORD,seclparam:DWORD
mov eax,secmsg
cmp eax,WM_CLOSE
jz wm_close

push seclparam
push secwparam
push secmsg
push secwnd
call DefWindowProc
ret

wm_close:
push SW_HIDE
push hSecWnd
call ShowWindow
ret
SecWndProc endp
end start

Posted on 2003-03-09 10:46:36 by sysnet
Originally posted by sysnet


push 0
push hInstance
push 0
push 0
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
[b][color=red]push WS_OVERLAPPEDWINDOW[/color][/b] ;you're missing this one
push offset sectitle
push offset secclass
push 0
call CreateWindowEx
mov hSecWnd,eax


i hope it's your intention that both windows appear when you start the app...
Posted on 2003-03-09 13:53:14 by hartyl
Oh,Thanks!
Your homepage is very beautiful !
Posted on 2003-03-09 23:46:39 by sysnet
thanks
btw, why don't you use the invoke-syntax? it will notice if you forget a parameter or have one in wrong type:



push 0
push hInstance
push 0
push 0
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push WS_OVERLAPPEDWINDOW
push offset sectitle
push offset secclass
push 0
call CreateWindowEx

becomes

invoke CreateWindowEx, 0, offset secclass, offset sectitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, 0, 0, hInstance, 0
Posted on 2003-03-10 13:17:21 by hartyl