Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

restore inherited form's original bounds

Posted on 1998-12-01
9
Medium Priority
?
236 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 280 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

886 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