Jump to content
Mark Gorst

FMX Resize / StartWindowResize

Recommended Posts

I'm trying to replicate some behavior I have in VCL Form. I have video updating in a TForm and when I resize that form I want to stop the video updating until the resize is complete. The Resize() is working fine, but I want to use FMX.Forms.TCommonCustomForm.StartWindowResize(). I have created an override function, but resizing the window does not seem to call my code. Everything else seems to work. If I make StartWindowResize() protected rather than public the compiler warns me about this having lower visibility - so that means that it is overriding the virtual stub.

 

csDesigning is not in the component state,

 

Does anyone have any suggestions, There seems to be almost no mention of using StartWindowResize() anywhere....

 

Mark

 

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure FormResize(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  public
    procedure StartWindowResize;override;
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.StartWindowResize;
begin
timer1.Enabled:=false;
ShowMessage('StartWindowResize');
inherited;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
label1.text:=FormatDateTime('hh:nn:ss.zzz',now);
end;
 

Share this post


Link to post

RAD HELP to StartWindowResize: Signals that this form's window is about to be resized. StartWindowResize exits if this form has a csDesigning component state

Share this post


Link to post

Thanks. I have read the help, and you'll note that I said "csDesigning is not in the component state," in mypost.

 

That is to say I did a break in TForm1.FormResize() when runing and the WatchList shows that "componentState = []" 

 

I'm assuming that is what the documentation is referring to ?

Share this post


Link to post

look at "procedure TCommonCustomForm.MouseDown(Button: TMouseButton; Shift: TShiftState; AFormX, AFormY: Single);", FMX.Forms.pas, line 3861 (RAD 11.2)

this procedure is called by "OnMouseDown"... not automatically!

I think that it dont be used for this propose (if resize... stop my task)

Edited by programmerdelphi2k

Share this post


Link to post

I can see this is one way it is called.

 

However a MouseDown() event is not the only way to resize a TForm. For instance maximising a window causes a Resize event to occur, but it is not a mouse down event, nor is dragging the border, this does not cause a MouseDown event.

 

I need to be able to avoid updating my TForm whilst it is being resized by the user. The call in MouseDown() is only triggered if you put the mouse down over an object [ ObjectAtPoint() <> nil]

 

Similarly  with StartWindowDrag whereby you can override to have your own code once you have started to drag the window, and that is not called at all in FMX.Forms directly, but I also have tried my own override on that and it does not get called when there is a drag event.

 

What I am trying to get at is the equivalent of a  WMEnterSizeMove message in VCL

 

So either the system is not calling StartWindowResize() for some reason, or my override is incorrect, I'm not expecting to call this manually, if so what's the point in having the virtual stub for TComonCustomForm ?

Share this post


Link to post

Look, "StartWindowsResize" is called JUST 1x in all framework FMX, and this called is done in "procedure TCommonCustomForm.MouseDown"!!!

try "Find in files" by "StartWindowResize" in your RAD sources and see for youself!

 

image.thumb.png.87f4a531e7a6ad65804df73ad1444271.png

 

other hand, "resize" procedure is called by "any try of resize your forms", be using mouse or by code!

until when creating a form your "resize event/procedure" can be called!!!

 

another thing, forget the direct relationship between VCL and FMX!!! two frameworks works distinctly in almost all, sometimes until in RTL functions!

 

my tip: use a "flag" to prevent any situation like "start/stop" a task for example!

  1. Form.RESIZE: Occurs immediately after the form is resized LFlagExecuteVideo = true;
  2. Form.Paint: Occurs when the form is redrawn.  = LFlagExecuteVideo = false;

Share this post


Link to post

Ok. I'll address this as best I can - and I'm only interested in FMX in the Windows environment.

 

On the basis of what you tell me the StartWindowResize is of little use, because if you resize your window using the mouse to drag the border or use the minimise/maximise icon - then this will never be called, even worse on the same basis StartWindowDrag will never be called because it's not called in FMX.Forms at all. So as functions they are off little use. 

 

I understand that FMX and VCL are not the same framework and will do different things. I simply mention the VCL messaging as that's the functionality I was hoping to reproduce. 

 

Thank you for your tip about a flag to start/stop a task, however it's not quite that simple with the devices I'm using.

 

I have got a different way of programming around the issue, It's just I thought that these two functions might do what the documentation implies, rather than StartWindowResize() only be called in a subset of resize circumstances and StartWindowDrag() never being used at all.

 

Share this post


Link to post

As a follow up to this "StartWindowResize" is only called when you MouseDown on a control that supports an ISizeGrip interface. It doesn't get called (on a Windows platform) when you drag the form edge, use the size icon, or change the width or height values.

 

I have yet found out how to do the equivalent of the Windows WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE messages.

 

 

Share this post


Link to post

I eventually found a way to deal with this. I stopped trying to capture the resize of the form and instead moved to the TPanel on which all the components are placed. The TPanel is client aligned to the TForm and so when the form is resized, the TPanel is always resized and I can capture the OnResize and OnResized events. If you drag the edge of the form then it will trigger a lot of pairs of these events. As I want to resize and restart my video which has a modest overhead, I use the OnResize to reset and start a TTimer so if resizing has has stopped for around 400ms then I resize and restart my video stream. Works on Windows, I'm not working with this on other platforms as the video is only supported on a single platform.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×