Hello, 

I have been trying to create a simple new component just for the
sake of experience and I MUST be real stupid as I get the following
backtrace when I try to insert the new component (which has been
compiled ok) to the form. The component comes from Delphi and
works just fine there.

It seems to me as if the TWincontrol needed a parent but as it
cannot find one simply raises an exception. Before getting into the
real thing I created the simplest component I can image, it extends
class TCustomPanel and onPaint it should draw a very short line
and is totally useless. The Canvas operation Moveto() seems to
start the chain.

Any help would be appreciated. I do not mind being called an 
idiot, either :)

When I get the first real component done I will document the 
process and publish it as a starter's tutorial.

----- gdb backtrace (running lazarus, dropping component) -----------
Program received signal SIGFPE, Arithmetic exception.
$0040dc98 in RAISEGDBEXCEPTION (MSG=$1f95e4c) at LCLProc.pas:594
(gdb) bt
#0  $0040dc98 in RAISEGDBEXCEPTION (MSG=$1f95e4c) at LCLProc.pas:594
#1  $00480f45 in TWINCONTROL__CREATEWND (this=$2216928) at
wincontrol.inc:4781
#2  $00480c53 in TWINCONTROL__CREATEHANDLE (this=$2216928)
    at wincontrol.inc:4723
#3  $004818ac in TWINCONTROL__HANDLENEEDED (this=$2216928)
    at wincontrol.inc:5031
#4  $0047ff73 in TWINCONTROL__GETHANDLE (this=$2216928) at
wincontrol.inc:4073
#5  $00482aa5 in TWINCONTROL__GETDEVICECONTEXT (WINDOWHANDLE=0,
this=$2216928)
    at wincontrol.inc:5502
#6  $004788f0 in TCONTROLCANVAS__CREATEHANDLE (this=$2199934)
    at controlcanvas.inc:90
#7  $004b8180 in TCANVAS__REQUIREDSTATE (REQSTATE=[CSHANDLEVALID],
    this=$2199934) at canvas.inc:1403
#8  $004b7a30 in TCANVAS__MOVETO (X1=2, Y1=2, this=$2199934) at
canvas.inc:1075
#9  $007c12b1 in TSIMPLELINE__PAINT (this=$2216928) at SimpleLine.pas:49
#10 $007c127d in TSIMPLELINE__RESIZE (this=$2216928) at SimpleLine.pas:44
---------------- /backtrace-------------------------

---------------------- unit/component------------------------
unit SimpleLine;
{$mode objfpc}{$H+}
interface
uses
  Windows, Messages, SysUtils, Classes, GraphType,Graphics, Controls,
Forms, Dialogs,
  ExtCtrls, LResources;

type
  TSimpleLine = class(TCustomPanel)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure Paint; override;
    procedure Resize; override;
  published
    property OnResize;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Misc',[TSimpleLine]);
end;

constructor TSimpleLine.Create(AOwner: TComponent);
begin
  inherited;
end;

procedure TSimpleLine.Resize;
begin
  inherited;
  paint();
end;

// --------- this is where it all starts -----------------------
procedure TSimpleLine.paint() ;
begin
  Canvas.Moveto(2,2);
  Canvas.Lineto(4,4);
end;

end.          
-- 
[EMAIL PROTECTED]

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to