Board index » delphi » Tree View doesn't paint its items inside a COM Object

Tree View doesn't paint its items inside a COM Object

Hi,

I'm trying to implement a com object whose purpose is to create a User
Interface.

That User Interface contains a Tree View. The problem comes when I insert
some items into the Tree View, they are there but are not displayed. I even
tried to make it a custom draw control but the event is never called. I
tried subclassing my own class to override the CustomDraw and CustomDrawItem
methods but the same happens, they are not called.

I tested the same thing in the MyForm.OnCreate event and it works, the
problem seems to come when the Tree View is created inside the com object.

I'm using Delphi5, Win95 version 4.00.950 B with Internet Explorer 4.0
version
4.72.2106.8. I upgraded the comctrl32.dll file so now the version of this
file is 4.72.3611.1900 but the result is the same.

Please I would appreciate any help, any clue,

This is my code:

IMyUserInterface = interface(IUnknown)
    ['{1CA521A0-AD5A-26B2-97CB-25C637A38652}']
    function  CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
end;

TMyUserInterface = class(TComObject, IMyUserInterface)
protected
    {Declare IMyUserInterface methods here}
    function CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
end;

The implementation of this method is:

function CreateAndPopulate(ParentWnd: LongWord): HResult;
begin
  TvwInfo := TTreeView.Create(nil);
  with TvwInfo do
  begin
    ParentWindow := ParentWnd;
    Left := 10;
    Top := 10;
    Width := 200;
    Height := 250;
    TabOrder := 0;
    Ctl3D := true;
    BorderStyle := bsSingle;
  end;

  TvwInfo.Items.Add(nil, 'Item 1');
  TvwInfo.Items.Add(nil, 'Item 2');
end;

The way this com object is called is this:
MyUI := CreateComObject(Class_MyUserInterface) as IMyUserInterface;
MyUI.CreateAndPopulate(Self.Handle);

Thanks a lot...

 

Re:Tree View doesn't paint its items inside a COM Object


Hi,
Actually I have no idea why this happens but I read something about ActiveX
controls somewhere. As I understand, you can create ActiveX versions of most
VCL controls but not all of them. First reason VCL control may depend on
another control that can not be ActiveX. Example for this is TDBGrid.
TDBGrid depends on TDataSource and TDataSource can not be ActiveX. Second
reason is it may be hard to implement, and the example for this one is
TTreeView. I don't know where I read it but it said that nodes in TTreeView
is very hard to implement in ActiveX.
Actually I'm not sure ActiveX control limitation is valid for your COM
implementation but I think the problem is same.

"J. Luis Rios" <jldevelo...@yahoo.com> wrote in message
news:8604kp$dgd24@bornews.borland.com...

Quote
> Hi,

> I'm trying to implement a com object whose purpose is to create a User
> Interface.

> That User Interface contains a Tree View. The problem comes when I insert
> some items into the Tree View, they are there but are not displayed. I
even
> tried to make it a custom draw control but the event is never called. I
> tried subclassing my own class to override the CustomDraw and
CustomDrawItem
> methods but the same happens, they are not called.

> I tested the same thing in the MyForm.OnCreate event and it works, the
> problem seems to come when the Tree View is created inside the com object.

> I'm using Delphi5, Win95 version 4.00.950 B with Internet Explorer 4.0
> version
> 4.72.2106.8. I upgraded the comctrl32.dll file so now the version of this
> file is 4.72.3611.1900 but the result is the same.

> Please I would appreciate any help, any clue,

> This is my code:

> IMyUserInterface = interface(IUnknown)
>     ['{1CA521A0-AD5A-26B2-97CB-25C637A38652}']
>     function  CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
> end;

> TMyUserInterface = class(TComObject, IMyUserInterface)
> protected
>     {Declare IMyUserInterface methods here}
>     function CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
> end;

> The implementation of this method is:

> function CreateAndPopulate(ParentWnd: LongWord): HResult;
> begin
>   TvwInfo := TTreeView.Create(nil);
>   with TvwInfo do
>   begin
>     ParentWindow := ParentWnd;
>     Left := 10;
>     Top := 10;
>     Width := 200;
>     Height := 250;
>     TabOrder := 0;
>     Ctl3D := true;
>     BorderStyle := bsSingle;
>   end;

>   TvwInfo.Items.Add(nil, 'Item 1');
>   TvwInfo.Items.Add(nil, 'Item 2');
> end;

> The way this com object is called is this:
> MyUI := CreateComObject(Class_MyUserInterface) as IMyUserInterface;
> MyUI.CreateAndPopulate(Self.Handle);

> Thanks a lot...

Re:Tree View doesn't paint its items inside a COM Object


Firstly, are you sure the items are there...i'm thinking exceptions are
occurring in COM that are being
handled in the safecall...where are you running the object Win95 or NT...
also a better type library exposed method using creation by the factory will
help. Make sure you
are absolutely certain the object is created (completely instantiated and
initialised as far as COM takes it)
before you call any of your methods....the create and whatever seems iffy.

willy...@garysown.freeserve.co.uk

Quote
Sinan Guven wrote in message <860rqv$e...@bornews.borland.com>...
>Hi,
>Actually I have no idea why this happens but I read something about ActiveX
>controls somewhere. As I understand, you can create ActiveX versions of
most
>VCL controls but not all of them. First reason VCL control may depend on
>another control that can not be ActiveX. Example for this is TDBGrid.
>TDBGrid depends on TDataSource and TDataSource can not be ActiveX. Second
>reason is it may be hard to implement, and the example for this one is
>TTreeView. I don't know where I read it but it said that nodes in TTreeView
>is very hard to implement in ActiveX.
>Actually I'm not sure ActiveX control limitation is valid for your COM
>implementation but I think the problem is same.

>"J. Luis Rios" <jldevelo...@yahoo.com> wrote in message
>news:8604kp$dgd24@bornews.borland.com...
>> Hi,

>> I'm trying to implement a com object whose purpose is to create a User
>> Interface.

>> That User Interface contains a Tree View. The problem comes when I insert
>> some items into the Tree View, they are there but are not displayed. I
>even
>> tried to make it a custom draw control but the event is never called. I
>> tried subclassing my own class to override the CustomDraw and
>CustomDrawItem
>> methods but the same happens, they are not called.

>> I tested the same thing in the MyForm.OnCreate event and it works, the
>> problem seems to come when the Tree View is created inside the com
object.

>> I'm using Delphi5, Win95 version 4.00.950 B with Internet Explorer 4.0
>> version
>> 4.72.2106.8. I upgraded the comctrl32.dll file so now the version of this
>> file is 4.72.3611.1900 but the result is the same.

>> Please I would appreciate any help, any clue,

>> This is my code:

>> IMyUserInterface = interface(IUnknown)
>>     ['{1CA521A0-AD5A-26B2-97CB-25C637A38652}']
>>     function  CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
>> end;

>> TMyUserInterface = class(TComObject, IMyUserInterface)
>> protected
>>     {Declare IMyUserInterface methods here}
>>     function CreateAndPopulate(ParentWnd: LongWord): HResult; stdcall;
>> end;

>> The implementation of this method is:

>> function CreateAndPopulate(ParentWnd: LongWord): HResult;
>> begin
>>   TvwInfo := TTreeView.Create(nil);
>>   with TvwInfo do
>>   begin
>>     ParentWindow := ParentWnd;
>>     Left := 10;
>>     Top := 10;
>>     Width := 200;
>>     Height := 250;
>>     TabOrder := 0;
>>     Ctl3D := true;
>>     BorderStyle := bsSingle;
>>   end;

>>   TvwInfo.Items.Add(nil, 'Item 1');
>>   TvwInfo.Items.Add(nil, 'Item 2');
>> end;

>> The way this com object is called is this:
>> MyUI := CreateComObject(Class_MyUserInterface) as IMyUserInterface;
>> MyUI.CreateAndPopulate(Self.Handle);

>> Thanks a lot...

Other Threads