Page 1 of 1

Window Resize Values?

Posted: Sun Aug 15, 2004 11:33 pm
by Shannara
Ok, Im going to assume this would require a callback, and I DO NOT want to limit the window resizing at all :)

Basically, I would like to know how do I get the new window width/height AFTER it has been resized by the user? I would like to know this for both normal windows and MDI children/parents.

Does anybody know how to go about doing this?

Posted: Sun Aug 15, 2004 11:53 pm
by GreenGiant
Do WindowWidth() & WindowHeight() not work?

Posted: Sun Aug 15, 2004 11:56 pm
by snap2000
If I am not mistaken, you could simply check the dimensions of the window in your loop, and if they're different, just record the new dimensions with WindowHeight() and WindowWidth()

Posted: Mon Aug 16, 2004 12:03 am
by Shannara
I never thought about doing it the loop way :) Thanks guys, but guess what? I figured out a different way. Took alot of debugging, and it flickers like a SOB, but here it is..

Code: Select all

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents

  If WindowID = WindowID(frmMDI)
    If Message = 133 ;after resize
      UseWindow(frmMDI)
      oWidth = WindowWidth()
      oheight = WindowHeight()
      UseImage(77)
      If oWidth >= ImageWidth()
        If oheight >= ImageHeight()
          ResizeImage(77,oWidth,oheight)
          SetWinBackgroundImage(GadgetID(myMDI),UseImage(77))  
        EndIf
      EndIf
    EndIf
  EndIf
  ProcedureReturn Result

EndProcedure 
The lovely callback..

Posted: Tue Aug 17, 2004 12:42 am
by Dr_Pixel
The flickering is caused because windows repeatedly sends the "resized" message the whole time the window is being resized.

What I do is use the callback to set a shared "flag" variable to show that a window was resized, and which window it was.

Then I check for this flag at the top of my main loop, and do any resizing of gadgets or whatnot at that point. Then set the flag back to 0

This eliminates the flickering, since events are only returned to the main loop once the resizing stops.

So I'm only doing the resizing stuff once.