Recent

Author Topic: We need OnChangingBounds event..  (Read 275 times)

jamie

  • Hero Member
  • *****
  • Posts: 2174
We need OnChangingBounds event..
« on: November 22, 2019, 02:08:24 am »
Currently we have OnChangeBounds which gets triggered after the fact.

 if one decides it does not like what it has then one could change the size and thus this will of course trigger another event.

 Now I know the LCL is processing the WM_WINDOWPOSCHAINGING message and thus if we
could gain access to the WNDOWPOS record so that one could update the record on return to reset the values.

 This would then prevent unneeded flickering and slowness of the GUI in many cases when things get busy on the screen..

 I am sure the constraints use this message period to limit the size of the form because I see it handles it very well without flicker, so we need this event to be exposed to a common event so the coder can also adjust the sizes..

 I have some apps I have always used the WM_SIZING so that I can maintain an aspect ratio of the form without flickering junk on the screen. It works nicely, I can smoothly enlarge and shrink a form there by adjusting the opposite side to maintain the ratio without any junk that takes place because I also have a lot of busy graphics on the form that gets updated.

 So a OnChangingBounds with a parameter VAR WINDOWSREC, for example so we can alter it before the LCL does any drawing.
Number 1 at blue screen app creations!

440bx

  • Hero Member
  • *****
  • Posts: 1298
Re: We need OnChangingBounds event..
« Reply #1 on: November 22, 2019, 04:16:40 am »
I thought it was possible to declare a message method which is "tied" to any Windows message you want.  Wouldn't that do what you're asking for ?

(Note: this is what I think based on what I've read in the documentation.  I've never used that stuff and hopefully never will.)
using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

ASerge

  • Hero Member
  • *****
  • Posts: 1423
Re: We need OnChangingBounds event..
« Reply #2 on: November 22, 2019, 10:45:23 pm »
Now I know the LCL is processing the WM_WINDOWPOSCHAINGING message and thus if we
could gain access to the WNDOWPOS record so that one could update the record on return to reset the values.
I see no difficulty in that:
Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, LMessages;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.   private
  13.  
  14.   protected
  15.     procedure WndProc(var TheMessage: TLMessage); override;
  16.   end;
  17.  
  18. var
  19.   Form1: TForm1;
  20.  
  21. implementation
  22.  
  23. uses LCLType;
  24.  
  25. {$R *.lfm}
  26.  
  27. procedure TForm1.WndProc(var TheMessage: TLMessage);
  28. var
  29.   P: PWindowPos;
  30. begin
  31.   inherited;
  32.   if TheMessage.msg = LM_WINDOWPOSCHANGING then
  33.   begin
  34.     P := PWindowPos(TheMessage.lParam);
  35.     if P^.x > 200 then
  36.     begin // Ignore sizing
  37.       P^.flags := SWP_NOSIZE;
  38.       TheMessage.Result := 0;
  39.     end;
  40.   end;
  41. end;
  42.  
  43. end.

jamie

  • Hero Member
  • *****
  • Posts: 2174
Re: We need OnChangingBounds event..
« Reply #3 on: November 22, 2019, 10:53:50 pm »
That is what I do now, I even process the WM_SIZING and MOVING message. I can make very smooth updating forms.

 The issue is, I do this for just about for every app now that has busy screen objects.

 With Delphi I use to implement the message using the standard practice which does not work with the LCL forms so there was never an issue with this and I had full control over the GUI drawing.

 I just thought It would be a nice way to make this cross platform so we can detect early changes of metrics and make changes before they get applied to the GUI objects, which makes a message if they are not the values you want used.


 
 
Number 1 at blue screen app creations!

jamie

  • Hero Member
  • *****
  • Posts: 2174
Re: We need OnChangingBounds event..
« Reply #4 on: November 23, 2019, 01:58:52 am »
Now I know the LCL is processing the WM_WINDOWPOSCHAINGING message and thus if we
could gain access to the WNDOWPOS record so that one could update the record on return to reset the values.
I see no difficulty in that:
Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, LMessages;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.   private
  13.  
  14.   protected
  15.     procedure WndProc(var TheMessage: TLMessage); override;
  16.   end;
  17.  
  18. var
  19.   Form1: TForm1;
  20.  
  21. implementation
  22.  
  23. uses LCLType;
  24.  
  25. {$R *.lfm}
  26.  
  27. procedure TForm1.WndProc(var TheMessage: TLMessage);
  28. var
  29.   P: PWindowPos;
  30. begin
  31.   inherited;
  32.   if TheMessage.msg = LM_WINDOWPOSCHANGING then
  33.   begin
  34.     P := PWindowPos(TheMessage.lParam);
  35.     if P^.x > 200 then
  36.     begin // Ignore sizing
  37.       P^.flags := SWP_NOSIZE;
  38.       TheMessage.Result := 0;
  39.     end;
  40.   end;
  41. end;
  42.  
  43. end.

Btw,  you can't over write the flags like that because other flags maybe set too.

I vote for the inclusion of this message that supplies the complete record via  a reference. A lot can be done in this message before unwanted drawing and movement is taking place.
Number 1 at blue screen app creations!

Zoran

  • Hero Member
  • *****
  • Posts: 1469
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: We need OnChangingBounds event..
« Reply #5 on: November 23, 2019, 07:24:57 am »
I vote for the inclusion of this message that supplies the complete record via  a reference. A lot can be done in this message before unwanted drawing and movement is taking place.

Make a feature request in bugtracker.