🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.delphi.dotnet
7 messages
7 total messages Started by Stephen Boyd Tue, 10 Jun 2008 19:19
How to add an icon to a VCL.Net component
#7
Author: Stephen Boyd
Date: Tue, 10 Jun 2008 19:19
7 lines
1235 bytes
One last question for today.  I have been looking for the answer to this 
for the last hour and I can't find it.

In the old days (Delphi 5) you could add an icon to a component that 
would be displayed next to the component on the tool bar.  You did this 
by putting the icon in a .DCR file.  What is the equivalent for a 
VCL.Net component in Rad Studio 2007?
Re: How to add an icon to a VCL.Net component
#8
Author: Yorai Aminov (TeamB)
Date: Tue, 10 Jun 2008 19:34
19 lines
1510 bytes
Stephen Boyd wrote:

> In the old days (Delphi 5) you could add an icon to a component
> that would be displayed next to the component on the tool bar.  You
> did this by putting the icon in a .DCR file.  What is the
> equivalent for a VCL.Net component in Rad Studio 2007?

Add a {$R} directive to a unit in your design time package linking in
the bitmap:

{$R 'MyNamespace.MyComponent.bmp'}

The bitmap name should be the full .NET component name.

-- 
Yorai Aminov (TeamB)
(TeamB cannot answer questions received via email.)
Shorter Path - http://www.shorterpath.com
Yorai's Page - http://www.yoraispage.com
Re: How to add an icon to a VCL.Net component
#11
Author: Horst Reichert
Date: Wed, 11 Jun 2008 07:05
11 lines
1297 bytes
> Add a {$R} directive to a unit in your design time package linking in
> the bitmap:
>
> {$R 'MyNamespace.MyComponent.bmp'}
and
{$R 'MyNamespace.MyComponent16.bmp'}
{$R 'MyNamespace.MyComponent32.bmp'}

for the small and large Icons

Regards Horst
Re: How to add an icon to a VCL.Net component
#17
Author: Stephen Boyd
Date: Wed, 11 Jun 2008 14:10
24 lines
1835 bytes
> 
> Add a {$R} directive to a unit in your design time package linking in
> the bitmap:
> 
> {$R 'MyNamespace.MyComponent.bmp'}
> 
> The bitmap name should be the full .NET component name.
> 

I have created a 16x16 256 colour bitmap.  The namespace for my 
components is LNSSoftware.  The class name for the component is 
TLNSEdit.  I named the bitmap LNSSoftware.TLNSEdit.bmp.  I added

{$R LNSSoftware.TLNSEdit.bmp}

just after the uses clause in the module which contains the TLNSEdit 
class.  I rebuilt the DLL.  The icon does not appear on the tool bar.

I also tried adding {$R LNSSoftware.TLNSEdit16.bmp} and {$R 
LNSSoftware.TLNSEdit32.bmp'}.  That didn't help either.

I must be doing something stupid but I can't figure out what it is.

Any suggestions?
Re: How to add an icon to a VCL.Net component
#19
Author: Stephen Boyd
Date: Wed, 11 Jun 2008 15:13
8 lines
1245 bytes
Stephen Boyd wrote:
> 
> I must be doing something stupid but I can't figure out what it is.
> 
> Any suggestions?

Never mind.  Removing the namespace from the front of the bitmap name 
made it work.  Don't ask me why though.
Re: How to add an icon to a VCL.Net component
#22
Author: Horst Reichert
Date: Thu, 12 Jun 2008 05:11
6 lines
1257 bytes
> Never mind.  Removing the namespace from the front of the bitmap name made 
> it work.  Don't ask me why though.
Did you add the resource to the Project or the Unit? If you took the unit it 
might be logical...

Regards Horst 
Re: How to add an icon to a VCL.Net component
#23
Author: Stephen Boyd
Date: Thu, 12 Jun 2008 12:28
12 lines
1695 bytes
Horst Reichert wrote:
>> Never mind.  Removing the namespace from the front of the bitmap name made 
>> it work.  Don't ask me why though.
> Did you add the resource to the Project or the Unit? If you took the unit it 
> might be logical...
> 

I added the resource to the unit.  I think that the problem arose 
because I gave the project a default namespace of LNSSoftware, but I 
didn't name the unit LNSSoftware.LNSEdit, rather just LNSEdit.  I 
haven't had a chance to experiment to see if that is indeed the problem 
though.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads