, : CreateMenu CreatePopupMenu,

 

: CreateMenu CreatePopupMenu.

..

. -923 ..

2001.

 

 

堠 3

蠠 5

CreateMenu CreatePopupMenu 6

7

堠 13

ꠠ 14


 

- .- , - .

. . , .

, - . , .

, , . , , , .

, , , , . , , - . , , , . . , , . Windows 95 . , [I]. Application Programming Interface (API).

Win32 API . , , , .

rc. res .

 

. . . WM_COMMAND, . , . . , , . , WM_COMMAND, , , . , (enabled), (disabled), (grayed) (checked). .

. , CreatMenu, AppendMenu InsertMenu LoadMenuIndirect, MENUITEMPLATE. Windows95 .

CreateMenu CreatePopupMenu. CreateMenu AppendMenu.

CreateMenu CreatePopupMenu

 

Windows- .data .code. 20 API. , .

mode1 (flat) (stdcall). flat . , 32- . .exe.

stdcall .

include win32.inc.

Win32 API, extrn , .

CreateMenu CreateWindowExA. CreatePopupMenu AppendMenu .

.1.

 

p386 ;

; i386

jumps ;

;

;

;

; ;

;

model flat, STDCALL ; 32-

;

; 젠 STDCALL,

;

include win32.inc ;

L equ <LARGE> ; LARGE,

; ,

; 32-,

; L

IDM_QUIT equ 100

IDM_ABOUT equ 101

MF_ENABLED equ 0

MF_POPUP equ 10h

MF_OWNERDRAW equ 100h

 

; Win32 API,

extrn BeginPaint :PROC

extrn CreateWindowExA :PROC

extrn DefWindowProcA :PROC

extrn DispatchMessageA :PROC

extrn EndPaint :PROC

extrn ExitProcess :PROC

extrn GetMessageA :PROC

extrn GetModuleHandleA :PROC

extrn LoadCursorA :PROC

extrn LoadIconA :PROC

extrn RegisterClassA :PROC

extrn PostQuitMessage :PROC

extrn ShowWindow :PROC

extrn TranslateMessage :PROC

extrn UpdateWindow :PROC

extrn CreateMenu :PROC

extrn MessageBoxA :PROC

extrn AppendMenuA :PROC

extrn DrawMenuBar :PROC

extrn CreatePopupMenu :PROC


.data ; ,

;

newhwnd dd 0

lppaint PAINTSTRUCT <?>

msg MSGSTRUCT <?>

wc WNDCLASS <?>

hInst dd 0

fl dw 0

szTitleName db ' ',0

szClassName db 'ASMCLASS32',0

szHello db '!',0

szAppName db '',0

hMenu dd 0

hsubmenu dd 0

item1 db '',0

item2 db '',0

item3 db '',0

 

.code ; ,

;

start:

push L 0

call GetModuleHandleA

mov [hInst], eax

; WndClass

mov [wc.clsStyle], CS_HREDRAW + CS_VREDRAW +

CS_GLOBALCLASS

mov [wc.clsLpfnWndProc], offset WndProc

mov [wc.clsCbClsExtra], 0

mov [wc.clsCbWndExtra], 0

mov eax, [hInst]

mov [wc.clsHInstance], eax

push L IDI_APPLICATION

push L 0

call LoadIconA

mov [wc.clsHIcon], eax

push L IDC_ARROW

push L 0

call LoadCursorA

mov [wc.clsHCursor], eax

mov [wc.clsHbrBackground], COLOR_WINDOW + 1

mov dword ptr [wc.clsLpszMenuName],0

mov dword ptr [wc.clsLpszClassName], offset szClassName

push offset wc

call RegisterClassA

 

call CreateMenu

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

 

call CreatePopupMenu

mov [hsubmenu], eax

push offset item2

push L IDM_QUIT

push 0

push eax

call AppendMenuA

 

push offset item3

push L IDM_ABOUT

push 0

push [hsubmenu] ;eax

call AppendMenuA

 

push offset item1

push [hsubmenu]

push MF_POPUP

push [hMenu]

call AppendMenuA

nop


push L SW_SHOWNORMAL

push [newhwnd]

call ShowWindow

 

push [newhwnd]

call UpdateWindow

 

push [newhwnd]

call DrawMenuBar

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


;---- ----

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 ;


1.


CreateMenu CreatePopupMenu. .

 

 

.. Assembler. DOS Windows Unix. .: , 1999

.. . .

TURBO ASSEMBLER . 1,2.: : / ... : . , 2000.



, :


 
 
 
 
 
, , , ...
 
 
  
  
   
 
 
bigmir)net TOP 100