flat assembler
Message board for the users of flat assembler.
Index
> Windows > For Newbies: Paint.asm Iczelion's example FASMW version |
Author |
|
vbVeryBeginner 26 Aug 2004, 05:27
same tutorial but with a different style... ye :p
Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' section '.data' data readable writeable wHMain dd ? wHInstance dd ? wTitle db 'FASM - Experiment 01',0 wClsName db 'EXP01',0 wMsg MSG wCls WNDCLASS expDc dd ? expTxt db 'Win32 assembly with FASM is great and easy!',0 expPs PAINTSTRUCT expRect RECT section '.code' code readable executable start: ; +------------------------------+ ; | registering the window class | ; +------------------------------+ invoke GetModuleHandle,NULL mov [wHInstance],eax mov [wCls.hInstance],eax mov [wCls.lpfnWndProc],window_procedure mov [wCls.lpszClassName],wClsName mov [wCls.hbrBackground],COLOR_BTNFACE+1 invoke LoadIcon,0,IDI_APPLICATION mov [wCls.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wCls.hCursor],eax invoke RegisterClass,wCls ; +--------------------------+ ; | creating the main window | ; +--------------------------+ invoke CreateWindowEx,\ 0,\ wClsName,\ wTitle,\ WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,\ 128,\ 128,\ 512,\ 128,\ 0,\ 0,\ [wHInstance],\ 0 mov [wHMain],eax ; +---------------------------+ ; | entering the message loop | ; +---------------------------+ window_message_loop_start: invoke GetMessage,wMsg,NULL,0,0 or eax,eax je window_message_loop_end invoke TranslateMessage,wMsg invoke DispatchMessage,wMsg jmp window_message_loop_start window_message_loop_end: invoke ExitProcess,0 ; +----------------------+ ; | the window procedure | ; +----------------------+ proc window_procedure,hWnd,uMsg,wParam,lParam push ebx esi edi ;even the API would preserved, but play safe :p cmp [uMsg],WM_DESTROY je wmDESTROY cmp [uMsg],WM_PAINT je wmPAINT wmDEFAULT: invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam] jmp wmBYE wmPAINT: invoke BeginPaint,[hWnd],expPs mov [expDc],eax invoke GetClientRect,[hWnd],expRect invoke DrawText,\ [expDc],\ expTxt,\ -1,\ expRect,\ DT_CENTER or DT_VCENTER or DT_SINGLELINE invoke EndPaint,[hWnd],expPs jmp wmBYE wmDESTROY: invoke PostQuitMessage,0 wmBYE: pop edi esi ebx return endp section '.idata' import data readable writable library KERNEL32, 'KERNEL32.DLL',\ USER32, 'USER32.DLL' import KERNEL32,\ GetModuleHandle, 'GetModuleHandleA',\ ExitProcess, 'ExitProcess' import USER32,\ RegisterClass, 'RegisterClassA',\ CreateWindowEx, 'CreateWindowExA',\ DefWindowProc, 'DefWindowProcA',\ LoadCursor, 'LoadCursorA',\ LoadIcon, 'LoadIconA',\ GetMessage, 'GetMessageA',\ TranslateMessage, 'TranslateMessage',\ DispatchMessage, 'DispatchMessageA',\ BeginPaint, 'BeginPaint',\ GetClientRect, 'GetClientRect',\ DrawText, 'DrawTextA',\ EndPaint, 'EndPaint',\ PostQuitMessage, 'PostQuitMessage' sincerely, vbVeryBeginner, http://sulaiman.thefreebizhost.com |
|||
26 Aug 2004, 05:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.