Solved

restore inherited form's original bounds

Posted on 1998-12-01
9
217 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 135
Delphi application Soap connection 5 104
Delphi and Access based Enumeration 9 64
Installshield for Embarcadero EX 10.1 Berlin 4 41
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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