Detecting resize events

You need some new stunning features ? Tell us here.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Detecting resize events

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
User avatar
Bisonte
Addict
Addict
Posts: 1232
Joined: Tue Oct 09, 2007 2:15 am

Re: Detecting resize events

Post 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)
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: Detecting resize events

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Justin
Addict
Addict
Posts: 832
Joined: Sat Apr 26, 2003 2:49 pm

Re: Detecting resize events

Post by Justin »

User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: Detecting resize events

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Detecting resize events

Post 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!!
Post Reply