Смекни!
smekni.com

Создание меню без файла описания ресурсов на основе функции LoadMenuIndirect (стр. 2 из 2)

push offset MenuTemplate

call LoadMenuIndirectA

mov [hMenu],eax

push L 0 ; lpParam

push [hInst] ; hInstance

push [hMenu] ; menu

push L 0 ; parent hwnd

push L CW_USEDEFAULT ; height

push L CW_USEDEFAULT ; width

push L CW_USEDEFAULT ; y

push L CW_USEDEFAULT ; x

push L WS_OVERLAPPEDWINDOW ; Style

push offset szTitleName ; Title string

push offset szClassName ; Class name

push L 0 ; extra style

call CreateWindowExA

mov [newhwnd], eax

push L SW_SHOWNORMAL

push [newhwnd]

call ShowWindow

push [newhwnd]

call UpdateWindow

msg_loop:

push L 0

push L 0

push L 0

push offset msg

call GetMessageA

cmp ax, 0

je end_loop

push offset msg

call TranslateMessage

push offset msg

call DispatchMessageA

jmp msg_loop

end_loop:

push [msg.msWPARAM]

call ExitProcess

; we never get to here

;----Оконная процедура----

WndProc proc uses ebx edi esi, hwnd:DWORD, wmsg:DWORD,\

wparam:DWORD, lparam:DWORD

LOCAL hDC:DWORD

cmp [wmsg], WM_DESTROY

je wmdestroy

cmp [wmsg], WM_SIZE

je wmsize

cmp [wmsg], WM_CREATE

je wmcreate

cmp [wmsg],WM_PAINT

je wmpaint

;**************************************

cmp [wmsg],WM_COMMAND

je wmcommand

;**************************************

jmp defwndproc

wmcommand:

mov eax,lparam

cmp ax,0

jne m1

mov eax,wparam

cmp ax,IDM_ABOUT

jne m2

call MessageBoxA,0,offset szHello,offset szAppName,MB_OK

jmp m1

m2: cmp ax,IDM_QUIT

jne m1

push 0

call PostQuitMessage

m1: mov eax,0

jmp finish

wmcreate:

mov eax, 0

jmp finish

defwndproc:

push [lparam]

push [wparam]

push [wmsg]

push [hwnd]

call DefWindowProcA

jmp finish

wmdestroy:

push L 0

call PostQuitMessage

mov eax, 0

jmp finish

wmsize:

mov eax, 0

jmp finish

wmpaint:

push offset lppaint

push [hwnd]

call BeginPaint

mov [hDC],eax

push offset lppaint

push [hwnd]

call EndPaint

mov eax,0

jmp finish

finish:

ret

WndProc endp

;---------------------------------

public WndProc

end start