Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-04-02
2
Medium Priority
?
663 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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 …
Screencast - Getting to Know the Pipeline

916 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