Code: Select all
EnableExplicit
Enumeration Window
	#Window_Main
	#Window_Child
EndEnumeration
Enumeration Gadget
	#a1
	#b1
	#a2
	#b2
	#yzit
EndEnumeration
Enumeration Gadget
	#ok
	#txt
	#chb
EndEnumeration
Structure MXYWH
	x.l
	y.l
	w.l
	h.l
	m.l
EndStructure
Global WinRect.MXYWH
Global WWE
Declare _MsgBox(txt$, w = 270, h = 180, t = 0)
Declare _ChildCoor(nWin, w, h, c=0, d=0)
If OpenWindow(#Window_Main, 0, 0, 420, 250, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	ButtonGadget (#a1, 5, 5, 50, 30, "corner")
	ButtonGadget (#b1, 5, 45, 50, 30, "center")
	
	ButtonGadget (#a2, 360, 170, 50, 30, "corner")
	ButtonGadget (#b2, 360, 210, 50, 30, "center")
	
	ButtonGadget (#yzit, 170, 110, 70, 30, "reduce")
	
	Repeat
		WWE = WaitWindowEvent()
		
		Select EventWindow()
			Case #Window_Main
				Select WWE
					Case #PB_Event_Gadget
						Select EventGadget()
							Case #a1, #a2
								_MsgBox("Close the program window?", 0, 0, 1)
							Case #b1, #b2
								_MsgBox("Close the program window?")
							Case #yzit
								ResizeWindow(#Window_Main, #PB_Ignore, #PB_Ignore, 200, 70)
								ResizeGadget(#a1, 5, 3, #PB_Ignore, #PB_Ignore)
								ResizeGadget(#b1, 5, 35, #PB_Ignore, #PB_Ignore)
								ResizeGadget(#a2, 140, 3, #PB_Ignore, #PB_Ignore)
								ResizeGadget(#b2, 140, 35, #PB_Ignore, #PB_Ignore)
								ResizeGadget(#yzit, 60, 30, #PB_Ignore, #PB_Ignore)
						EndSelect
					Case #PB_Event_CloseWindow
						CloseWindow(#Window_Main)
						End
				EndSelect
				
			Case #Window_Child
				Select WWE
					Case #PB_Event_Gadget
						Select EventGadget()
							Case #ok
								CloseWindow(#Window_Child)
								DisableWindow(#Window_Main, #False)
						EndSelect
					Case #PB_Event_CloseWindow
						CloseWindow(#Window_Child)
						DisableWindow(#Window_Main, #False)
				EndSelect
		EndSelect
	ForEver
EndIf
Procedure _MsgBox(txt$, w = 270, h = 180, t = 0)
	If Not w
		w = 270
	EndIf
	If Not h
		h = 180
	EndIf
	_ChildCoor(#Window_Main, w, h, t, 30)
	With WinRect
		OpenWindow(#Window_Child, \x, \y, \w, \h, "Message", #PB_Window_SystemMenu)
	EndWith
	SetWindowLongPtr_(WindowID(#Window_Child), #GWL_HWNDPARENT, WindowID(#Window_Main))
	TextGadget(#txt, 10, 10, 250, 60, txt$)
	CheckBoxGadget(#chb, 20, h-80, 240, 20, "Don't ask again")
	ButtonGadget (#ok, (w-50)/2, h - 40, 50, 30, "Ок")
	DisableWindow(#Window_Main, #True)
EndProcedure
Procedure _ChildCoor(nWin, w, h, c=0, d=0)
	Protected DX, DY
	With WinRect
		\h = WindowHeight(nWin)
		\w = WindowWidth(nWin)
		\x = WindowX(nWin)
		\y = WindowY(nWin)
		
		ExamineDesktops()
		DX=DesktopWidth(0)
		DY=DesktopHeight(0)
		If c = 0
			\x+(\w-w)/2
			\y+(\h-h)/2
		EndIf
		If \x+w+d>DX
			\x=DX-w-10-d
		EndIf
		If \y+h+60+d>DY
			\y=DY-h-70-d
		EndIf
		If \x<=d
			\x=d
		EndIf
		If \y<=d
			\y=d
		EndIf
		\w=w
		\h=h
	EndWith
EndProcedure