Solved

Resizing a form

Posted on 2004-08-16
10
293 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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