Cool window with child window (attached child):
Code: Select all
Global Toggle=0
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
If Message = #WM_MOVE And IsWindow(1)
GetWindowRect_(WindowID, @Rect.RECT)
ResizeWindow(1, Rect\right, Rect\top, #PB_Ignore, #PB_Ignore)
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow(0, 0, 0, 400, 300, "Left window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ButtonGadget(2, 150, 100, 100, 100, "Show child window")
Procedure ShowIt()
GetWindowRect_(WindowID(0), @Rect.RECT)
OpenWindow(1, Rect\right, Rect\top, 300, 200, "Right window", #PB_Window_SystemMenu | #PB_Window_TitleBar,WindowID(0))
SetWindowCallback(@MyWindowCallback(), 0)
hMenu = GetSystemMenu_(WindowID(1), 0)
RemoveMenu_(hMenu, #SC_MOVE, #MF_BYCOMMAND )
toggle=1
EndProcedure
Procedure CloseIt()
CloseWindow(1)
toggle=0
EndProcedure
Repeat
windowevent=WaitWindowEvent()
Gadget=EventGadget()
window=EventWindow()
EventType = EventType()
If Gadget = 2 And EventType = #PB_EventType_LeftClick
If toggle=0
ShowIt()
Else
CloseIt()
EndIf
EndIf
If window=0 And Windowevent=#PB_Event_CloseWindow
Break
ElseIf window=1 And Windowevent=#PB_Event_CloseWindow
CloseIt()
EndIf
ForEver
End