Resize gadget negative forced to zero
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Resize gadget negative forced to zero
I noticed that in PureBasic LTS 5.21 a gadget size can't be negative. You now get an error.
This can cause major headaches with resizable gadgets as you now have to check for negative sizes and set them to zero, etc...
Would it not be better for the ResizeGadget command to check for a negative height/width and set the value to zero? (not draw the gadget).
This can cause major headaches with resizable gadgets as you now have to check for negative sizes and set them to zero, etc...
Would it not be better for the ResizeGadget command to check for a negative height/width and set the value to zero? (not draw the gadget).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: Resize gadget negative forced to zero
DoubleDutch wrote:I noticed that in PureBasic LTS 5.21 a gadget size can't be negative. You now get an error.


@PB-Team: Please go back to the old behaviour.
Thanks in advance & Greetings ... Kiffi
Hygge
Re: Resize gadget negative forced to zero
IHMO, you shouldn't have negative size in your code or something is wrong. There is no check at the command level, that's why a debugger check has been introduced to help catching errors. For example, I'm not sure than negative size will work on every OS. If it's only for the ResizeGadget() command, you can still write your own wrapper which check for that.
Re: Resize gadget negative forced to zero
> That's very bad!
Why? How can a gadget have negative dimensions?
Why? How can a gadget have negative dimensions?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Resize gadget negative forced to zero
because now i have to write my own wrapper (as Fred wrote).PB wrote:Why?
Simple example: Create a new form with the Visual Designer. Place a Button on the form. Lock the button top, left, right and bottom.
Now the Visual Designer has created the ResizeGadgets[YourForm]() - Procedure you can call on #PB_Event_SizeWindow. But if the Button has negative Dimensions, the code will now (with V5.21) throw an error.
I don't know, how to write a wrapper for it, because i may not change the VD generated code.
Greetings ... Kiffi
Hygge
Re: Resize gadget negative forced to zero
I followed your steps but still can't create a gadget with negative dimensions.
How are you creating a gadget with 0 (or less!) pixels in width or height?
How are you creating a gadget with 0 (or less!) pixels in width or height?

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Resize gadget negative forced to zero
the button gets negative dimensions by resizing the form (not in the VD but in your code).PB wrote:I followed your steps but still can't create a gadget with negative dimensions.
How are you creating a gadget with 0 (or less!) pixels in width or height?
Greetings ... Kiffi
Hygge
Re: Resize gadget negative forced to zero
Could you post some examples where it happens ?
Re: Resize gadget negative forced to zero
yes, of course.
VD-generated file (save as test.pbf):
my Code:
VD-generated file (save as test.pbf):
Code: Select all
Enumeration FormWindow
#Window_0
EndEnumeration
Enumeration FormGadget
#Button_0
EndEnumeration
Declare ResizeGadgetsWindow_0()
Procedure OpenWindow_0(x = 0, y = 0, width = 416, height = 360)
OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
ButtonGadget(#Button_0, 8, 8, 248, 248, "")
EndProcedure
Procedure ResizeGadgetsWindow_0()
Protected FormWindowWidth, FormWindowHeight
FormWindowWidth = WindowWidth(#Window_0)
FormWindowHeight = WindowHeight(#Window_0)
ResizeGadget(#Button_0, 8, 8, FormWindowWidth - 168, FormWindowHeight - 112)
EndProcedure
Code: Select all
XIncludeFile "test.pbf"
OpenWindow_0()
Repeat
Select WaitWindowEvent()
Case #PB_Event_SizeWindow
ResizeGadgetsWindow_0()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Hygge
Re: Resize gadget negative forced to zero
OK, I see now. The code from the VD should be fixed to avoid such cases.
Re: Resize gadget negative forced to zero
sounds good. Thanks in advance!Fred wrote:OK, I see now. The code from the VD should be fixed to avoid such cases.
Greetings ... Kiffi
Hygge