Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple smart dialogs: ending just one
#1
I have a smart dialog that calls another smart dialog, but when I close the called dialog, it closes the main dialog, too. How can I close just one dialog.
I have this code in the called dialog:
Code:
Copy      Help
,case IDCANCEL
,end


EDIT: I have tried clo and DestroyWindow without success.
#2
i think if you put "ret 0" in the "case" statement of the calling dialog, it will stay open.
An old blog on QM coding and automation.

The Macro Hook
#3
ken gray Wrote:i think if you put "ret 0" in the "case" statement of the calling dialog, it will stay open.
That doesn't help..

EDIT: The caller stays opened when it calls the another, but it's closed if the another is closed.
#4
post the code for that call and let's take a look at it.
An old blog on QM coding and automation.

The Macro Hook
#5
I made another two dialogs and found that the problem is occurred only when I put quit message with mes.

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

if(!ShowDialog("caller2" &caller2)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 71 97 "Dialog"
;1 Button 0x54030001 0x4 10 14 48 14 "Call"
;2 Button 0x54030000 0x4 10 34 48 14 "Exit"
;3 Static 0x54000000 0x0 10 52 48 34 "I simplified this dialog for testing. Still same issue.."
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,if(!ShowDialog("another" &another)) ret
,case IDCANCEL
ret 1

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

if(!ShowDialog("another" &another)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 85 46 "Dialog"
;4 Button 0x54030000 0x4 8 24 68 14 "Close this one"
;3 Static 0x54000000 0x0 8 10 68 10 "I have been called.."
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,mes "I'm going to be closed."
,end
,
,case IDOK
,case IDCANCEL
ret 1
#6
here's how i got it to work right.

create another button. don't edit the line that is the "ok" button definition; delete it entirely.

in your called dialog, don't use "end" use "clo hDlg". that does what youre wanting.
An old blog on QM coding and automation.

The Macro Hook
#7
end ends whole thread. Use id 2, which is IDCANCEL, instead of 4. Or use DT_Cancel, or clo.

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

if(!ShowDialog("another" &another)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 85 46 "Dialog"
;2 Button 0x54030000 0x4 8 24 68 14 "Close this one"
;3 Static 0x54000000 0x0 8 10 68 10 "I have been called.."
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,mes "I'm going to be closed."
ret 1
#8
That works after button press, but i close the dialog other way(after many checks in case WM_INITDIALOG). It doesn't work there.

Caller is the same as above, but I changed the another:
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("another" &another)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 85 46 "Dialog"
;4 Button 0x54030000 0x4 8 24 68 14 "Close this one"
;3 Static 0x54000000 0x0 8 10 68 10 "I have been called.."
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,mes "check! now clo hDlg"
,clo hDlg
,mes "still here? now super forced end"
,end
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,mes "I'm going to be closed."
,clo hDlg
,
,case IDOK
,case IDCANCEL
ret 1
#9
Just remove

,mes "still here? now super forced end"
,end

To see what happens, place Deb before first mes. Before starting, click menu File -> Collapse folders.

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

if(!ShowDialog("another" &another)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 85 46 "Dialog"
;4 Button 0x54030000 0x4 8 24 68 14 "Close this one"
;3 Static 0x54000000 0x0 8 10 68 10 "I have been called.."
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,mes "check! now clo hDlg"
,Deb 500
,clo hDlg
,mes "still here? now super forced end"
,;end
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,mes "I'm going to be closed."
,clo hDlg
,
,case IDOK
,case IDCANCEL
ret 1
#10
So when using "clo hDlg", it continues the code process, but closes the visible window. In my case I need to stop parsing the code after window close.
#11
Why? When you click Cancel or call clo, ShowDialog returns 0, and no code is executed after if(!ShowDialog(...)) ret. The code that is executed after clo is required to properly close the window without memory leaks etc.


Forum Jump:


Users browsing this thread: 1 Guest(s)