Just starting out? Need help? Post your questions and find answers here.
rndrei
Enthusiast
Posts: 153 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 14, 2025 9:48 am
How to find out if ContainerGadget has changed ( #PB_EventType_Resize )?!
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "ContainerGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(0, 8, 8, 306, 133, #PB_Container_Raised)
ButtonGadget(1, 10, 15, 80, 24, "Button 1")
ButtonGadget(2, 95, 15, 80, 24, "Button 2")
CloseGadgetList()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Piero
Addict
Posts: 923 Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy
Post
by Piero » Mon Apr 14, 2025 10:54 am
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "ContainerGadget")
ButtonGadget(0, 10, 15, 80, 24, "Resize")
ContainerGadget(1, 8, 8, 306, 133, #PB_Container_Raised)
CloseGadgetList()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
ResizeGadget(1, 8, 8, 306, 99)
Case 1
Select EventType()
Case #PB_EventType_Resize
Debug "Resize Event"
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Axolotl
Addict
Posts: 837 Joined: Wed Dec 31, 2008 3:36 pm
Post
by Axolotl » Mon Apr 14, 2025 11:09 am
OMG. RTFM.
In the IDE move the Caret (Text-Cursor) over the word "ContainerGadget()" and press F1.
On the Help Page you will find this:
The following event is supported through EventType():
#PB_EventType_Resize: The gadget has been resized.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home . Now started with Linux (VM: Ubuntu 22.04 ).
Kiffi
Addict
Posts: 1502 Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9
Post
by Kiffi » Mon Apr 14, 2025 11:11 am
Code: Select all
EnableExplicit
Enumeration
#Window
#ContainerGadget
#Button1
#Button2
EndEnumeration
Procedure SizeWindowEvent()
Select EventWindow()
Case #Window
ResizeGadget(#ContainerGadget, #PB_Ignore, #PB_Ignore, WindowWidth(#Window) - 2*8, WindowHeight(#Window) - 2*8)
EndSelect
EndProcedure
Procedure ContainerGadgetEvent()
Select EventType()
Case #PB_EventType_Resize
Debug "#PB_EventType_Resize W:" + Str(GadgetWidth(#ContainerGadget)) + " H:" + Str(GadgetHeight(#ContainerGadget))
EndSelect
EndProcedure
If OpenWindow(#Window, 0, 0, 322, 150, "ContainerGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
ContainerGadget(#ContainerGadget, 8, 8, 306, 133, #PB_Container_Raised)
ButtonGadget(#Button1, 10, 15, 80, 24, "Button 1")
ButtonGadget(#Button2, 95, 15, 80, 24, "Button 2")
CloseGadgetList()
BindEvent(#PB_Event_SizeWindow, @SizeWindowEvent())
BindGadgetEvent(#ContainerGadget, @ContainerGadgetEvent())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Hygge
Piero
Addict
Posts: 923 Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy
Post
by Piero » Mon Apr 14, 2025 12:00 pm
NOTE TO FRED:
To make the windows 11 ARM (VM) 64 version behave like on monterey mac M1 (graphics and debug) I had to modify it:
Code: Select all
p=1
If OpenWindow(0, 0, 0, 322, 150, "ContainerGadget")
ContainerGadget(1, 8, 8, 306, 133, #PB_Container_Raised)
ButtonGadget(0, 10, 15, 80, 24, "Resize")
CloseGadgetList()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
ResizeGadget(1, 8, 8, 306, 99-p)
p+1
Case 1
Select EventType()
Case #PB_EventType_Resize
Debug "Resize Event"
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
rndrei
Enthusiast
Posts: 153 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 14, 2025 12:38 pm
Thank you, I will understand!