when child windows are minimized ,if I maximize the frame window , child windows remain in their original minimized position. is there a way to have them a just each time frame window change size while they are in their minimized position . Thanks
Best Regards
mdi question
-
- Enthusiast
- Posts: 105
- Joined: Wed Jan 18, 2006 7:40 pm
- Location: Hamburg
Maybe this give you a hint:
The EventWindow() will tell if the event was from the main window (which has number 0 here),
or the childs who have dynamic IDs MDIChild1 or MDIChild2
This is just to demonstate how to access child windows,
you surely have to use a sort of list to manage child window IDs
[Edit] You should check it the child window IDs still valide,
if you close a child window they can't be use any longer, or you get errors or program crash!
Code: Select all
#Main = 0
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
If CreateMenu(#Main, WindowID(#Main))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
; Using #PB_Any will give you an ID to use in calls to window procedures
; But you could also use constants, but that would be problematic with dynamic creation
MDIChild1 = AddGadgetItem(0, #PB_Any, "Child-Fenster1")
; add gadgets here...
MDICHild2 = AddGadgetItem(0, #PB_Any, "Child-Fenster2")
; add gadgets here...
UseGadgetList(WindowID(#Main)) ; get back to main window gadget list
EndIf
SetWindowTitle(MDIChild1, "New title for child 1") ; set new title for child window 1
Repeat
evt = WaitWindowEvent()
; If evt <> #WM_MOUSEMOVE And evt <> #WM_NCMOUSEMOVE
; Debug "Evt: " + Str(EventWindow()) + ": " + Str(evt)
; EndIf
Select EventWindow()
Case #main
Select evt
Case #PB_Event_SizeWindow
; When main window change size, normalize child windows and rearrange
If MDIChild1
SetWindowState(MDIChild1, #PB_Window_Normal)
EndIf
If MDIChild2
SetWindowState(MDIChild2, #PB_Window_Normal)
EndIf
SetGadgetState(0, #PB_MDI_TileHorizontally)
Case #PB_Event_CloseWindow
; If main windows is close, quit program loop
Break
EndSelect
Case MDIChild1
Select evt
Case #PB_Event_CloseWindow
CloseWindow(MDIChild1)
MDIChild1 = 0 ; Mark window as closed
SetGadgetState(0, #PB_MDI_TileHorizontally) ; Rearrange windows, if any left
Debug "Childs left: " + Str(CountGadgetItems(0))
EndSelect
Case MDIChild2
Select evt
Case #PB_Event_CloseWindow
CloseWindow(MDIChild2)
MDIChild2 = 0 ; Mark window as closed
SetGadgetState(0, #PB_MDI_TileHorizontally)
Debug "Childs left: " + Str(CountGadgetItems(0))
EndSelect
EndSelect
ForEver
EndIf
or the childs who have dynamic IDs MDIChild1 or MDIChild2
This is just to demonstate how to access child windows,
you surely have to use a sort of list to manage child window IDs
[Edit] You should check it the child window IDs still valide,
if you close a child window they can't be use any longer, or you get errors or program crash!
-
- User
- Posts: 54
- Joined: Mon Jul 18, 2005 10:28 am