Page 1 of 1

Problem with resizecallback procedure

Posted: Sun Oct 26, 2003 9:39 pm
by Jurgen
I have a main window with a resize callback procedure.
Resizing works fine.
When I open a second window, close it again, the resize callback doesn't work anymore.
What could be wrong ?

Code: Select all

Procedure ResizeCallback(Window, Message, wParam, lParam) 
  result = #PB_ProcessPureBasicEvents 
   
  If Message = #WM_SIZE 
    Select Window 
      Case WindowID(#MainWindow) 
        ResizeGadget(#Splitter, -1, -1, WindowWidth()-10, WindowHeight()-80) 
        UpdateStatusBar(#StatusBar_0)
        SendMessage_(hToolbar, #TB_AUTOSIZE, 0, 0) 
    EndSelect 
  EndIf 
  ProcedureReturn result 
EndProcedure

Posted: Sun Oct 26, 2003 9:46 pm
by freak
WindowWidth() and WindowHeight() always use the current window, which
is changed when you open the second one.

A simple 'UseWindow(#MainWindow)' before the resizing should do the job.

Timo

Posted: Sun Oct 26, 2003 9:53 pm
by Jurgen
Thanks man.

Posted: Mon Oct 27, 2003 12:21 am
by Inner
You don't actually need a callback procedure for this;

Code: Select all

Repeat
   eid=WaitWindowEvent()
   Select eid
       case #WM_SIZE
          ResizeGadget(#Splitter, -1, -1, WindowWidth()-10, WindowHeight()-80) 
          UpdateStatusBar(#StatusBar_0) 
          SendMessage_(hToolbar, #TB_AUTOSIZE, 0, 0) 
    EndSelect
Until Quit=#TRUE
Should work just as well.

Posted: Mon Oct 27, 2003 12:32 am
by Jurgen
Thanks for the tip Inner, didn't know that. :idea: