Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginning "smart dialog "
#1
I started with creating dialogs, but it seems very difficult I have been trying for days to get a grip on it.
I finally now can create a dialogbox and smart dialogbox that triggers a messagebox when pressing a button.
To help me get along a little bit faster an example would help greatly.

- I have folder c:\test which contains 4 text files , and I want those file-names to be populated in a combo-box (dropdown-list-box).
- And I want a window above the combo-box which which gets populated with the contents of "c:\test\pathfile1.txt" and when selecting "pathfile2.txt" from the combo-box, the window above the combo-box gets populated with the contents of "pathfile2.txt"

c:\test\pathfile1.txt
c:\test\pathfile2.txt
c:\test\pathfile3.txt
c:\test\pathfile4.txt

what I mean:

[Image: 13zvgk.gif]

And if it is possible I want to click on a line in the window (see arrow above) and that line to be outputted in the output window. From what I have read, I need a smart-dialog because it keeps processing code after being launched.
#2
Function dialog_files_combo
Code:
Copy      Help
\Dialog_Editor

;Shows text files in My Documents folder in a combo box.
;When a file selected, shows its contents in a list box.

function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4"
str cb3 lb4
if(!ShowDialog("dialog_files_combo" &dialog_files_combo &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 ComboBox 0x54230243 0x0 2 4 96 213 ""
;4 ListBox 0x54230101 0x200 102 4 118 109 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030401 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
ARRAY(str)- aFiles
ARRAY(str) aLines
int i h
str s
sel wParam
,case CBN_DROPDOWN<<16|3
,;on combo dropdown, get txt files from My Documents folder and add filenames
,h=id(3 hDlg)
,GetFilesInFolder aFiles "$documents$" "*.txt"
,SendMessage h CB_RESETCONTENT 0 0
,for(i 0 aFiles.len) CB_Add h s.getfilename(aFiles[i]) i
,
,case CBN_SELENDOK<<16|3
,;on combo item selected, open the file
,h=id(3 hDlg)
,_i=CB_SelectedItem(h)
,if(_i<0) ret
,i=SendMessage(h CB_GETITEMDATA _i 0)
,s.getfile(aFiles[i])
,;add lines to the list box
,aLines=s
,h=id(4 hDlg)
,SendMessage h LB_RESETCONTENT 0 0
,for(i 0 aLines.len) LB_Add h aLines[i] i
,
,case LBN_SELCHANGE<<16|4
,;on list item selected, get its text and show in QM output
,h=id(4 hDlg)
,_i=LB_SelectedItem(h)
,if(_i<0) ret
,LB_GetItemText h _i s
,out s
,
,case IDOK
,case IDCANCEL
ret 1
#3
thank you very much!!!!
#4
Sorry for these 2 very simple questions I tried to look in the Windows API library for question 2.

Question 1
If want to check if a certain button is pressed in the " \Dialog_Editor" code, I do the following
Check what "wParam" outputs when I press a button, for example it outputs: 33554436
Then in QuickMacros in the " \Dialog_Editor", I do the following

Function test1
Code:
Copy      Help
sel wParam
,case 33554436
,,...[PROCESS CODE ON BUTTON PRESS]...
,case IDOK        
,case IDCANCEL
ret 1

Is this correct or is there a faster (better) way ?

Question 2
I have a very simple smart dialog and want to get the output of the text edit-field and the checkbox.
I want to get the output of the text-field and checkbox in the below generated code.


Function dialogtest
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Edit 0x54030080 0x200 4 26 96 14 ""
;4 Button 0x54012003 0x0 110 26 48 12 "Check"
;5 Button 0x54032000 0x0 4 52 48 14 "Button"
;END DIALOG
;DIALOG EDITOR: "" 0x2030307 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

The code generated after rendering the above code is:

Macro Macro13
Code:
Copy      Help
str controls = "3 4"
str e3 c4Che
if(!ShowDialog("dialogtest" &dialogtest &controls)) ret

I can get the output of the 2 elements (text-field and checkbox) very easily here, but I want to get the output in the above "\Dialog_Editor" code.
#5
1. You can see button id in dialog editor, also in dialog definition, also in QM status bar. In dialog function wParam is id.

2.
,case 5 ;;button 5 pressed
,str s.getwintext(id(3 hDlg))
,int checked=but(4 hDlg)
#6
Yes!
That's it, thanks!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)