Problem with resizecallback procedure

Just starting out? Need help? Post your questions and find answers here.
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Problem with resizecallback procedure

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Post by Jurgen »

Thanks man.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post 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.
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Post by Jurgen »

Thanks for the tip Inner, didn't know that. :idea:
Post Reply