Solved

derived class creat not called

Posted on 1998-09-30
11
146 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 40 total points
ID: 1341348
Thanks

//Vik
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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