Solved

How do I trap the end of the resize event of a tPanel?

Posted on 2012-04-02
2
623 Views
Last Modified: 2012-04-02
I have a tPanel that has a tImage control on it with a bitmap in it.  The user can resize this panel.  I need to be able to trap when they are done resizing it.

I know that I can't use the onResize event, because it happens too often (triggered every time the user makes a micromovement while resizing the picture).  I saw an answer to a similar question (but for a form, not a panel) that involved trapping the resize of the whole form.  It said to use the WM_EXITSIZEMOVE.  The code for that was almost perfect for me, but my form already is trapping (and using) that message for the form, and I need to know when the panel is being resized, not the form.  

How do I trap the message for the end the resize of just the panel?

The code from the other person's answer is below:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    procedure WMEXITSIZEMOVE(var Message: TMessage);
       message WM_EXITSIZEMOVE;
    { Public declarations }
  end;
var
  Form1: TForm1;

implementation

{$R *.DFM}
procedure TForm1.WMEXITSIZEMOVE(var Message: TMessage);
begin
  Form1.Caption := 'Finished Moving and sizing';
end;
0
Comment
Question by:tawoodard
2 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 37796242
How are you enabling the TPanel resizing?
If you are overriding the Tpanel you can add the procedure to the TPanel itself, or if you are using a descendent just add the code to it.
Tahe a look at this example
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Forms, Dialogs, Variants, Classes, Controls, ExtCtrls;

type
  TPanel = class(ExtCtrls.TPanel)
  private
    procedure WMEXITSIZEMOVE(var Message: TMessage); message WM_EXITSIZEMOVE;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

  TForm1 = class(TForm)
    Panel1: TPanel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TPanel.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or WS_SIZEBOX;
end;

procedure TPanel.WMEXITSIZEMOVE(var Message: TMessage);
begin
  ShowMessage('Move / resize complete!');
end;

end.

Open in new window

0
 

Author Comment

by:tawoodard
ID: 37796581
Thank you for your help.

I tried adding the code you gave, but had problems because my program had overwritten the panel's create event, so this conflicted with it.

The code I am working on is actually a large project programmed by someone else, so I didn't know how the sizer thing was working.  By trying to overwrite that panel create event, I found the unit that is doing the sizing of the panels, and also found nice little procedures that I could use.  There was a DeActivateSizer procedure, which gave me access to just what I needed.

Thank you!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now