Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help on Dialog
#1
I have a simple dialog box which has 1 listbox and 1 edit box
In the listbox I fill it with a list of exe files
I would like to select one of them and calculate its MD5 Hash value.
The result will be showed in the edit box.
So far
- I could populate the listbox with exe files.
- I could find the MD5 hash value for that exe file.
But I could not show it in the edit box, I did try this
s.setwintext(id(3, hDlg))
but I still don't see it appear on the edit box
I did verify by this
e3.getwintext(id(3, hDlg))
out e3
and see it there.
any suggestion?
Besides I would like the dialog to stay open not close after I press the OK button. What should I do?

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

str controls = "3"
str e3

if(!ShowDialog("dlg_MD5_Hash" &dlg_MD5_Hash &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 230 196 "Dialog"
;3 Edit 0x54030080 0x200 66 144 158 16 ""
;5 ListBox 0x54230109 0x200 6 9 218 128 ""
;4 Static 0x54000200 0x0 6 144 54 16 "MD5 Hash Value"
;1 Button 0x54030001 0x0 147 168 48 14 "OK"
;2 Button 0x54030000 0x0 87 168 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040108 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,,ARRAY(str) exeList; int i
,,str initdir="$my qm$"
,,if(!BrowseForFolder(_s initdir 4)) ret
,,GetFilesInFolder exeList _s "*.exe"
,,for i 0 exeList.len-1
,,,LB_Add id(5 hDlg) exeList[i]

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 1
,,str item
,,LB_SelectedItem(id(5 hDlg) item)
,,str s.FileMD5(item 1)
,,s.setwintext(id(3, hDlg))
,,e3.getwintext(id(3, hDlg))
,,out e3
,,3
,case 2 end
,case IDOK
,case IDCANCEL
ret 1
#2
Function dlg_MD5_Hash
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str e3

if(!ShowDialog("dlg_MD5_Hash" &dlg_MD5_Hash &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 230 196 "Dialog"
;3 Edit 0x54030080 0x200 66 144 158 16 ""
;5 ListBox 0x54230101 0x200 6 9 218 128 ""
;4 Static 0x54000200 0x0 6 144 54 16 "MD5 Hash Value"
;1 Button 0x54030001 0x0 147 168 48 14 "OK"
;2 Button 0x54030000 0x0 87 168 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040108 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,,ARRAY(str) exeList; int i
,,str initdir="$my qm$"
,,if(!BrowseForFolder(_s initdir 4)) ret
,,GetFilesInFolder exeList _s "*.exe"
,,for i 0 exeList.len
,,,LB_Add id(5 hDlg) exeList[i]

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|5 ;;this code is created with the Events button in the Dialog Editor
,_i=LB_SelectedItem(lParam)
,,str item
,,LB_SelectedItem(id(5 hDlg) item)
,,str s.encrypt(2|8 item "" 0x100)
,,s.setwintext(id(3, hDlg))
,,e3.getwintext(id(3, hDlg))
,,out e3
,,;3 ;;don't use wait in dialogs
,;case 2 end ;;don't use end to end dialog
,case IDOK
,;ret 0 ;;return 0 if don't want to close dialog on OK
,case IDCANCEL
ret 1
#3
It works like a charm!
Thanks a lot for your help!
#4
Now if I want to call this dialog from my toolbar what should I do?
I did this:
...
case MD5: dlg_MD5_Hash
...
and the program saying this needs 4 arguments, not 0

What arguments should I provide though?
#5
Ah huh! I thought it's a function so I could call it directly, but I have to call it like a macro.
Thanks for the help!
#6
Sorry, my answer was incorrect. Toolbar/menu code runs in own thread. Only toolbar hook functions run in main QM thread. You can use any of the 4 methods to show the dialog from toolbar. I deleted that post.

1. dlg_MD5_Hash 0 0 0 0
2. In the function line enclose all 4 parameters in [ ]. Then to call: dlg_MD5_Hash
3. Create dialog without the function line. QM 2.4.1 creates such dialogs by default. Then to call: dlg_MD5_Hash
4. mac "dlg_MD5_Hash"
#7
Thank you for clarification:
In four mehods to call directly I could verify and see it runs correctly with number 1, 2 and 4
For number 3, I still have no clue how to use it since I still need a "hDlg" to populate the ListBox
e.g.: LB_Add id(5 hDlg) exeList[i]
#8
Macro Macro2372
Code:
Copy      Help
\Dialog_Editor

str controls = "3"
str e3

if(!ShowDialog("" &sub.DlgProc &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 230 196 "Dialog"
;3 Edit 0x54030080 0x200 66 144 158 16 ""
;5 ListBox 0x54230101 0x200 6 9 218 128 ""
;4 Static 0x54000200 0x0 6 144 54 16 "MD5 Hash Value"
;1 Button 0x54030001 0x0 147 168 48 14 "OK"
;2 Button 0x54030000 0x0 87 168 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040108 "" "" "" ""

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,ARRAY(str) exeList; int i
,,str initdir="$my qm$"
,,if(!BrowseForFolder(_s initdir 4)) ret
,,GetFilesInFolder exeList _s "*.exe"
,,for i 0 exeList.len
,,,LB_Add id(5 hDlg) exeList[i]

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|5 ;;this code is created with the Events button in the Dialog Editor
,_i=LB_SelectedItem(lParam)
,,str item
,,LB_SelectedItem(id(5 hDlg) item)
,,str s.encrypt(2|8 item "" 0x100)
,,s.setwintext(id(3, hDlg))
,,str e3.getwintext(id(3, hDlg))
,,out e3
,,;3 ;;don't use wait in dialogs
,;case 2 end ;;don't use end to end dialog
,case IDOK
,;ret 0 ;;return 0 if don't want to close dialog on OK
,case IDCANCEL
ret 1
#9
Now I see, you wrap the function in a #sub functon and call it.
That's really neat and cool!
Thanks for the sample.


Forum Jump:


Users browsing this thread: 2 Guest(s)