Thanks Eros; :p
The example has a bug in it. The Control ID's have the same Numbers. :(
It's working now. here is the code....
uses "UI"
'----------------------------------------------------------------
' Main Dialog (called a MDI Frame)
'----------------------------------------------------------------
%MDIFrame_MDI = 500
%MDIFrame_MAKECHILD = 505
%MDIFrame_SEPARATOR_510 = 510
%MDIFrame_EXIT = 515
Global hMDIFrame As Long ' Main MDI Dialog handle
Global hMDIFrame_Menu0 As Long
Global hMDIFrame_Menu1 As Long
Global hMDIFrame_Menu2 As Long
Global MDI_ClientHandle As Long
Global Style As Long
Global ExStyle As Long
'----------------------------------------------------------------
' Dlg1 Dialog
%Dlg1_but1 = 100
%Dlg1_but2 = 105 :(
%Dlg1_txt1 = 110
%child1_Select = 115
Global hMDIChild1 As Long
'----------------------------------------------------------------
' Dlg2 Dialog
%Dlg2_but1 = 200
%Dlg2_but2 = 205
%Dlg2_txt1 = 210
%child2_Select = 215
Global hMDIChild2 As Long
'----------------------------------------------------------------
' Dlg3 Dialog
%Dlg3_but1 = 300
%Dlg3_but2 = 305
%Dlg3_txt1 = 310
%child3_Select = 315
Global hMDIChild3 As Long
'----------------------------------------------------------------
' Dlg4 Dialog
%Dlg4_but1 = 400
%Dlg4_but2 = 405
%Dlg4_txt1 = 410
%child4_Select = 415
Global hMDIChild4 As Long
'----------------------------------------------------------------
' Main Dialog (called a MDI Frame)
Sub TBMain() As Long
Style = %WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER
ExStyle = 0
Dialog New 0, "MDI using UI", 0, 0, 450, 320, Style, ExStyle To hMDIFrame
Menu New Bar To hMDIFrame_Menu0
Menu New PopUp To hMDIFrame_Menu1
MENU Add Popup, hMDIFrame_Menu0 ,"&File", hMDIFrame_Menu1, %MF_ENABLED
MENU Add String, hMDIFrame_Menu1, "E&xit", %MDIFrame_EXIT, %MF_ENABLED
MENU New Popup To hMDIFrame_Menu2
MENU Add Popup, hMDIFrame_Menu0 ,"&Select", hMDIFrame_Menu2, %MF_ENABLED
MENU Add String, hMDIFrame_Menu2, "Select Dialog 1", %child1_Select, %MF_ENABLED
MENU Add String, hMDIFrame_Menu2, "Select Dialog 2", %child2_Select, %MF_ENABLED
MENU Add String, hMDIFrame_Menu2, "Select Dialog 3", %child3_Select, %MF_ENABLED
MENU Add String, hMDIFrame_Menu2, "Select Dialog 4", %child4_Select, %MF_ENABLED
Menu Attach hMDIFrame_Menu0, hMDIFrame
'---Must be MODELESS dialog without a message loop
'---Message loop will be governed by MDI_MessageLoop function
'---To be executed after this line
Dialog Show Modeless hMDIFrame , Call MDIFrame_DLGPROC
' ----------------------
MDI_ClientHandle = MDI_CreateClient(hMDIFrame)
' ---------------------- IMPORTANT
MDI_SubClassDialog hMDIFrame
' ----------------------
' IMPORTANT: MDI_MessageLoop must be invoked after MDI_CreateClient calling
' MDI_MessageLoop MDI_ClientHandle
'-----------------------
ShowDialog_MDIChild1 MDI_ClientHandle ' client is parent
ShowDialog_MDIChild2 MDI_ClientHandle ' client is parent
ShowDialog_MDIChild3 MDI_ClientHandle ' client is parent
ShowDialog_MDIChild4 MDI_ClientHandle ' client is parent
MDI_SendMessage %WM_MDIACTIVATE, hMDIChild1, 0
MDI_SendMessage %WM_MDIACTIVATE, hMDIChild2, 0
MDI_SendMessage %WM_MDIACTIVATE, hMDIChild3, 0
MDI_SendMessage %WM_MDIACTIVATE, hMDIChild4, 0
Dialog Show State hMDIchild1, %SW_MAXIMIZE
MDI_MessageLoop MDI_ClientHandle
End Sub
'----------------------------------------------------------------
CallBack Function MDIFrame_DLGPROC() as long
'----------------------------------------------------------------
Select Case CbMsg
Case %WM_INITDIALOG
Case %WM_SIZE
Case %WM_COMMAND
Select Case CbCtl
'Case %MDIFrame_MAKECHILD
'MDIFrame_MAKECHILD_Create
Case %child1_Select
Dialog Show State hMDIchild1, %SW_MAXIMIZE
Dialog Show State hMDIchild2, %SW_HIDE
Dialog Show State hMDIchild3, %SW_HIDE
Dialog Show State hMDIchild4, %SW_HIDE
Case %child2_Select
Dialog Show State hMDIchild1, %SW_HIDE
Dialog Show State hMDIchild2, %SW_MAXIMIZE
Dialog Show State hMDIchild3, %SW_HIDE
Dialog Show State hMDIchild4, %SW_HIDE
Case %child3_Select
Dialog Show State hMDIchild1, %SW_HIDE
Dialog Show State hMDIchild2, %SW_HIDE
Dialog Show State hMDIchild3, %SW_MAXIMIZE
Dialog Show State hMDIchild4, %SW_HIDE
Case %child4_Select
Dialog Show State hMDIchild1, %SW_HIDE
Dialog Show State hMDIchild2, %SW_HIDE
Dialog Show State hMDIchild3, %SW_HIDE
Dialog Show State hMDIchild4, %SW_MAXIMIZE
Case %MDIFrame_EXIT
dialog end cbhndl
Case Else
End Select
Case %WM_DESTROY
'--------------------
' Important otherwise process remain active
'--------------------
MDI_PostQuitMessage
Case Else
End Select
End Function
'----------------------------------------------------------------
' Make MDI Child1 Dialog
Sub ShowDialog_MDIChild1(ByVal hParent As Long)
Style = %WS_CHILD | %DS_MODALFRAME | %WS_MINIMIZEBOX | %WS_MAXIMIZEBOX | %WS_CLIPSIBLINGS
ExStyle = %WS_EX_MDICHILD | %WS_EX_CONTROLPARENT
Dialog New hParent, "MDI Child #1 using UI", 0, 0, 267, 138, Style, ExStyle To hMDIChild1
Control Add "Button", hMDIChild1, %Dlg1_but1, "Button 1", 21, 20, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add "Button", hMDIChild1, %Dlg1_but2, "Button 2", 21, 39, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add TextBox, hMDIChild1, %Dlg1_txt1, "", 93, 20, 147, 103, _
%WS_CHILD Or %WS_VISIBLE Or %ES_MULTILINE Or %ES_WANTRETURN Or %ES_LEFT Or %WS_TABSTOP, _
%WS_EX_CLIENTEDGE
Dialog Set Color hMDIChild1, -1, Rgb(175,90,75)
Dialog Show State hMDIchild1, %SW_HIDE
Dialog Show Modeless hMDIChild1 , Call MDIChild1_DLGPROC
End Sub
'----------------------------------------------------------------
CallBack Function MDIChild1_DLGPROC() as long
'----------------------------------------------------------------
Select Case CbMsg
Case %WM_INITDIALOG
' ---------------------- IMPORTANT
'MDI_SetExtendedStyles CbHndl
MDI_SubClassDialog CbHndl
' ----------------------
case %WM_COMMAND
select case cbctl
Case %Dlg1_but1
control set text cbhndl, %Dlg1_txt1, "Pressed buton 1"
Case %Dlg1_but2
Control Set Text CBHNDL, %Dlg1_txt1, "Pressed buton 2"
end select
Case Else
End Select
End Function
'----------------------------------------------------------------
' Make MDI Child2 Dialog
'----------------------------------------------------------------
Sub ShowDialog_MDIChild2(ByVal hParent as long)
Style = %WS_CHILD Or %DS_MODALFRAME Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_CLIPSIBLINGS
ExStyle = %WS_EX_MDICHILD | %WS_EX_CONTROLPARENT
Dialog New hParent, "MDI Child #2 using UI", 40, 20, 267, 138, Style, ExStyle To hMDIChild2
Control Add "Button", hMDIChild2, %Dlg2_but1, "Button 1", 21, 60, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add "Button", hMDIChild2, %Dlg2_but2, "Button 2", 21, 80, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add TextBox, hMDIChild2, %Dlg2_txt1, "", 93, 20, 147, 103, _
%WS_CHILD Or %WS_VISIBLE Or %ES_MULTILINE Or %ES_WANTRETURN Or %ES_LEFT Or %WS_TABSTOP, _
%WS_EX_CLIENTEDGE
Dialog Set Color hMDIChild2, -1, Rgb(75,190,75)
Dialog Show State hMDIchild2, %SW_HIDE
Dialog Show Modeless hMDIChild2 , Call MDIChild2_DLGPROC
End Sub
'----------------------------------------------------------------
CallBack Function MDIChild2_DLGPROC() as long
'----------------------------------------------------------------
Select Case CbMsg
Case %WM_INITDIALOG
' ---------------------- IMPORTANT
'MDI_SetExtendedStyles CbHndl
MDI_SubClassDialog CbHndl
' ----------------------
case %WM_COMMAND
select case cbctl
Case %Dlg2_but1
'Dialog Show State hMDIchild1, %SW_HIDE
control set text cbhndl, %Dlg2_txt1, "Pressed buton 1"
Case %Dlg2_but2
'Dialog Show State hMDIchild1, %SW_SHOW
Control Set Text CBHNDL, %Dlg2_txt1, "Pressed buton 2"
end select
Case Else
End Select
End Function
'----------------------------------------------------------------
' Make MDI Child3 Dialog
'----------------------------------------------------------------
Sub ShowDialog_MDIChild3(ByVal hParent As Long)
Style = %WS_CHILD Or %DS_MODALFRAME Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_CLIPSIBLINGS
ExStyle = %WS_EX_MDICHILD | %WS_EX_CONTROLPARENT
Dialog New hParent, "MDI Child #3 using UI", 40, 20, 267, 138, Style, ExStyle To hMDIChild3
Control Add "Button", hMDIChild3, %Dlg3_but1, "Button 1", 21, 60, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add "Button", hMDIChild3, %Dlg3_but2, "Button 2", 21, 80, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add Textbox, hMDIChild3, %Dlg3_txt1, "", 93, 20, 147, 103, _
%WS_CHILD Or %WS_VISIBLE Or %ES_MULTILINE Or %ES_WANTRETURN Or %ES_LEFT Or %WS_TABSTOP, _
%WS_EX_CLIENTEDGE
Dialog Set Color hMDIChild3, -1, Rgb(75,90,175)
Dialog Show State hMDIchild3, %SW_HIDE
Dialog Show Modeless hMDIChild3 , Call MDIChild3_DLGPROC
End Sub
'----------------------------------------------------------------
CallBack Function MDIChild3_DLGPROC() As Long
Select Case CBMSG
Case %WM_INITDIALOG
' ---------------------- IMPORTANT
'MDI_SetExtendedStyles CbHndl
MDI_SubClassDialog CBHNDL
' ----------------------
Case %WM_COMMAND
Select Case CBCTL
Case %Dlg3_but1
Control Set Text CBHNDL, %Dlg3_txt1, "Pressed 1"
Case %Dlg3_but2
Control Set Text CBHNDL, %Dlg3_txt1, "Pressed 2"
End Select
Case Else
End Select
End Function
'----------------------------------------------------------------
' Make MDI Child4 Dialog
'----------------------------------------------------------------
Sub ShowDialog_MDIChild4(ByVal hParent As Long)
Style = %WS_CHILD Or %DS_MODALFRAME Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_CLIPSIBLINGS
ExStyle = %WS_EX_MDICHILD | %WS_EX_CONTROLPARENT
Dialog New hParent, "MDI Child #4 using UI", 40, 20, 267, 138, Style, ExStyle To hMDIChild4
Control Add "Button", hMDIChild4, %Dlg4_but1, "Button 1", 21, 60, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add "Button", hMDIChild4, %Dlg4_but2, "Button 2", 21, 80, 53, 15, _
%WS_CHILD Or %WS_VISIBLE Or %BS_PUSHBUTTON Or %WS_TABSTOP
Control Add Textbox, hMDIChild4, %Dlg4_txt1, "", 93, 20, 147, 103, _
%WS_CHILD Or %WS_VISIBLE Or %ES_MULTILINE Or %ES_WANTRETURN Or %ES_LEFT Or %WS_TABSTOP, _
%WS_EX_CLIENTEDGE
Dialog Set Color hMDIChild4, -1, Rgb(75,190,175)
Dialog Show State hMDIchild4, %SW_HIDE
Dialog Show Modeless hMDIChild4 , Call MDIChild4_DLGPROC
End Sub
'----------------------------------------------------------------
CallBack Function MDIChild4_DLGPROC() As Long
Select Case CBMSG
Case %WM_INITDIALOG
' ---------------------- IMPORTANT
'MDI_SetExtendedStyles CbHndl
MDI_SubClassDialog CBHNDL
' ----------------------
Case %WM_COMMAND
Select Case CBCTL
Case %Dlg4_but1
Control Set Text CBHNDL, %Dlg4_txt1, "buton 1"
Case %Dlg4_but2
Control Set Text CBHNDL, %Dlg4_txt1, "buton 2"
End Select
Case Else
End Select
End Function