GadgetFit(gadget) command
Posted: Mon Sep 29, 2025 3:22 pm
Heya, @Fred,
Could this be implemented into PB?
I based the code on the forum from 2018 or so.
I have an include file for all my apps to share functions.
This procedure makes the gadgets fit into the contents, for example: text gadgets which have too much or too little pixels for the text.
Here is the code:
This useful command would benefit all users.
Thanks!
Could this be implemented into PB?
I based the code on the forum from 2018 or so.
I have an include file for all my apps to share functions.
This procedure makes the gadgets fit into the contents, for example: text gadgets which have too much or too little pixels for the text.
Here is the code:
Code: Select all
; Changes the width and height of a gadget automatically to fits its text
;
; V1.0 - 25/JUL/2018
; 27/JUL/2018
; V1.1 - 24/OCT/2019
; o Changed variable names to unique
;
Procedure GadgetFit(MARCOAGPINTO_gadget)
MARCOAGPINTO_x=GadgetX(MARCOAGPINTO_gadget)
MARCOAGPINTO_y=GadgetY(MARCOAGPINTO_gadget)
MARCOAGPINTO_w=GadgetWidth(MARCOAGPINTO_gadget)
MARCOAGPINTO_h=GadgetHeight(MARCOAGPINTO_gadget)
MARCOAGPINTO_w_new=GadgetWidth(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
MARCOAGPINTO_h_new=GadgetHeight(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
If MARCOAGPINTO_w<>MARCOAGPINTO_w_new Or MARCOAGPINTO_h<>MARCOAGPINTO_h_new
ResizeGadget(MARCOAGPINTO_gadget,MARCOAGPINTO_x,MARCOAGPINTO_y,MARCOAGPINTO_w_new,MARCOAGPINTO_h_new)
EndIf
EndProcedure
Thanks!