Уроки Iczelion'а




Урок 15. Тpеды (ветви) - часть 5


.const IDM_CREATE_THREAD equ 1

IDM_EXIT equ 2 WM_FINISH equ WM_USER+100h

.data ClassName db "Win32ASMThreadClass",0 AppName db "Win32 ASM MultiThreading Example",0 MenuName db "FirstMenu",0

SuccessString db "The calculation is completed!",0

.data?

hInstance HINSTANCE ? CommandLine LpSTR ? hwnd HANDLE ? ThreadID DWORD ?

.code start:

invoke GetModuleHandle, NULL mov hInstance,eax invoke GetCommandLine mov CommandLine,eax

invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT invoke Exitprocess,eax

WinMain proc hInst:HINSTANCE,hprevInst:HINSTANCE,CmdLine:LpSTR,CmdShow:DWORD LOCAL wc:WNDCLASSEX LOCAL msg:MSG

mov wc.cbSize,SIZEOF WNDCLASSEX 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 .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_DESTROY

invoke postQuitMessage,NULL .ELSEIF uMsg==WM_COMMAND mov eax,wparam .if lparam==0

.if ax==IDM_CREATE_THREAD mov eax,OFFSET Threadproc invoke CreateThread,NULL,NULL,eax,\ 0,\

ADDR ThreadID invoke CloseHandle,eax .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




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