Solved

Resizing a form

Posted on 2004-08-16
10
294 Views
Last Modified: 2010-04-05
I want to execute the code that is executed if my form is resized without resizing it. Hence a better title would be "Resizing a form without changing width and height". Maybe I can send a message?

TIA
0
Comment
Question by:__alex
10 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 11807538
Which sizes do you  mean the? if not width and height?
Anyways the form event you are looking might be onResize or onCanResize.
If I understood your problem corectly.

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11807564
write you code in OnResize event of the form, but remove the line with inherited;
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11807608
procedure TForm1.FormResize(Sender: TObject);
begin
  with Self.Constraints do
    begin
      MinHeight := Height;
      MaxHeight := Height;
      MinWidth  := Width;
      MaxWidth  := Width;
    end;
  // you code below
  Label1.Caption := 'Hello World!';
end;
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:__alex
ID: 11807621
I meant the code deep inside the VCL. I don't want to add any events.

> write you code in OnResize event of the form, but remove the line with inherited;
???
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11807633
sorry, it was a mistake. I was thinking of something else...
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 11807719
why not using something like

procedure TForm1.FormResize(Sender: TObject);
begin
   ShowMessage('BOO');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   FormResize(Sender);
end;

that will call the code in FormREsize, alternitvly you could create a your own procedure with the code from the resize procedire and then call that:

procedure TForm1.FormResize(Sender: TObject);
begin
   myprocedure;
end;

procedure TForm1.myprocedure;
Begin
   ShowMessage('BOO');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   myprocedure;
end;

which would avoid having to bother sending a 'Sender' varible to it

David
0
 
LVL 2

Author Comment

by:__alex
ID: 11807819
DavidBirch2dotCom ,
since I don't add any events to my form the OnFormResize property is Nil.

I don't have the source of the code I want to execute. It's not in my form but somewhere in TForm, TWinControl or whatever. Sorry for these ambiguities...
0
 
LVL 2

Accepted Solution

by:
DarkCore_ earned 200 total points
ID: 11808488
try to send the message WM_SIZE using

   MyForm.Perform( WM_SIZE, 0, 0 )
 
or
 
   SendMessage( MyForm.Handle, WM_SIZE, 0, 0 )

Edy
0
 
LVL 3

Expert Comment

by:lmikle
ID: 11808492
Try to send a WM_SIZE message to the form.

procedure TForm1.Button1Click(Sender : TObject);
begin
  Self.Perform(WM_SIZE,SIZE_RESTORED,(WORD(Self.Height) Shl 16) Or WORD(Self.Width));
end;
0
 
LVL 2

Author Comment

by:__alex
ID: 11809017
Got it... Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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