Page 1 of 1

resizing gadget when resizing window?

Posted: Sun May 04, 2003 8:02 pm
by muab256
hiho =))

how would i have to change this code to work properly?

Case #PB_event_resizewindow
ResizeGadget(4, 6, 10, WindowWidth()-12, WindowHeight()-20)

thx
muaB

Posted: Sun May 04, 2003 8:22 pm
by Henrik
Hi muab256

i would use the SetWindowCallback function for stuff like that but, but -"i'm no guro sooo"-
Anyway as i recall there is a functional example of that, in your Examples [dir]
The "WebBrowser.pb" uses SetWindowCallback(@SizeCallback()) and the
Procedure ResizeWebWindow()

Take look at that one.

and i recalled right, i'm old but not that old :?


Bedst Regards
Henrik

Posted: Sun May 04, 2003 9:55 pm
by Danilo
For completeness sake, a small example:

Code: Select all

Procedure WinCallback(Win,Msg,wParam,lParam)
  Select Msg
    Case #WM_SIZE
      ResizeGadget(1,5,5,WindowWidth()-10,WindowHeight()-10)
  EndSelect
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow(0,0,0,200,30,#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget,"Test")
  CreateGadgetList(WindowID())
  ButtonGadget(1,5,5,190,20,"Button")
  
SetWindowCallback(@WinCallback())

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow