Solved

derived class creat not called

Posted on 1998-09-30
11
143 Views
Last Modified: 2010-04-06
I have a form class that is derived from a form template. When I create the derived class the OnCreate for the derived class is not called and the form template appears. Does anyone have an idea what am may be doing wrong?

Thanks, Tom.
0
Comment
Question by:tomcorcoran
  • 6
  • 4
11 Comments
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Some code will help??? What is your code in the OnCreate() of the form.....

Regards,
Viktor Ivanov
0
 

Author Comment

by:tomcorcoran
Comment Utility
Viktor,

Here's some code snippets:

   with TfrmSchedGridConfig.Create(Self) do
      try
         if not (ShowModal = mrCancel) then begin
            ...
         end;
      finally
         Free;
      end;

  TfrmSchedGridConfig = class(TfrmRepDDLst)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure btnOkClick(Sender: TObject);
  private
    { Private declarations }
   ...
  public
    { Public declarations }
  end;
.

procedure TfrmSchedGridConfig.FormCreate(Sender: TObject);
begin
   inherited; // never goes in here
   ...
end;

Thanks, Tom.


0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Why dont youtry without inherited because you never override the OnCreate() of that form...Try wihout having the inherited method and enter some other code for example to show you a message so you can see that it's working...

//Viktor
0
 

Author Comment

by:tomcorcoran
Comment Utility
Well like I said it never goes in there (regardless of whether inheritd is commented out or not). Tom.
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Why don't you send the whole coed on th E-E

Oh, and tell me where does this code come from???

with TfrmSchedGridConfig.Create(Self) do
           try
              if not (ShowModal = mrCancel) then begin
                 ...
              end;
           finally
              Free;
           end;

vik
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:tomcorcoran
Comment Utility
Vik,

Thanks for your help. I just found what it was, the form create had somehow got disconnected in the object inspector...

Tom.
0
 
LVL 3

Expert Comment

by:KE
Comment Utility
Add this to your public declaration of TfrmSchedGridConfig

public
  Constructor Create( AOwner: TObject ); override;

In your implementation part write the Constructor as follows

Constructor TfrmSchedGridConfig( AOwner: TObject );
begin
  Inherited Create( AOwner );
  FormCreate( self );
end;

0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
I just created a unit to try this out......and here is the code for the whole unit and it works perfectly..........
-------------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
      ShowMessage('Hello');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
      with TForm1.Create(self) do
    try
          Randomize;
        Left := Random(Screen.Width);
        Top := Random(Screen.Height);
        Caption := 'Hello World';
          ShowModal;
    finally
          Free;
    end;
end;

end.
--------------
Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
as Tom said he has fixed the problem.....

//Viktor Ivanov
0
 

Author Comment

by:tomcorcoran
Comment Utility
Vic, thanks for all the work, answer so I can grade, Tom.
0
 
LVL 10

Accepted Solution

by:
viktornet earned 40 total points
Comment Utility
Thanks

//Vik
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

18 Experts available now in Live!

Get 1:1 Help Now