Solved

Resizing a form

Posted on 2004-08-16
10
291 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

22 Experts available now in Live!

Get 1:1 Help Now