Hi all,
I have a slight problem when attempting to create a class. I'm creating it, based on TPanel, and it is supposed to include a button showing the text hello world.
There were a couple of problems however: The first, being the less major one. Delphi didn't create a dfm file for this new unit of mine, and I knew no way of making one, so I ended up copying the one for my main form, renaming it, and editing with notepad. Anyone got a clue on how this could be avoided?
Then, secondly, I tried to use this class of mine, so I tried the following code on my main form:
The program crashes however, resulting in the following error: Project luokka2 raised an exception class EAccesViolation with message 'Access violation at address 00455ED9 in module 'luokka2.exe'. Read of address 00000000'. Process stopped. Use step or Run to continue.
I have a slight problem when attempting to create a class. I'm creating it, based on TPanel, and it is supposed to include a button showing the text hello world.
Code:
unit spanel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TSpanel = class(TPanel)
Buttoni: TButton;
procedure ButtoniClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Spanel1: TSpanel;
implementation
{$R *.dfm}
procedure TSpanel.ButtoniClick(Sender: TObject);
begin
Showmessage('HelloWorld');
end;
end.
There were a couple of problems however: The first, being the less major one. Delphi didn't create a dfm file for this new unit of mine, and I knew no way of making one, so I ended up copying the one for my main form, renaming it, and editing with notepad. Anyone got a clue on how this could be avoided?
Then, secondly, I tried to use this class of mine, so I tried the following code on my main form:
Code:
procedure TForm1.FormCreate(Sender: TObject);
var
s: TSpanel;
begin
s := TSpanel.Create(Self);
With Form1 do
begin
s.parent := form1;
s.SetBounds(1,1,500,500);
s.Buttoni.SetBounds(10,10,10,10) ;
The program crashes however, resulting in the following error: Project luokka2 raised an exception class EAccesViolation with message 'Access violation at address 00455ED9 in module 'luokka2.exe'. Read of address 00000000'. Process stopped. Use step or Run to continue.