?
Solved

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

Posted on 2012-04-02
2
Medium Priority
?
657 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Simple Linear Regression
Suggested Courses

719 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