get it here :

http://visual-assembler.pt.vu



here an example based on WINENUM.ASM of masm HUTCH package
converted to NAGOA+.INC ( nasm )






%include "\lab\vasm\inc\nagoa+.inc"



; - - - - - - - - - - - - - - - - - - -
data use32 ; data that will be in the exe file

szClassName db "NaGoA"

; - - - - - - - - - - - - - - - - - - -
bss use32 ; data that will not be in the exe file

CommandLine dd 0
hWnd dd 0
hInstance dd 0
hList dd 0
hStat1 dd 0
hStat2 dd 0
lpfnListProc dd 0

; - - - - - - - - - - - - - - - - - - -
code use32

..start:
invoke GetModuleHandle, NULL
mov [hInstance], eax
invoke GetCommandLine
loccall WinMain,[hInstance],NULL,eax,SW_SHOWDEFAULT
invoke ExitProcess,eax

; - - - - - - - - - - - - - - - - - - -
proc WinMain , hInst , hPrevInst , CmdLine , CmdShow

stack wc,WNDCLASSEX_size ,\
msg,MSG_size ,\
Wwd,4 ,\
Wht,4 ,\
Wtx,4 ,\
Wty,4

mov dword [@wc+WNDCLASSEX.cbSize], WNDCLASSEX_size
mov dword [@wc+WNDCLASSEX.style], CS_BYTEALIGNWINDOW
mov dword [@wc+WNDCLASSEX.lpfnWndProc], WndProc
mov dword [@wc+WNDCLASSEX.cbClsExtra], NULL
mov dword [@wc+WNDCLASSEX.cbWndExtra], NULL
m2m [@wc+WNDCLASSEX.hInstance], [@hInst]
mov dword [@wc+WNDCLASSEX.hbrBackground], COLOR_BTNFACE+1
mov dword [@wc+WNDCLASSEX.lpszMenuName], NULL
mov dword [@wc+WNDCLASSEX.lpszClassName],szClassName
invoke LoadIcon,[@hInst],500 ; icon ID
movd [@wc+WNDCLASSEX.hIcon], eax
invoke LoadCursor,NULL,IDC_ARROW
mov dword [@wc+WNDCLASSEX.hCursor], eax
mov dword [@wc+WNDCLASSEX.hIconSm], 0

invoke RegisterClassEx, addr @wc
mov dword [@Wwd], 600
mov dword [@Wht], 350
invoke GetSystemMetrics,SM_CXSCREEN
loccall TopXY,[@Wwd],eax
mov [@Wtx], eax
invoke GetSystemMetrics,SM_CYSCREEN
loccall TopXY,[@Wht],eax
mov [@Wty], eax

invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,\
szClassName,\
"Enumerate Windows",\
WS_OVERLAPPEDWINDOW,\
[@Wtx],[@Wty],[@Wwd],[@Wht],\
NULL,NULL,\
[@hInst],NULL
mov [hWnd] , eax

invoke EnumWindows,EnmProc,0

invoke LoadMenu,[@hInst],600 ; menu ID
invoke SetMenu,[hWnd],eax

invoke ShowWindow,[hWnd],SW_SHOWNORMAL
invoke UpdateWindow,[hWnd]

.Loop_msg:
invoke GetMessage,addr @msg,NULL,0,0
test eax, eax
jz .Exit_Loop
invoke TranslateMessage, addr @msg
invoke DispatchMessage, addr @msg
jmp .Loop_msg
.Exit_Loop:
mov eax ,[@msg+MSG.wParam]

endproc WinMain
; - - - - - - - - - - - - - - - - - - -
proc WndProc , hWin, uMsg , wParam , lParam

stack Rc ,RECT_size ,\
rLeft ,4 ,\
rTop ,4 ,\
rRight ,4 ,\
rBottom ,4

IF dword [@uMsg],e, WM_COMMAND

IF dword [@wParam],e, 1000
invoke SendMessage,[@hWin],WM_SYSCOMMAND,SC_CLOSE,NULL
ENDIF
IF dword [@wParam],e,1001
invoke SendMessage,[hList],LB_RESETCONTENT,0,0
invoke EnumWindows,EnmProc,0
ENDIF
IF dword [@wParam],e,1900
invoke MessageBox,[@hWin],"Assembler, Pure & Simple",\
"Enumerate Windows",MB_OK
ENDIF
IF dword [@wParam],e,502
invoke SendMessage,[hList],LB_RESETCONTENT,0,0
invoke EnumWindows,EnmProc,0
ENDIF

ENDIF

IF dword [@uMsg],e, WM_CREATE
loccall ListBox,20,20,550,200,[@hWin],600
mov [hList], eax
invoke SetWindowLong,[hList],GWL_WNDPROC,ListProc ; proc to controlate list messages
mov [lpfnListProc], eax
loccall Static," hWnd",[@hWin],20,5,52,18,500
loccall Static," Window Class Name",[@hWin],95,5,160,18,501
loccall PushButton,"Refresh",[@hWin],300,2,100,22,502
ENDIF

IF dword [@uMsg],e,WM_SIZE
invoke GetClientRect,[@hWin], addr @Rc
m2m [@rLeft], [@Rc+RECT.left]
add dword [@rLeft], 20
m2m [@rTop], [@Rc+RECT.top]
add dword [@rTop], 25
m2m [@rRight], [@Rc+RECT.right]
sub dword [@rRight], 40
m2m [@rBottom], [@Rc+RECT.bottom]
sub dword [@rBottom], 45
invoke MoveWindow,[hList],[@rLeft],[@rTop],[@rRight],[@rBottom],TRUE
return FALSE
ENDIF
IF dword [@uMsg] ,e, WM_DESTROY
invoke PostQuitMessage,NULL
ENDIF

invoke DefWindowProc,[@hWin],[@uMsg],[@wParam],[@lParam]

endproc WndProc
; - - - - - - - - - - - - - - - - - - -
proc TopXY , wDim , sDim
shr dword [@sDim], 1 ; divide screen dimension by 2
shr dword [@wDim], 1 ; divide window dimension by 2
mov eax, [@wDim] ; copy window dimension into eax
sub [@sDim], eax ; sub half win dimension from half screen dimension
mov eax , [@sDim]
endproc TopXY
; - - - - - - - - - - - - - - - - - - -
proc ListBox , a,b,wd,ht,hParent,ID

stack hLst,4 , \
hFont,4

%assign .style WS_VSCROLL | WS_VISIBLE | WS_BORDER | WS_CHILD | \
LBS_HASSTRINGS |LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL

invoke CreateWindowEx,WS_EX_CLIENTEDGE,"LISTBOX",0,\
.style , [@a],[@b],[@wd],[@ht],[@hParent],[@ID],[hInstance],NULL

mov [@hLst], eax

invoke GetStockObject,SYSTEM_FIXED_FONT ; ANSI_FIXED_FONT
mov [@hFont], eax
invoke SendMessage,[@hLst],WM_SETFONT,[@hFont], 0

mov eax, [@hLst]

endproc ListBox
; - - - - - - - - - - - - - - - - - - -

proc EnmProc , eHandle

stack Buffer,256 ,\
clName,64

invoke GetClassName,[@eHandle],addr @clName ,64
invoke wsprintf,addr @Buffer,"%-2.6lu %s",[@eHandle],addr @clName
invoke SendMessage,[hList],LB_ADDSTRING,0,addr @Buffer
mov eax, [@eHandle]

endproc EnmProc

; - - - - - - - - - - - - - - - - - - -

proc Static , lpText,hParent,a,b,wd,ht,ID

stack hStat,4 ,\
hFont,4

invoke CreateWindowEx,WS_EX_STATICEDGE,"STATIC",[@lpText],\
WS_CHILD | WS_VISIBLE | SS_LEFT,\
[@a],[@b],[@wd],[@ht],[@hParent],[@ID],[hInstance],NULL

mov [@hStat], eax
invoke GetStockObject,ANSI_FIXED_FONT
mov [@hFont], eax
invoke SendMessage,[@hStat],WM_SETFONT,[@hFont], 0
mov eax, [@hStat]

endproc Static
; - - - - - - - - - - - - - - - - - - -
proc ListProc , hCtl , uMsg , wParam , lParam

stack IndexItem,4 ,\
Buffer,128

IF dword [@uMsg],e,WM_CHAR
IF dword [@wParam],e, 13
loccall ShowItem
ENDIF
ENDIF

IF dword [@uMsg],e, WM_LBUTTONDBLCLK
loccall ShowItem
ENDIF

invoke CallWindowProc,[lpfnListProc],[@hCtl],[@uMsg],[@wParam],[@lParam]
return

ShowItem:
invoke SendMessage,[@hCtl],LB_GETCURSEL,0,0
mov [@IndexItem], eax
invoke SendMessage,[@hCtl],LB_GETTEXT,[@IndexItem],addr @Buffer
invoke MessageBox,[hWnd],addr @Buffer,"Enumerate Windows",MB_OK
invoke SetFocus,[@hCtl]
ret

endproc ListProc
; - - - - - - - - - - - - - - - - - - -
proc PushButton , lpText,hParent,a,b,wd,ht,ID

invoke CreateWindowEx,0,\
"BUTTON",[@lpText],\
WS_CHILD | WS_VISIBLE,\
[@a],[@b],[@wd],[@ht],[@hParent],[@ID],\
[hInstance],NULL

endproc PushButton
Posted on 2004-03-27 20:05:33 by Nguga