If the dialog is shown modally we can assume variables in that procedure and declared before the dlg creation, then we are able to set a pointer to this variable by using SetProp() API like (pseudo):
Local nResult as Long
Dialog create to hwnd
Setprop( hWnd, "result", Varptr( nResult ) )
Dialog show modal
In the dlg proc:
Local nResult as Long ptr
nResult = GetProp( cbhndl, "result" )
@nResult = 1234
Don't forget to remove the property on WM_DESTROY.
Announcement
Collapse
No announcement yet.
Dialog Show Modal
Collapse
X
-
Just my two cents worth on Dialog End and lresult&. I've found it useful when I want an application to gracefully close files, etc before it ends to always react to that value. I've found that clicking the X to close a dialog will always return a 0 to lresult&, hence I trap that and make it branch to shutdown code for the program before I EXIT FUNCTION.
If I use Child dialogs as message boxes I use the lresult to branch to new appropriate dialog or processing code based on choices made in the popup dialog.
Bob Mechler
Leave a comment:
-
note:
Code:Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes ?Using$("Alt Key pressed " & $CrLf & _ " CbMsg = #" & $CrLf & _ " CbCtl = #" & $CrLf & _ " CbCtlMsg = #", _ CbMsg, CbCtl, CbCtlMsg)
Leave a comment:
-
Thanks, Kev. That seems like a redundant way to do it. I think I'll look at another option before I do that one.
Leave a comment:
-
No that can't be done as the result from WM_DESTROY is lost. If you trap WM_SYSCOMMAND (the close button/Alt+F4), then you can use DIALOG END to return the result:
Code:CALLBACK FUNCTION StartDlgCB() STATIC lRes AS LONG SELECT CASE CONST CBMSG CASE %WM_SYSCOMMAND IF (CBWPARAM AND &HFFF0) = %SC_CLOSE THEN ' User closing dialog... DIALOG END CBHNDL, lRes ' Do this to stop Windows closing the dialog... FUNCTION = %TRUE END IF END SELECT END FUNCTION
Last edited by Kev Peel; 12 Feb 2008, 09:23 PM.
Leave a comment:
-
Well, what I need to do is determine whether a user wants to continue setting up parameters or quit the application. My thought is something like this:
Code:FUNCTION PBMAIN() LOCAL lRes AS LONG lRes = StartDlg(0, 1) IF lRes > 0 then lRes = StartDlg(0, 2) END IF END FUNCTION FUNCTION StartDlg(BYVAL hDlg AS LONG, BYVAL Flag AS BYTE) LOCAL lRes AS LONG ' DIALOG SETUP CODE DIALOG SHOW MODAL, CALL StartDlgCB TO lRes FUNCTION = lRes END FUNCTION CALLBACK FUNCTION StartDlgCB() STATIC lRes AS LONG 'CALLBACK HANDLING CODE CASE %WM_DESTROY IF lRes THEN FUNCTION = lRes END FUNCTION
Leave a comment:
-
Not a DDT programmer here, but in sdk when you call EndDialog() to end a modal dialog box one has the option of returning any value one wishes as the second parameter to the EndDialog call...
Code:BOOL EndDialog ( HWND hDlg, // handle to dialog box int nResult // value to return );
Last edited by Fred Harris; 12 Feb 2008, 08:46 PM.
Leave a comment:
-
Dialog Show Modal
Syntax: DIALOG SHOW MODAL hDlg [[,] CALL callback] [TO lResult&]
According to the help:
lResult&
When the modal dialog is destroyed using the DIALOG END statement, the resulting value is assigned to the lResult& variable, if specified. lResult& is excluded from becoming a Register variable by the compiler, since this value can be assigned from outside of the function containing the DIALOG SHOW MODAL statement, and this may only be performed with a memory variable. However, if the target variable is explicitly declared as a register variable, PowerBASIC raises a compile-time Error 491 ("Invalid register variable").
Is the same result assigned if the user clicks on the system close dialog button?
If I trap the %WM_DESTROY message and set "FUNCTION =" will that be returned to the lResult& variable?Tags: None
Leave a comment: