Page 1 of 1

Detecting resize events

Posted: Tue Aug 27, 2013 11:10 pm
by tinman
Hi,

What is the best way to handle resize events? I have a CanvasGadget that displays a map that is locked to all sides of the window. If the window is resized then I want to redraw the map to fill the CanvasGadget. Currently I have to have extra code in my event loop to handle this resize in addition to the ResizeGadgetsWindow_0 procedure that is generated, and it does not really fit with the way of defining event procedures.

For example, I have this:

Code: Select all

  Repeat
    ev = WaitWindowEvent()
    
    Select EventWindow()
      Case MainWindow
        If MainWindow_Events(ev) = #False
          quit = #True
        ElseIf ev = #PB_Event_SizeWindow
          DrawMap(@map_area)
        EndIf
        
    EndSelect
    
  Until quit
Since there does not seem to be a way to catch it from an event procedure, which would be more consistent.

Thanks.

Re: Detecting resize events

Posted: Wed Aug 28, 2013 5:45 am
by Bisonte
maybe you looking for this ?

Code: Select all

Procedure myResizeEvent()
  
  DrawMap(@map_area)
  ; do whatever todo at window resize
  
EndProcedure

BindEvent(#PB_Event_SizeWindow, @myResizeEvent(), MainWindow)

Re: Detecting resize events

Posted: Wed Aug 28, 2013 1:24 pm
by tinman
Hi Bisonte,
Bisonte wrote:maybe you looking for this ?
Thank you. Yes, I had missed that as a new feature in 5.20. However, the problem with using BindEvent is that it gets called before the FormDesigner resize procedure so I would not know what the new size was as the CanvasGadget would not have been resized by the time the callback is active.

Re: Detecting resize events

Posted: Wed Aug 28, 2013 7:33 pm
by Justin

Re: Detecting resize events

Posted: Wed Aug 28, 2013 8:43 pm
by tinman
Hi Justin,
Justin wrote:I sugested this
Thanks I've chipped in to add to your request. Hopefully it might be added, but I'll just have to live with the code I have for now.

Cheers.

Re: Detecting resize events

Posted: Sat Aug 31, 2013 12:20 pm
by Polo
Justin wrote:I sugested this:
http://www.purebasic.fr/english/viewto ... 2&t=54222
got ignored.
I didn't ignore you. I just don't have that much free time!!