flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > Need help with CB_ADDSTRING

Author
Thread Post new topic Reply to topic
catafest



Joined: 05 Aug 2010
Posts: 100
I try to use CB_ADDSTRING to add items to combobox and use it .
I read this https://board.flatassembler.net/topic.php?p=149763, but is not very clear to me.
This is the source code:
Code:
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
Post 12 Dec 2017, 21:52
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 128
Changes I made to get string to populate combo.

Code:
; invoke SetDlgItemText,[hwnddlg],IDC_COMBOBOX_1,szInitText invoke SendDlgItemMessage,[hwnddlg],IDC_COMBOBOX_1,CB_ADDSTRING,0,szInitText import user,\ .. SendDlgItemMessage,'SendDlgItemMessageA',\ ; dialogitem 'COMBOBOX',IDC_COMBOBOX_1,-1,10,10,140,12,BS_GROUPBOX+WS_VISIBLE+WS_VSCROLL,0 dialogitem 'COMBOBOX',"",IDC_COMBOBOX_1,10,10,140,50,WS_VISIBLE+WS_VSCROLL+CBS_DROPDOWNLIST
Post 13 Dec 2017, 02:05
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 100
@Walter: SendDlgItemMessage into resource ?
I think you make a copy paste from internet I saw many examples.
If you try tell me about messaging issue , I know just : SendMessage,'SendMessageA'
Post 13 Dec 2017, 07:49
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 100
The next step , try the SendMessage issue:
The FASM compile the source code but when I run the window form is not show.
I think is something wrong with code after .wminitdialog .
Code:
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 mov [ctr_item_ID],eax mov esi,items @@: or eax,eax jz @f push eax invoke SendMessage,[ctr_item_ID],CB_ADDSTRING,NULL,esi pop eax add esi,eax inc esi jmp @r @@: jmp .done .wmclose: invoke EndDialog,[hwnddlg],0 .done: mov eax,1 .quit: ret endp section '.data' readable ctr_item_ID dd ? items db 'Item_1',0 db 'Item_2',0 db 'Item_3',0 db 'Item_4',0 db NULL 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',\ SendMessage,'SendMessageA' 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
Post 13 Dec 2017, 11:04
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.