;; versao 19 mar?o 2003 for NASM
;;=========================
;-- -----------------------------------------
; rotin Funcion,arg1,..,argN
;
; local_ var1,4,msg,MSG_size,hWnd,4 ; locals using stack !
;
; mov ,eax
;
; CONST ola , "ola meu!",0 ; data declared in code !
;
; _ret ; jump to endrotin
;
; lea eax,
;
; _ret 1 ; can return a value !
;
; mov eax,
;
; endrotin
;------------------------------------------
; dword = 4 ;)
;========================


here the file
Posted on 2003-03-19 14:01:34 by Nguga
%include "\lab\vasm\inc\nagoa.inc"
%include "pgcmacro.asm"



..start:
call GetModuleHandle, NULL
CONST hInstance, dd 0 ; data declared in side code !
mov ,eax
call GetCommandLine
CONST CommandLine, dd 0
mov ,eax
invoke WinMain,,NULL,CommandLine, SW_SHOWDEFAULT
call ExitProcess,eax

rotin WinMain,hInst,hPrevInst,CmdLine,CmdShow

local_ hwnd,4 ; stack locals hwnd = ebp-4
local_ msg,MSG_size
local_ wc,WNDCLASSEX_size



movd ,WNDCLASSEX_size
movd , CS_HREDRAW | CS_VREDRAW
movd ,WndProc
movd ,NULL
movd ,NULL
m2m ,
movd ,COLOR_WINDOW+1
movd ,NULL
CONST ClassName, db "SimpleWinClass",0 ;--> data in side code !
movd ,ClassName
call LoadIcon,NULL,IDI_APPLICATION
movd ,eax
movd ,eax
call LoadCursor,NULL,IDC_ARROW
movd ,eax
lea ebx,
call RegisterClassEx,ebx
CONST AppName, db "Our First Window",0
call CreateWindowEx,NULL,ClassName,AppName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL, ,NULL
mov ,eax
call ShowWindow, ,
call UpdateWindow,

;=================================
; Loop Messages in order to get all of them..
;=================================
.Messageloop
push ebx
lea ebx, ; get the efective adress of ebp-4-MSG_size
call GetMessageA,ebx, NULL, 0, 0
test eax, eax
je .Fim
cmp eax, -1
je .erro
call TranslateMessage,ebx
call DispatchMessageA,ebx
pop ebx
jmp .Messageloop

.Fim:
mov eax,
_ret
.erro
xor eax, eax
endrotin

rotin WndProc,hWnd,uMsg,wParam,lParam

; declare locals like all in one line is better!
local_ hdc,4,ps,PAINTSTRUCT_size,hfont,4

cmp dword ,WM_DESTROY
je .WM_DESTROY
cmp dword ,WM_PAINT
je .WM_PAINT

.Default:
call DefWindowProc,,,,
_ret

.WM_DESTROY:
call PostQuitMessage,NULL
_ret

.WM_PAINT:
push ebx
lea ebx,
call BeginPaint,,ebx
mov ,eax ; handle of our palet
call CreateFont,24,16,0,0,400,0,0,0,OEM_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SCRIPT, "verdana"
call SelectObject, , eax ; move the font to our palet
mov ,eax ; handle of font on our palet
RGB 200,200,50
call SetTextColor,,eax
RGB 0,0,255
call SetBkColor,,eax
call TextOut,,0,0,"TestString",10 ; write on the palet
call SelectObject,,
call EndPaint,,ebx
pop ebx
endrotin
Posted on 2003-03-19 14:04:03 by Nguga