ResizeGadget() with flag = PB_Gadget_ScreenCoordinate
Posted: Thu Jan 01, 2015 9:21 am
Code: Select all
#Window = 1
Procedure __ResizeGadget( Gadget, X,Y,Width,Height, Flags)
Protected WindowX, WindowY
If Flags = #PB_Gadget_ScreenCoordinate
WindowY = GadgetY(Gadget,#PB_Gadget_ScreenCoordinate)-GadgetY(Gadget,#PB_Gadget_WindowCoordinate)
WindowX = GadgetX(Gadget,#PB_Gadget_ScreenCoordinate)-GadgetX(Gadget,#PB_Gadget_WindowCoordinate)
If X ! #PB_Ignore
X = (X - WindowX)
EndIf
If Y ! #PB_Ignore
Y = (Y - WindowY)
EndIf
EndIf
ResizeGadget( Gadget,X,Y,Width,Height )
EndProcedure
Macro ResizeGadget( Gadget,X,Y,Width,Height, Flags = #PB_Gadget_ContainerCoordinate)
__ResizeGadget( Gadget,X,Y,Width,Height, Flags )
EndMacro
OpenWindow(#Window, 100, 50, 335, 395, "", #PB_Window_SystemMenu )
ButtonGadget(1, 5, 5, 160,70, "ButtonGadget_1")
StringGadget(2, 170, 80, 160,70, "StringGadget_2")
ResizeGadget(1, #PB_Ignore, GadgetY(2), #PB_Ignore, #PB_Ignore) ; Only move the gadget to a new position.
ButtonGadget(3, 5, 155, 160,70, "ButtonGadget_3")
StringGadget(4, 170, 230, 160,70, "StringGadget_4")
ResizeGadget(3, #PB_Ignore, GadgetY(4,#PB_Gadget_ScreenCoordinate), #PB_Ignore, #PB_Ignore)
;Uncoment for look
;ResizeGadget(3, #PB_Ignore, GadgetY(4,#PB_Gadget_ScreenCoordinate), #PB_Ignore, #PB_Ignore, #PB_Gadget_ScreenCoordinate)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow