oto kod...
format PE GUI 4.0
entry start
include 'C:\Program Files\Flat Asembler\INCLUDE\win32a.inc'
IDM_NEW = 101
IDM_OPN = 102
IDM_SAV = 103
IDM_EXT = 104
IDM_ABT = 201
section '.data' data readable writeable
_title db ' ',0
_class db 'SREMain',0
_btn db 'BUTTON',0
_stc db 'STATIC',0
hWnd dd ?
hInstance dd ?
x dd ?
hPanel dd ?
hPix dd ?
rect RECT
msg MSG
wc WNDCLASS
section '.code' code readable executable
start:
invoke GetModuleHandle,0
mov [hInstance],EAX
invoke LoadIcon,0,IDI_APPLICATION
mov [wc.hIcon],EAX
invoke LoadCursor,0,IDC_ARROW
mov [wc.hCursor],EAX
mov [wc.style],0
mov [wc.lpfnWndProc],WindowProc
mov [wc.cbClsExtra],0
mov [wc.cbWndExtra],0
mov EAX,[hInstance]
mov [wc.hInstance],EAX
mov [wc.hbrBackground],COLOR_BTNFACE+1
mov [wc.lpszMenuName],0
mov [wc.lpszClassName],_class
invoke RegisterClass,wc
invoke LoadMenu, [hInstance], 1
invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,0,0,800,550,NULL,eax,[hInstance],NULL
mov [hWnd],EAX
msg_loop:
invoke GetMessage,msg,NULL,0,0
or EAX,EAX
jz end_loop
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp msg_loop
end_loop:
invoke ExitProcess,[msg.wParam]
proc WindowProc, hwnd,wmsg,wparam,lparam
push ebx esi edi
cmp [wmsg],WM_DESTROY
je onDestroy
defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
cmp [wmsg],WM_CREATE
je onCreate
cmp [wmsg],WM_SIZE
je onResize
cmp [wmsg],WM_COMMAND
je onCommand
jmp finish
onDestroy:
invoke PostQuitMessage,0
xor EAX,EAX
onCreate:
invoke GetClientRect, [hwnd], rect
invoke CreateWindowEx,0, _stc, 0, WS_CHILD+WS_VISIBLE+WS_THICKFRAME, [rect.left],[rect.top],[rect.right],32 , [hwnd], NULL, [hInstance], NULL
mov [hPanel], eax
invoke CreateWindowEx,0, _btn, 0, WS_CHILD+WS_VISIBLE, 1, 1, 25, 25, [hPanel], NULL, [hInstance], 301
mov [hPix], eax
jmp finish
onResize:
invoke GetClientRect, [hwnd], rect
invoke MoveWindow, [hPanel], [rect.left], [rect.top], [rect.right], 32, TRUE
jmp finish
onCommand:
cmp [wparam], IDM_EXT
je onDestroy
cmp [wparam], 301
jne finish
jmp onDestroy
invoke SendMessage, [hPix], BM_GETCHECK, 0, 0
cmp eax, BST_CHECKED
jne uc
invoke SendMessage, [hPix], BM_SETSTATE, 0, 0
uc:
invoke SendMessage, [hPix], BM_SETSTATE, 1, 0
finish:
pop edi esi ebx
return
endp
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'
import user,\
RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
SendMessage,'SendMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
LoadMenu,'LoadMenuA',\
GetClientRect,'GetClientRect',\
MoveWindow, 'MoveWindow',\
PostQuitMessage,'PostQuitMessage'
section '.rsrc' resource data readable
directory RT_MENU, menus
resource menus,\
1,LANG_ENGLISH+SUBLANG_DEFAULT,mm
menu mm
menuitem '&Plik',0,MFR_POPUP
menuitem '&Nowy', IDM_NEW, 0
menuitem '&Otwórz', IDM_OPN, 0
menuitem '&Zapisz', IDM_SAV, 0
menuseparator
menuitem 'Z&amknij', IDM_EXT, MFR_END
menuitem '&About', IDM_ABT, MFR_END
Nie wiem, czy to cokolwiek zmienia...