Steward
分享是一種喜悅、更是一種幸福
程式語言 - ObjAsm - Set Timer
參考資訊:
https://github.com/ObjAsm
https://objasm.x10host.com/index.htm
main.asm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | % include @ Environ ( OBJASM_PATH )\Code\Macros\Model. inc SysSetup OOP , WIN32 , ANSI_STRING MakeObjects Primer , Stream , WinPrimer , Window , WinApp , SdiApp .const CStr szName, " main " Object MyApp , , SdiApp RedefineMethod Init VirtualEvent OnTimer , WM_TIMER VirtualEvent OnPaint , WM_PAINT VirtualEvent OnClose , WM_CLOSE , WM_QUERYENDSESSION DefineVariable cnt, DWORD , 0 DefineVariable wndClass, WNDCLASS , {0} ObjectEnd .code Method MyApp . Init , uses esi SetObject esi ACall esi . Init m2m [ esi ].wndClass.hbrBackground, COLOR_WINDOW m2m [ esi ].wndClass.lpfnWndProc, $ MethodAddr ( MyApp . WndProc ) m2m [ esi ].wndClass.lpszClassName, offset szName invoke RegisterClass , addr [ esi ].wndClass invoke CreateWindowEx , WS_EX_LEFT , offset szName, offset szName, WS_OVERLAPPEDWINDOW or WS_VISIBLE , 0, 0, 300, 300, NULL , NULL , NULL , pSelf m2m [ esi ].hWnd, eax invoke SetTimer , [ esi ].hWnd, 1, 1000, NULL MethodEnd Method MyApp . OnPaint , uses esi , wParam: WPARAM , lParam: LPARAM local hDC: HDC local PS: PAINTSTRUCT SetObject esi mov hDC, $ invoke ( BeginPaint , [ esi ].hWnd, addr PS) invoke EndPaint , [ esi ].hWnd, addr PS MethodEnd Method MyApp . OnTimer , uses esi , wParam: WPARAM , lParam: LPARAM local buf[255]: byte SetObject esi inc [ esi ].cnt invoke wsprintf , addr buf, $ OfsCStr ("% d "), [ esi ].cnt invoke SetWindowText , [ esi ].hWnd, addr buf invoke DefWindowProc , [ esi ].hWnd, WM_TIMER , wParam, lParam MethodEnd Method MyApp . OnClose , uses esi , wParam: WPARAM , lParam: LPARAM SetObject esi invoke KillTimer , [ esi ].hWnd, 1 invoke DefWindowProc , [xsi].hWnd, WM_CLOSE , wParam, lParam MethodEnd start proc SysInit OCall $ ObjTmpl ( MyApp ):: MyApp . Init OCall $ ObjTmpl ( MyApp ):: MyApp . Run OCall $ ObjTmpl ( MyApp ):: MyApp . Done SysDone invoke ExitProcess , 0 start endp end |
完成