Iczelion's Win32 Assembly Tutorial: More_about_Text
format PE GUI 4.0
entry start
include '%fasminc%\win32w.inc'
macro RGB cR, cG, cB {
xor eax,eax mov ah,cB
shl eax,8
mov ah,cG
mov al,cR
}
section '.data' data readable writeable
wTitle TCHAR 'Iczelion Tutorial No.5',0
wClsName TCHAR 'TUT05',0
expTxt TCHAR 'Win32 assembly with FASM is great and easy',0
wMsg MSG
wCls WNDCLASS
OBJ_FONT equ 6
expHdc dd ?
expFont TCHAR 'script',0
expPs PAINTSTRUCT
wHMain dd ?
wHInstance dd ?
section '.code' code readable executable
start:
invoke GetModuleHandle, 0
mov [wHInstance], eax
mov [wCls.hInstance], eax
mov [wCls.style], CS_HREDRAW or CS_VREDRAW
mov [wCls.lpfnWndProc], window_procedure
mov [wCls.lpszClassName], wClsName
mov [wCls.hbrBackground], COLOR_BTNFACE+1
invoke LoadIcon, NULL, IDI_APPLICATION
mov [wCls.hIcon], eax
invoke LoadCursor, NULL, IDC_ARROW
mov [wCls.hCursor], eax
invoke RegisterClass, wCls
invoke CreateWindowEx, 0, wClsName, wTitle,\
WS_OVERLAPPEDWINDOW + WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,\
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, [wHInstance], NULL
mov [wHMain], eax
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
proc window_procedure uses ebx esi edi, hWnd, uMsg, wParam, lParam
mov eax, [uMsg]
cmp eax, WM_PAINT
je .wmPAINT
cmp eax, WM_DESTROY
je .wmDESTROY
.wmDEFAULT:
invoke DefWindowProc, [hWnd], [uMsg], [wParam], [lParam]
jmp .exit
.wmPAINT:
invoke BeginPaint, [hWnd], expPs
mov [expHdc], eax
invoke GetCurrentObject, [expHdc], OBJ_FONT
push eax invoke CreateFont, 26, 12, 0, 0, 400, 0, 0, 0, OEM_CHARSET, OUT_DEFAULT_PRECIS,\
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH or FF_SCRIPT, expFont
invoke SelectObject, [expHdc], eax
RGB 200, 200, 50
invoke SetTextColor, [expHdc], eax
RGB 0, 0, 255
invoke SetBkColor, [expHdc], eax
invoke lstrlen, expTxt invoke TextOut, [expHdc], 0, 0, expTxt, eax
pop eax
invoke SelectObject, [expHdc], eax
invoke EndPaint, [hWnd], expPs
jmp .exit
.wmDESTROY:
invoke PostQuitMessage, 0
.exit:
ret
endp
section '.idata' import data readable
library kernel32, 'KERNEL32.DLL',\
user32, 'USER32.DLL',\
gdi32, 'GDI32.DLL'
include '%fasminc%\api\kernel32.inc'
include '%fasminc%\api\user32.inc'
include '%fasminc%\api\gdi32.inc'
Последнее обновление : 25 января 2008