?
Solved

derived class creat not called

Posted on 1998-09-30
11
Medium Priority
?
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 10

Expert Comment

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

Regards,
Viktor Ivanov
0
 

Author Comment

by:tomcorcoran
ID: 1341339
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
ID: 1341340
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
Industry Leaders: 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!

 

Author Comment

by:tomcorcoran
ID: 1341341
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
ID: 1341342
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
 

Author Comment

by:tomcorcoran
ID: 1341343
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
ID: 1341344
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
ID: 1341345
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
ID: 1341346
as Tom said he has fixed the problem.....

//Viktor Ivanov
0
 

Author Comment

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

Accepted Solution

by:
viktornet earned 160 total points
ID: 1341348
Thanks

//Vik
0

Featured Post

Independent Software Vendors: 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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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