Solved

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

Posted on 2012-04-02
2
626 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now