Lionheart008
12-03-2010, 21:17
some month ago I was looking for a way to close a dialog by a second dialog.
I searched a solution deleting the first dialog by a second one.
I didn't find my "transmitter" example here at the board (there were four dialogs with sending different messages to other dialogs), so I've made a simple solution for this task. I am so glad to find this little but precious trick ;)
success: you can close with second dialog the first dialog and vice versa. try it! :)
my ten cents for today:
' Empty GUI script created on 03-12-2010 18:50:45 by frank (ThinAIR)
Uses "console", "ui"
%one = 1001
%two = 1002
%close = 1003
%four = 1004
%closeFirst = 1005
%closethis = 1006
Global hDlg, hDlg2 As DWord
Function TBMain() As Long
Dialog New Pixels, 0, "Close App from anotherOne",300,300,340,340, %WS_OVERLAPPEDWINDOW To hDlg
Control Add Button, hDlg, %one,"Create a new Dialog", 30,20,150,40
Control Add Button, hDlg, %two,"Close second Dialog", 30,80,150,40
Control Add Button, hDlg, %close,"Close this Dialog", 30,160,150,40
Dialog Set Gradient hDlg, %GRADIENT_FILL_H, Rgb(255,0,100), Rgb(0,150,255)
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %one Then
Dialog New Pixels, 0, "Another Dialog",600,320,300,400, %WS_OVERLAPPEDWINDOW To hDlg2
Control Add Textbox, hDlg2, %four,"my textBox for Lord of the Rings", 40,260,180,20
Control Add Button, hDlg2, %closeFirst,"Close first Dialog", 30,80,150,40 Call DlgProc2
Control Add Button, hDlg2, %closethis,"Close THIS Dialog", 30,180,150,40 Call DlgProc
Dialog Set Gradient hDlg2, %GRADIENT_FILL_H, Rgb(155,200,100), Rgb(100,250,55)
Dialog Set Text hDlg, "..first dialog ready"
Dialog Show Modal hDlg2
End If
If CBWPARAM = %two Then
Dialog Set Text hDlg, "2. dialog was canceled"
Dialog End hDlg2
End If
If CBWPARAM = %close Then Dialog End CBHNDL
If CBWPARAM = %closeThis Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
CallBack Function DlgProc2() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %closeFirst Then Dialog End hdlg
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
sometimes it takes only some month to get the mind clear again.
best regards, frank
I searched a solution deleting the first dialog by a second one.
I didn't find my "transmitter" example here at the board (there were four dialogs with sending different messages to other dialogs), so I've made a simple solution for this task. I am so glad to find this little but precious trick ;)
success: you can close with second dialog the first dialog and vice versa. try it! :)
my ten cents for today:
' Empty GUI script created on 03-12-2010 18:50:45 by frank (ThinAIR)
Uses "console", "ui"
%one = 1001
%two = 1002
%close = 1003
%four = 1004
%closeFirst = 1005
%closethis = 1006
Global hDlg, hDlg2 As DWord
Function TBMain() As Long
Dialog New Pixels, 0, "Close App from anotherOne",300,300,340,340, %WS_OVERLAPPEDWINDOW To hDlg
Control Add Button, hDlg, %one,"Create a new Dialog", 30,20,150,40
Control Add Button, hDlg, %two,"Close second Dialog", 30,80,150,40
Control Add Button, hDlg, %close,"Close this Dialog", 30,160,150,40
Dialog Set Gradient hDlg, %GRADIENT_FILL_H, Rgb(255,0,100), Rgb(0,150,255)
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %one Then
Dialog New Pixels, 0, "Another Dialog",600,320,300,400, %WS_OVERLAPPEDWINDOW To hDlg2
Control Add Textbox, hDlg2, %four,"my textBox for Lord of the Rings", 40,260,180,20
Control Add Button, hDlg2, %closeFirst,"Close first Dialog", 30,80,150,40 Call DlgProc2
Control Add Button, hDlg2, %closethis,"Close THIS Dialog", 30,180,150,40 Call DlgProc
Dialog Set Gradient hDlg2, %GRADIENT_FILL_H, Rgb(155,200,100), Rgb(100,250,55)
Dialog Set Text hDlg, "..first dialog ready"
Dialog Show Modal hDlg2
End If
If CBWPARAM = %two Then
Dialog Set Text hDlg, "2. dialog was canceled"
Dialog End hDlg2
End If
If CBWPARAM = %close Then Dialog End CBHNDL
If CBWPARAM = %closeThis Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
CallBack Function DlgProc2() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %closeFirst Then Dialog End hdlg
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
sometimes it takes only some month to get the mind clear again.
best regards, frank