format PE GUI 4.0
entry start
include '%fasminc%\win32a.inc'
section '.data' data readable writeable
caption db "Listbox example",0
item1 db 'Item1',0
item2 db 'Item2',0
hCursor dd ?
hInstance dd ?
hListBox dd ?
IndexItem dd ?
buffer rb 10
section '.text' code readable executable
start:
invoke GetModuleHandle, NULL
mov [hInstance],eax
invoke DialogBoxParam,[hInstance],1000,NULL,DlgProc,NULL
invoke ExitProcess,eax
proc DlgProc hWnd, uMsg, wParam, lParam
cmp [uMsg],WM_CLOSE
jne @f
invoke EndDialog,[hWnd],NULL
jmp rtr
@@:
cmp [uMsg],WM_INITDIALOG
jne @f
invoke LoadCursor,0,IDC_CROSS
mov [hCursor],eax
invoke GetDlgItem,[hWnd],1001
mov [hListBox],eax
invoke SendMessage,[hListBox],LB_ADDSTRING,0, item1
invoke SendMessage,[hListBox],LB_ADDSTRING,0, item2
jmp rtr
@@:
cmp [uMsg],WM_SETCURSOR
jne @f
invoke SetCursor,[hCursor]
jmp rtr
@@:
cmp [uMsg],WM_COMMAND
jne rtr1
mov edx,[wParam]
shr edx,16
cmp dx,LBN_DBLCLK
jne rtr
invoke SendMessage,[hListBox],LB_GETCURSEL,0,0
mov [IndexItem], eax
invoke SendMessage,[hListBox],LB_GETTEXT,[IndexItem],buffer
invoke MessageBox,0,buffer,caption,MB_OK
jmp rtr
rtr1:
mov eax,FALSE
ret
rtr:
mov eax,TRUE
ret
endp
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'
import user,\
DialogBoxParam,'DialogBoxParamA',\
GetDlgItemText,'GetDlgItemTextA',\
MessageBox,'MessageBoxA',\
EndDialog,'EndDialog',\
GetDlgItem,'GetDlgItem',\
SendMessage,'SendMessageA',\
LoadCursor,'LoadCursorA',\
SetCursor,'SetCursor'
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs
resource dialogs,\
1000,LANG_ENGLISH+SUBLANG_DEFAULT,MyDialog
dialog MyDialog,'Listbox example',6,6,250,102,WS_SYSMENU + WS_VISIBLE
dialogitem 'LISTBOX','',1001,50,25,150,50, LBS_HASSTRINGS+WS_EX_CLIENTEDGE+WS_VISIBLE+WS_BORDER+WS_CHILD
dialogitem 'STATIC', "Double click on listbox items", 1, 50, 5, 154, 13,WS_VISIBLE
enddialog