Today I start with a simple FASM tutorial about combo box control.
In this tutorial, I will show you how to deal with this control.
First, you need to create a simple window and then to add it.
The steps are very simple:
- start program with the format PE GUI 4.0
- define the entry start point to start running ;
- include library win32a;
- create two ID’s: one for window form and one for combo box control;
- create sections for : .code, .idata , .text and .rc;
- create a variable ( named by me szInitText ) to use like string message into the .itext area ;
- fill the .idata and .irc with my source code ( default settings for window and set the dialog item );
- create the DialogProc and fill with all is a need to make the window form;
This source code just creates combo box control without items.
This is the source code of this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | ;---- free-tutorials.org - FASM - tutorials ;---- december 2017 format PE GUI 4.0 entry start include 'win32a.inc' IDD_TEST_DIALOGS = 102 IDC_COMBOBOX_1 = 1000 section '.code' code readable executable start: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,IDD_TEST_DIALOGS,0,DialogProc,0 exit: invoke ExitProcess,0 proc DialogProc uses esi edi ebx,hwnddlg,msg,wparam,lparam cmp [msg],WM_INITDIALOG je .wminitdialog cmp [msg],WM_CLOSE je .wmclose xor eax,eax jmp .quit .wminitdialog: invoke SetDlgItemText,[hwnddlg],IDC_COMBOBOX_1,szInitText jmp .done .wmclose: invoke EndDialog,[hwnddlg],0 .done: mov eax,1 .quit: 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',\ SetDlgItemText,'SetDlgItemTextA',\ EndDialog,'EndDialog' section '.text' readable writeable szInitText db "Text set by WM_INITDIALOG.",0 section '.rc' resource data readable directory RT_DIALOG,dialogs resource dialogs,IDD_TEST_DIALOGS,LANG_ENGLISH+SUBLANG_DEFAULT,mod_exp_dialog dialog mod_exp_dialog,\ 'FASM - Dialogs Examples - combobox',0,0,160,160,\ DS_MODALFRAME+WS_MINIMIZEBOX+WS_POPUP+WS_VISIBLE+WS_CAPTION+WS_SYSMENU,\ 0,0,"Lucida Console",11 dialogitem 'COMBOBOX',IDC_COMBOBOX_1,-1,10,10,140,12,BS_GROUPBOX+WS_VISIBLE+WS_VSCROLL,0 enddialog |
This is the result :