Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-05

Carbon: Simple component in a simple package with strange behavior

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bent Normann Olsen

Hi all,

Lately I've been trying to create a package with custom components, which works already on Lazarus Win32, but gets all kinds of errors on Mac OS X, so I created a package from scratch and try to isolate different problems.

I created a new package and saved it as "TestPackage.lpk", added a new component with TWinControl as ancestor type and named it TCommonTest, named the unit NewCtrls and saved the unit as newctrls.pas. I added a new requirement to the package, so that LCL also is required by the new package.

I then manually added a new component to the unit named TComponentTest with TCommonTest as ancestor, and changed the register procedure to only register the last component.

It compiles, and the component is installed, and the component is visible in the tab "New Ctrls" on Lazarus, which is compiled to Carbon.

But when I try to drop the new component on a form (on a new and clean application) it fails saying "Error moving component ComponentTest1:TComponentTest". The new component does not appear on the Object Inspector at first, but clicking on the component tree will make it appear, and I also can select the component on the form - but nothing is added to the unit source, and the application can't run because of Class "TComponentTest" not found, which naturally is caused by nothing was added to the units uses clause.

Manually making the changes to the forms unit will cause the application to raise an exception with the message: "(V)TCarbonWSWinControl.CreateHandle Error:Not implemented - unable to create Carbon win control for ComponentTest1:TComponentTest!"

Does a new component with an ancestor type of TWinControl need special handling, or is it impossible? Or am I doing something totally wrong?

Thanks and best regards,
Normann

-------
//The NewCtrls unit is simple and looks like this:
unit NewCtrls;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;
type
  TCommonTest = class(TWinControl)
  private
  protected
  public
  published
  end;
  TComponentTest = class(TCommonTest)
  private
  protected
  public
  published
  end;
procedure Register;
implementation
procedure Register;
begin
  RegisterComponents('New Ctrls',[TComponentTest]);
end;
end.
-------
//And the package unit looks like this:
unit TestPackage;
interface
uses
  NewCtrls, LazarusPackageIntf;
implementation
procedure Register;
begin
  RegisterUnit('NewCtrls', @NewCtrls.Register);
end;
initialization
  RegisterPackage('TestPackage', @Register);
end.

Reply by email

Bent Normann Olsen
to Bent Normann Olsen

Hi again,

I moved up an ancestor type of TCustomControl, and it works better - it might be caused by the paint behavior on Carbon, I dunno, but it would be nice to know why :-)

Regards,
Normann

Earlier message 15 lines
-----Original Message----- From: [mailto:] On Behalf Of Bent Normann Olsen Sent: 30. maj 2008 12:20 To: 'General mailing list' Subject: [Lazarus] Carbon: Simple component in a simple package with strange behavior Hi all, Lately I've been trying to create a package with custom components, which works already on Lazarus Win32, but gets all kinds of errors on Mac OS X, so I created a package from scratch and try to isolate different problems. [snip]

Reply by email

Tom Gregorovic
to Bent Normann Olsen: Lately I've been trying to create a package with custom components, which works already…
Bent Normann Olsen wrote 35 lines
Hi all, Lately I've been trying to create a package with custom components, which works already on Lazarus Win32, but gets all kinds of errors on Mac OS X, so I created a package from scratch and try to isolate different problems. I created a new package and saved it as "TestPackage.lpk", added a new component with TWinControl as ancestor type and named it TCommonTest, named the unit NewCtrls and saved the unit as newctrls.pas. I added a new requirement to the package, so that LCL also is required by the new package. I then manually added a new component to the unit named TComponentTest with TCommonTest as ancestor, and changed the register procedure to only register the last component. It compiles, and the component is installed, and the component is visible in the tab "New Ctrls" on Lazarus, which is compiled to Carbon. But when I try to drop the new component on a form (on a new and clean application) it fails saying "Error moving component ComponentTest1:TComponentTest". The new component does not appear on the Object Inspector at first, but clicking on the component tree will make it appear, and I also can select the component on the form - but nothing is added to the unit source, and the application can't run because of Class "TComponentTest" not found, which naturally is caused by nothing was added to the units uses clause. Manually making the changes to the forms unit will cause the application to raise an exception with the message: "(V)TCarbonWSWinControl.CreateHandle Error:Not implemented - unable to create Carbon win control for ComponentTest1:TComponentTest!" Does a new component with an ancestor type of TWinControl need special handling, or is it impossible? Or am I doing something totally wrong?

Hi,
each TWinControl descendant needs to have implemented creation of underlying Carbon control. If you want to use generic TWinControl, you have to choose TCustomControl.

Tom

Reply by email

Bent Normann Olsen
to Tom Gregorovic

Thanks Tom, it works. It's old Delphi habit, when you can use TWinControl and design a new control from buttom. But TCustomControl is fine, and I'll work with that ;-)

/Normann

Earlier message 15 lines
-----Original Message----- From: [mailto:] On Behalf Of Tom Gregorovic Sent: 30. maj 2008 13:15 To: General mailing list Subject: Re: [Lazarus] Carbon: Simple component in a simple package with strange behavior [snip] Hi, each TWinControl descendant needs to have implemented creation of underlying Carbon control. If you want to use generic TWinControl, you have to choose TCustomControl. Tom

Reply by email