Window Resize Values?

Just starting out? Need help? Post your questions and find answers here.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Window Resize Values?

Post 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?
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Do WindowWidth() & WindowHeight() not work?
snap2000
User
User
Posts: 88
Joined: Fri Jun 04, 2004 12:11 am

Post 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()
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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..
Dr_Pixel
User
User
Posts: 36
Joined: Fri Oct 24, 2003 1:36 pm

Post 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.
Dr Pixel
Post Reply