ContainerGadget Attributes
ContainerGadget Attributes
It would be nice, like the ScrollAreaGadget(), if the inner height and width could be get with these constants:
#PB_Container_InnerWidth
#PB_Container_InnerHeight
#PB_Container_InnerWidth
#PB_Container_InnerHeight
Tranquil
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
If I run this code I get exactly the width / height I specified. Regardless of the border style.Tranquil wrote:This seems not to return the real inner width and height. I get in conflicts with a drawn border.
Code: Select all
OpenWindow(0,0,0,320,240,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
ContainerGadget(0,5,5,100,100) : CloseGadgetList()
ContainerGadget(1,110,5,100,100,1) : CloseGadgetList()
ContainerGadget(2,5,110,100,100,2) : CloseGadgetList()
ContainerGadget(3,110,110,100,100,4) : CloseGadgetList()
For i=0 To 3
Debug "Dimensions = " + Str(GadgetWidth(i)) + "," + Str(GadgetHeight(i))
Next
SetGadgetColor(0,#PB_Gadget_BackColor,#Red)
While WaitWindowEvent() ! 16 : Wend
All the same, so where's the problem?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
@Fluid Byte:
Your results are the gadgets including the border... tranquil need the innerwidth of the gadgets..
@Tranquil:
I wrote two small procedures that should solve your problem... I hope this is what you are looking for...
Your results are the gadgets including the border... tranquil need the innerwidth of the gadgets..
@Tranquil:
I wrote two small procedures that should solve your problem... I hope this is what you are looking for...
Code: Select all
OpenWindow(0,0,0,320,240,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
ContainerGadget(0,5,5,100,100) : CloseGadgetList()
ContainerGadget(1,110,5,100,100,1) : CloseGadgetList()
ContainerGadget(2,5,110,100,100,2) : CloseGadgetList()
ContainerGadget(3,110,110,100,100,4) : CloseGadgetList()
Procedure GetGadgetInnerWidth(lGadget.l)
lGadgetID.l = GadgetID(lGadget.l)
If GetClientRect_(lGadgetID, @winRc.RECT)
ProcedureReturn (winRc\right - winRc\left) - GetSystemMetrics_(#SM_CXBORDER ) +1
EndIf
EndProcedure
Procedure GetGadgetInnerHeight(lGadget.l)
lGadgetID.l = GadgetID(lGadget.l)
If GetClientRect_(lGadgetID, @winRc.RECT)
ProcedureReturn (winRc\bottom - winRc\top) - GetSystemMetrics_(#SM_CYBORDER ) +1
EndIf
EndProcedure
For i=0 To 3
Debug "Dimensions = " + Str(GetGadgetInnerWidth(i)) + "," + Str(GetGadgetInnerHeight(i))
Next
SetGadgetColor(0,#PB_Gadget_BackColor,#Red)
While WaitWindowEvent() ! 16 : Wend
va!n aka Thorsten
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Perfectly normal, that's the way it should be. And if you need the size without the border what's so hard about subtracting 2, respectivley 4 pixels?@Fluid Byte:
Your results are the gadgets including the border... tranquil need the innerwidth of the gadgets..
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
just subtracting 2 or 4 pixel could return wrong results if you are using any special skins i.e... so why not using system commands to get always the correct results instead being to lazy and working with fixing values? I think the API is great, as long as people using this instead trying dirty tricks with fixed values. just my opinion
However, if you want use your methode... you have to check the type of the gadget... is is borderless, flat, double... ^^
However, if you want use your methode... you have to check the type of the gadget... is is borderless, flat, double... ^^
va!n aka Thorsten
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
This is exactly what I needed. Thanks va!n!va!n wrote:@Fluid Byte:
Your results are the gadgets including the border... tranquil need the innerwidth of the gadgets..
@Tranquil:
I wrote two small procedures that should solve your problem... I hope this is what you are looking for...
Code: Select all
OpenWindow(0,0,0,320,240,"untitled",#WS_OVERLAPPEDWINDOW | 1) CreateGadgetList(WindowID(0)) ContainerGadget(0,5,5,100,100) : CloseGadgetList() ContainerGadget(1,110,5,100,100,1) : CloseGadgetList() ContainerGadget(2,5,110,100,100,2) : CloseGadgetList() ContainerGadget(3,110,110,100,100,4) : CloseGadgetList() Procedure GetGadgetInnerWidth(lGadget.l) lGadgetID.l = GadgetID(lGadget.l) If GetClientRect_(lGadgetID, @winRc.RECT) ProcedureReturn (winRc\right - winRc\left) - GetSystemMetrics_(#SM_CXBORDER ) +1 EndIf EndProcedure Procedure GetGadgetInnerHeight(lGadget.l) lGadgetID.l = GadgetID(lGadget.l) If GetClientRect_(lGadgetID, @winRc.RECT) ProcedureReturn (winRc\bottom - winRc\top) - GetSystemMetrics_(#SM_CYBORDER ) +1 EndIf EndProcedure For i=0 To 3 Debug "Dimensions = " + Str(GetGadgetInnerWidth(i)) + "," + Str(GetGadgetInnerHeight(i)) Next SetGadgetColor(0,#PB_Gadget_BackColor,#Red) While WaitWindowEvent() ! 16 : Wend
Tranquil
Re: ContainerGadget Attributes
Seven years and this is not implemented yet?
So it is imposible to position a gadget in a container with borders to match the width or height of the container? Crossplatform.
As in this example:
All the container border flags are useless if we can't retrieve the inner width/height.
So it is imposible to position a gadget in a container with borders to match the width or height of the container? Crossplatform.
As in this example:
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)
Debug GadgetWidth(0)
ButtonGadget(1, 0, 0, GadgetWidth(0), 24, "Button 1")
CloseGadgetList()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf