Set Gadget's Position?

Just starting out? Need help? Post your questions and find answers here.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Set Gadget's Position?

Post by Mythros »

Hi all! How do you position a gadget AFTER said gadget has been created & resized using `ResizeGadget ( )` ?

Any help is GREATLY appreciated!

Thanks alot! <3
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Set Gadget's Position?

Post by Bisonte »

:shock:

Is this "Hidden camera" ?

With ResizeGadget() of course...
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: Set Gadget's Position?

Post by Mythros »

I think you misunderstand. I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget in the middle of the screen constantly with the new size of the button being the width & height of the string the button uses.
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 114
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: Set Gadget's Position?

Post by Erlend »

Mythros wrote:I think you misunderstand. I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget in the middle of the screen constantly with the new size of the button being the width & height of the string the button uses.
I think you need to reformulate you're question as what you are asking, Bisonte allready answered...
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: Set Gadget's Position?

Post by Mythros »

Ok, so say I wanted to position the button gadget AFTER resizing it to the width / height of the string so i can put it always in the middle of the screen based on its' new width / height. how can i do that?
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 114
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: Set Gadget's Position?

Post by Erlend »

Mythros wrote:Ok, so say I wanted to position the button gadget AFTER resizing it to the width / height of the string so i can put it always in the middle of the screen based on its' new width / height. how can i do that?
Do you mean the actual screen or the window? (Still not sure of you intent with this :-) )

For Window?:

Code: Select all

OpenWindow(0,0,0,300,300,"",#PB_Window_SizeGadget)

ButtonGadget(0,0,0,100,100,"ThisAndThat")
ResizeGadget(0,(WindowWidth(0)/2)-(GadgetWidth(0)/2),(WindowHeight(0)/2)-(GadgetHeight(0)/2),#PB_Ignore,#PB_Ignore)

Repeat
  event=WaitWindowEvent()
  If event=#PB_Event_SizeWindow
      ResizeGadget(0,(WindowWidth(0)/2)-(GadgetWidth(0)/2),(WindowHeight(0)/2)-(GadgetHeight(0)/2),#PB_Ignore,#PB_Ignore)
  EndIf
Until event=#PB_Event_CloseWindow 
wombats
Enthusiast
Enthusiast
Posts: 716
Joined: Thu Dec 29, 2011 5:03 pm

Re: Set Gadget's Position?

Post by wombats »

You can use #PB_Ignore in place of X, Y, Width and Height if you don't want to modify it.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: Set Gadget's Position?

Post by BarryG »

Mythros wrote:I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget
The ResizeGadget() command can size and move the gadget at the same time. It's not just for resizing.
Post Reply