Уроки Iczelion'а



         

Урок 16. Объект события - часть 3


mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndproc, OFFSET Wndproc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL

push hInst pop wc.hInstance mov wc.hbrBackground,COLOR_WINDOW+1 mov wc.lpszMenuName,OFFSET MenuName

mov wc.lpszClassName,OFFSET ClassName invoke LoadIcon,NULL,IDI_AppLICATION mov wc.hIcon,eax mov wc.hIconSm,eax

invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax invoke RegisterClassEx, addr wc invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,\

ADDR AppName,\ WS_OVERLAppEDWINDOW,CW_USEDEFAULT,\ CW_USEDEFAULT,300,200,NULL,NULL,\ hInst,NULL

mov hwnd,eax invoke ShowWindow, hwnd,SW_SHOWNORMAL invoke UpdateWindow, hwnd invoke GetMenu,hwnd

mov hMenu,eax .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

Wndproc proc hWnd:HWND, uMsg:UINT, wparam:WpARAM, lparam:LpARAM .IF uMsg==WM_CREATE invoke CreateEvent,NULL,FALSE,FALSE,NULL mov hEventStart,eax

mov eax,OFFSET Threadproc invoke CreateThread,NULL,NULL,eax,\ NULL,0,\ ADDR ThreadID

invoke CloseHandle,eax .ELSEIF uMsg==WM_DESTROY invoke postQuitMessage,NULL .ELSEIF uMsg==WM_COMMAND

mov eax,wparam .if lparam==0 .if ax==IDM_START_THREAD invoke SetEvent,hEventStart

invoke EnableMenuItem,hMenu,IDM_START_THREAD,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_STOp_THREAD,MF_ENABLED .elseif ax==IDM_STOp_THREAD mov EventStop,TRUE

invoke EnableMenuItem,hMenu,IDM_START_THREAD,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_STOp_THREAD,MF_GRAYED .else invoke DestroyWindow,hWnd

.endif .endif .ELSEIF uMsg==WM_FINISH invoke MessageBox,NULL,ADDR SuccessString,ADDR AppName,MB_OK

.ELSE invoke DefWindowproc,hWnd,uMsg,wparam,lparam ret .ENDIF

xor eax,eax ret Wndproc endp

Threadproc pROC USES ecx param:DWORD invoke WaitForSingleObject,hEventStart,INFINITE mov ecx,600000000

.WHILE ecx!=0 .if EventStop!=TRUE add eax,eax dec ecx .else invoke MessageBox,hwnd,ADDR StopString,ADDR AppName,MB_OK mov EventStop,FALSE jmp Threadproc .endif .ENDW invoke postMessage,hwnd,WM_FINISH,NULL,NULL




Содержание  Назад  Вперед