Restored from previous forum. Originally posted by wayne1.
Code: Select all
;hide gadget example #1
If OpenWindow(0, 100, 100, 395, 260, "Hide Gadgets Example", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget|#PB_Window_SizeGadget)
ButtonGadget(0, 85, 90, 95, 30, "Hide Gadgets")
ButtonGadget(1, 185, 90, 95, 30, "Does Nothing")
ButtonGadget(3, 60, 0, 260, 30, "Restore Hidden Child Windows")
StringGadget(2, 130, 150, 90, 30, "")
CheckBoxGadget(4, 130, 50, 90, 30, "CheckBox")
DisableGadget(3,1)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #PB_Event_Gadget
Select EventGadget()
Case 0
pRect.RECT ; struct for GetClientRect()
*Memory = AllocateMemory(300)
h=GetWindow_(WindowID(0), #GW_CHILD);get first child window handle
Repeat ;loop thru children
GetWindowText_(h, *Memory, 50)
If PeekS(*Memory)= "Restore Hidden Child Windows";don't ask to hide it
Goto SkipIt
EndIf
If PeekS(*Memory) <> "" ;if it has text get it
a = MessageRequester("Message", "This Gadgets text is "+PeekS(*Memory)+",Hide It??",#PB_MessageRequester_YesNo)
Else ;if no text get approx. size
GetClientRect_(h, pRect ); get size
top$= Str(pRect\top) ;always 0
bottom$=Str(pRect\bottom);height
left$=Str(pRect\left);always 0
right$=Str(pRect\right);width
cr$=Chr(10)
a=MessageRequester("Message", "This Gadget has no text but the size is approximately "+cr$+"Width " +right$+cr$+ "Height "+bottom$+cr$+" Hide It??",#PB_MessageRequester_YesNo)
EndIf
If a = 6
ShowWindow_(h,#SW_HIDE);if yes hide child
DisableGadget(3,0);enable restore button
EndIf
SkipIt:
h=GetWindow_(h,#GW_HWNDNEXT); get next child
Until h = 0
Case 3
DisableGadget(3,1);disable restore button just because we can
d=GetWindow_(WindowID(0), #GW_CHILD);get first child
Repeat ;loop thru children
ShowWindow_(d,#SW_SHOW);restore children
d=GetWindow_(d,#GW_HWNDNEXT);get next child
Until d = 0
EndSelect
EndIf
Until Quit = 1
EndIf
End
Edited by - wayne1 on 09 October 2001 03:48:38