Solved

restore inherited form's original bounds

Posted on 1998-12-01
9
210 Views
Last Modified: 2010-04-04
When I create a bunch of forms based on a base form held in the repository, they all start out being the same size as the base form - until I resize the instance form.  Then the instance form has it's own bounds viz. top, left, etc. properties.

How do I tell the form to revert to using the inherited base form size?  

Similarly with components on the base form - if I move them on the instance form they forever are independent of the base form component position.  How do I tell these components to revert to the base form component's position (this applies to all the other properties, beside top,left,width etc. )
0
Comment
Question by:abulka
  • 5
  • 4
9 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 70 total points
ID: 1348836
Right click on a component in the inherited form and you will see a revert to inherited optin - this will undo any changes made to the inherited component (and should work for the form itself too - though I am not sure if it changes all the components on the form as well.

Cheers,

Raymond.
0
 

Author Comment

by:abulka
ID: 1348837
You are right about 'revert to inherited' for components.  However,
The menu item is always dimmed out for forms.  How do I get the form to revert?  This is the main thing I want to get working.
-A

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1348838
OK - here we have to get crafty!

When viewing the form itself, press Alt-F12. This converts the form to text. Near the top you will see lines that say
left = x
top = y
width = z

etc.

To make the inherited form revert to the properties of the ancestor form delete the properties you want to be the same eg: deleting the top, left, width and height lines will make the inherited form take the size and position of the ancestor form.

once you have deleted these press alt-F12 again to convert the text back into a form.

Cheers,

Raymond.

0
 

Author Comment

by:abulka
ID: 1348839
Ok that sounds good.  I'll accept the answer.

If you give me some code to get the inherited form to revert to the ancestor form's size and position prior to displaying at runtime, this will give me a RUNTIME solution (as well as the design time solution that you gave me).

I've increased the points a little.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1348840
Hmm...

This may not be the best way to do this, but you could just implement it in a TForm derived class and derive all your ancestor forms from that (either that or do it in each form - but thats yucky):

TMyForm = class(TForm)
  private
    TheTop, TheLeft, TheHeight, TheWidth : Integer;
  protected //? could be public...
    procedure Loaded; override;
end;

procedure TMyForm.Loaded;

begin
  if csInherited in ComponentState then
    begin
      TheTop := Top;
      TheLeft := Left;
      TheHeight := Height;
      TheWidth := Width;
    end
  else
    SetBounds(TheLeft, TheTop, TheWidth, TheHeight);
end;

Cheers,

Raymond.

0
 

Author Comment

by:abulka
ID: 1348841
Looks good - just one last question.

Wouldn't I have to call
  inherited
in the TMyForm.Loaded;    of the ancestor/base form?
or is the loaded message just for notification and I don't have to pass it up?

e.g.

procedure TMyForm.Loaded;
     inherited; // parameters here???      
      begin
        if csInherited in ComponentState then
          begin
     etc...
     ...
       
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1348842
Yes. I forgot to include that.

Cheers,

Raymond.
0
 

Author Comment

by:abulka
ID: 1348843
Ok.  Does the inherited call need parameters?  e.g. sender or something?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1348844
No - it shoudln't. It should compile just fine as it is. If not change it to:

Inherited Loaded;

Cheers,

Raymond.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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