[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

derived class creat not called

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
boardtc
Asked:
boardtc
  • 6
  • 4
1 Solution
 
viktornetCommented:
Some code will help??? What is your code in the OnCreate() of the form.....

Regards,
Viktor Ivanov
0
 
boardtcAuthor Commented:
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
 
viktornetCommented:
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
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.

 
boardtcAuthor Commented:
Well like I said it never goes in there (regardless of whether inheritd is commented out or not). Tom.
0
 
viktornetCommented:
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
 
boardtcAuthor Commented:
Vik,

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

Tom.
0
 
KECommented:
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
 
viktornetCommented:
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
 
viktornetCommented:
as Tom said he has fixed the problem.....

//Viktor Ivanov
0
 
boardtcAuthor Commented:
Vic, thanks for all the work, answer so I can grade, Tom.
0
 
viktornetCommented:
Thanks

//Vik
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now