Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog return value
#1
If I have dialog in a function called "test_return_value", how can I return any value (negative, 0 or positive) upon pressing a button in that dialog?
For example the below dialog, see button text. (Preferably without using thread/global vairables.)

If want to use the function "test_return_value" function like this:
Code:
Copy      Help
if(test_return_value=-77) out "-77"

I can't do it with: DT_Ret(hDlg -77), DT_Ok(hDlg -77), DT_EndDialog(hDlg -77), ...
(if it is possible, then I am using in an incorrect way).

Function test_return_value
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 72 44 86 39 "upon pressing this button, close this dialog and return -77"
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,,;; When this button is pressed
,,;; 1. Close this dialog
,,;; 2. Return: -77
,,;; ...
ret 1
#2
Function test_return_value
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 72 44 86 39 "upon pressing this button, close this dialog and return -77"
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

ret ShowDialog(dd &sub.DlgProc 0)


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,,DT_Ok(hDlg -77)
ret 1
#3
I already tried that before and it didn't work! (!?)
I tried your code again and now it works!!! (!?)

I'm really confused! But it works now...!

Thank you!!!

EDIT:
Now I know why just using
Code:
Copy      Help
DT_Ok
didn't work.
I also needed to change the showdialog line, like you did!!!
Code:
Copy      Help
ret ShowDialog(dd &sub.DlgProc 0)

I never would have thought of also changing that line! Thanks again!


Forum Jump:


Users browsing this thread: 2 Guest(s)