Solved

Resizing a form

Posted on 2004-08-16
10
288 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

14 Experts available now in Live!

Get 1:1 Help Now