Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

773 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