Restored from previous forum. Originally posted by PB.
> Any chance you could share your code? What I find happens is that
> as the user resizes the window, the window changes size. However,
> the gadgets inside the window do not, so you either get a large
> space between gadgets and window border (if making the window
> bigger) or the edges of gadgets get cut off (if making the window
> smaller).
This is all I'm doing to resize windows perfectly with no problems.
As mentioned, I don't use callbacks, but I may do so in the future.
Code: Select all
Form1_W=312 ; Form's client width.
Form1_H=213 ; Form's client height.
Form1_X=(GetSystemMetrics_(#SM_CXSCREEN)-Form1_W)/2 ; Centered horizontally.
Form1_Y=(GetSystemMetrics_(#SM_CYSCREEN)-Form1_H)/2 ; Centered vertically.
;
#Form1_Flags=#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_SystemMenu
Form1_hWnd=OpenWindow(0,Form1_X,Form1_Y,Form1_W,Form1_H,#Form1_Flags,"Form1")
If Form1_hWnd=0 Or CreateGadgetList(Form1_hWnd)=0 : End : EndIf
;
Form1_OrigW=WindowWidth() ; Original non-client width.
Form1_OrigH=WindowHeight() ; Original non-client height.
;
#Form1_Command1=1 : Form1_Command1_hWnd=ButtonGadget(#Form1_Command1,8,8,81,33,"Command1")
#Form1_Command2=2 : Form1_Command2_hWnd=ButtonGadget(#Form1_Command2,224,8,81,33,"Command2")
#Form1_Command3=3 : Form1_Command3_hWnd=ButtonGadget(#Form1_Command3,120,88,81,33,"Command3")
#Form1_Command4=4 : Form1_Command4_hWnd=ButtonGadget(#Form1_Command4,8,176,81,33,"Command4")
#Form1_Command5=5 : Form1_Command5_hWnd=ButtonGadget(#Form1_Command5,224,176,81,33,"Command5")
;
Repeat
Form1_EventID=WaitWindowEvent()
Select Form1_EventID
Case #WM_SIZE ; Form's size has changed.
Form1_RatioW.f=WindowWidth()/Form1_OrigW ; Get horizontal difference.
Form1_RatioH.f=WindowHeight()/Form1_OrigH ; Get vertical difference.
ShowWindow_(Form1_hWnd,#SW_HIDE) ; To prevent graphics corruption.
ResizeGadget(#Form1_Command1,8*Form1_RatioW,8*Form1_RatioH,81*Form1_RatioW,33*Form1_RatioH)
ResizeGadget(#Form1_Command2,224*Form1_RatioW,8*Form1_RatioH,81*Form1_RatioW,33*Form1_RatioH)
ResizeGadget(#Form1_Command3,120*Form1_RatioW,88*Form1_RatioH,81*Form1_RatioW,33*Form1_RatioH)
ResizeGadget(#Form1_Command4,8*Form1_RatioW,176*Form1_RatioH,81*Form1_RatioW,33*Form1_RatioH)
ResizeGadget(#Form1_Command5,224*Form1_RatioW,176*Form1_RatioH,81*Form1_RatioW,33*Form1_RatioH)
ShowWindow_(Form1_hWnd,#SW_SHOW)
EndSelect
Until Form1_EventID=#PB_EventCloseWindow
;
End
PB - Registered PureBasic Coder