Posts: 62
Threads: 19
Joined: Jan 2007
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:
EDIT: I have tried clo and DestroyWindow without success.
Posts: 1,769
Threads: 410
Joined: Feb 2003
i think if you put "ret 0" in the "case" statement of the calling dialog, it will stay open.
Posts: 62
Threads: 19
Joined: Jan 2007
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.
Posts: 1,769
Threads: 410
Joined: Feb 2003
post the code for that call and let's take a look at it.
Posts: 62
Threads: 19
Joined: Jan 2007
I made another two dialogs and found that the problem is occurred only when I put quit message with mes.
caller2:
\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:
\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
Posts: 1,769
Threads: 410
Joined: Feb 2003
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.
Posts: 12,092
Threads: 142
Joined: Dec 2002
end ends whole thread. Use id 2, which is IDCANCEL, instead of 4. Or use DT_Cancel, or clo.
\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
Posts: 62
Threads: 19
Joined: Jan 2007
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:
\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
Posts: 12,092
Threads: 142
Joined: Dec 2002
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.
\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
Posts: 62
Threads: 19
Joined: Jan 2007
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.
Posts: 12,092
Threads: 142
Joined: Dec 2002
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.
|