Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Component icon not showing up in component bar or on forms


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Feb 1, 2018 4:48 PM Last Post By: Ted Lyngmo Threads: [ Previous | Next ]
Ted Lyngmo

Posts: 117
Registered: 10/3/06
Component icon not showing up in component bar or on forms  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 31, 2018 12:01 PM
I created a BITMAP (24x24x16 indexed colors) icon for my component back in 2002 (BCB4). I used the Image Editor to put it in a .res file as

File: TComPort.res
 
Contents
  |
  +-- Bitmap
       |
       +-- TCOMPORT    


This works fine in BCB4 and RAD2007 but I can't figure out how to make it work properly in 10.2.

In the IDE:s Component bar, and when dropping the component on a form, the default "this component doesn't have an icon" icon is shown.
In the Structure view and in the Tool Palette, my bitmap is shown fine.

I used "Project\Resources and Images" to add the resource file (even though *.res wasn't included in the selection).
The .res file is added but doesn't show up if I go into "Project\Resources and Images" again.
Also, when adding it, it pre-selected type RCDATA, so I stuck with that and changed the Resource Identifier to "TComPort".
I also tried changing the type to BITMAP and the identifier to TCOMPORT - and I tried the RCDATA/TCOMPORT and BITMAP/TComPort combinations.
Same result.

I then tried this guide https://community.embarcadero.com/blogs/entry/easy-add-custom-component-icons-in-delphi by rescaling the original bitmap to 128x128 (RGB) and added it to a plain .bmp file which I added to the project with "Project\Resources and Images". This time, it stays listed as a BITMAP in the "Project\Resources and Images" list even if I close it and re-open it.
But the result is the same.

I also found this:
https://community.embarcadero.com/blogs/entry/new-in-10-2-2-component-icons
"Component icons should come in 16, 24 and 32px sizes for differing display in the Tool Palette or component toolbar and the form designer; not only did we not always have all sizes, but sometimes they looked completely different at different sizes."

I interpret "should" as "does not have to" since they also say they didn't have all sizes prior to 10.2.2, and I have 10.2.1 :)

Also tried adding USERES("TComPort.res") but the need for that seems to have been removed.
#define USERES(FileName) \
   extern PACKAGE int DummyThatIsNeverReferenced


It feels like I'm close since the icon is visible in the Structure view and Tool Palette - but I can't figure out what's missing to get it to show up in the component bar and on the actual forms.

Br,
Ted
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Component icon not showing up in component bar or on forms  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 31, 2018 4:44 PM   in response to: Ted Lyngmo in response to: Ted Lyngmo
Ted Lyngmo wrote:

I created a BITMAP (24x24x16 indexed colors) icon for my component
back in 2002 (BCB4).

Modern versions of the IDE support multiple image sizes (16x16, 24x24,
32x32, and 128x128) and multiple color depths (16bit, 24bit, and
32bit). And 10.2.2 Tokyo even adds support for PNGs!

I used the Image Editor to This works fine in BCB4 and RAD2007 but I
can't figure out how to make it work properly in 10.2.

The exact same way as before. The old method still works. We just
don't have the Borland Image Editor anymore, but any graphics editor
will work. And you can compile .res files using .rc files with
BRCC32.EXE.

In the IDE:s Component bar, and when dropping the component on a
form, the default "this component doesn't have an icon" icon is
shown.

Then you didn't compile your images into your component's package
correctly.

I used "Project\Resources and Images" to add the resource file (even
though *.res wasn't included in the selection).

Nor is it supposed to be. That dialog is meant for managing individual
resources. So you would add the individual images, not the precompiled
.res file.

The .res file is added but doesn't show up if I go into "Project
\Resources and Images" again. Also, when adding it, it pre-selected
type RCDATA, so I stuck with that and changed the Resource Identifier
to "TComPort".

This is all wrong. If you are going to use the dialog to manage teh
.res file (I prefer using .rc files instead), then add your 24x24
image, give it the BITMAP type, and "TCOMPORT" identifier. DO NOT add
the .res file itself!

I then tried this guide
https://community.embarcadero.com/blogs/entry/easy-add-custom-componen
t-icons-in-delphi by rescaling the original bitmap to 128x128 (RGB)
and added it to a plain .bmp file which I added to the project with
"Project\Resources and Images".

Did you add a "128" suffix to the resource identifier ("TCOMPORT128")?
You need a separate resource for each image size ("TCOMPORT16" for
16x16, "TCOMPORT" for 24x24, "TCOMPORT32" for 32x32, "TCOMPORT128" for
128x128) that you want to support.

I also found this:
https://community.embarcadero.com/blogs/entry/new-in-10-2-2-component-icons

Yes, do what that says.

I interpret "should" as "does not have to" since they also say they
didn't have all sizes prior to 10.2.2, and I have 10.2.1 :)

Correct. If you don't provide an image of a certain size, the IDE will
simply resize one of the images that you do provide. The IDE has
always done that.

Also tried adding USERES("TComPort.res") but the need for that seems
to have been removed.

#define USERES(FileName) \
   extern PACKAGE int DummyThatIsNeverReferenced

The USE...() macros were disabled way way back in like BCB 5 or 6, I
forget which.

--
Remy Lebeau (TeamB)
Ted Lyngmo

Posts: 117
Registered: 10/3/06
Re: Component icon not showing up in component bar or on forms  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 1, 2018 12:23 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Ted Lyngmo wrote:

I created a BITMAP (24x24x16 indexed colors) icon for my component
back in 2002 (BCB4).

Modern versions of the IDE support multiple image sizes (16x16, 24x24,
32x32, and 128x128) and multiple color depths (16bit, 24bit, and
32bit). And 10.2.2 Tokyo even adds support for PNGs!

I used the Image Editor to This works fine in BCB4 and RAD2007 but I
can't figure out how to make it work properly in 10.2.

The exact same way as before. The old method still works.

That's good! Something must have gone wrong when I copied the project from BCB4 to RAD2007 and then from RAD2007 to 10.2 since the bitmap in the existing .res file only appeared in 2 out of 4 places in the 10.2 IDE.

We just don't have the Borland Image Editor anymore,

I still use the editor from BCB4. It matches my graphical skills perfectly.

but any graphics editor will work. And you can compile .res files
using .rc files with BRCC32.EXE.
[...]
Then you didn't compile your images into your component's package
correctly.

Indeed.

I removed all traces of the loose bitmap variants from the project and then added the original resource file again but this time via the "Project Manager" (instead of via "Resources and Images..."):

"Contains\Add..."
"Unit file name: TComPort.res"

Compiled and installed - and now it works!

Edit: I take that back. After having removed it and tried misc. other ways, I can't get it to work like I did above again... sigh
Edit2: No icon was shown in any of the four placed it was shown before. I then just restarted the IDE and there it was - but this time only on the Component bar and on the forms which is the opposite to what made me start this thread. What made it appear to work for a while may have been some glitch in the IDE. I didn't restart to see if the Icon was still visible. :-/
Edit3: The "LynconComPort_resources.rc" with a reference to TComPort.bmp was still present in the directory even after I removed the bmp file from the project (and then removed the bmp from the directory). I now deleted that rc file, recompiled and installed and now it's visible everywhere again. This time I restarted the IDE to check - and now the Icon is gone again. Another noticeable thing that it's not showing up in the list of Installed Packages anymore (it did previously).

Edit4: I noticed the compiler had stopped creating new object files (or only did it occasionally) so when I changed something it didn't have an immediate effect. The linker happily linked the old versions. I ran the compilation command from command prompt and it was successful ... but the file wasn't updated. I removed the object file and ran the command and again, successful - but no obj file. I think that it was when I unticked "C++ Compiler\Pre-compiled Headers\External type files (Clang compiler)" that I got the object file generation going again and then I added the bmp file and it now looks like it's working.

On the subject of header files: When using my component in a project, the header file can't be found. $(BDSCOMMONDIR)\hpp\$(Platform) is empty. What do I need to do to get it installed so it can be used directly (like the lib etc)?

The .res file is added but doesn't show up if I go into "Project
\Resources and Images" again. Also, when adding it, it pre-selected
type RCDATA, so I stuck with that and changed the Resource Identifier
to "TComPort".

This is all wrong. If you are going to use the dialog to manage teh
.res file (I prefer using .rc files instead), then add your 24x24
image, give it the BITMAP type, and "TCOMPORT" identifier. DO NOT add
the .res file itself!

Got it!

I then tried this guide
https://community.embarcadero.com/blogs/entry/easy-add-custom-componen
t-icons-in-delphi by rescaling the original bitmap to 128x128 (RGB)
and added it to a plain .bmp file which I added to the project with
"Project\Resources and Images".

Did you add a "128" suffix to the resource identifier ("TCOMPORT128")?
You need a separate resource for each image size ("TCOMPORT16" for
16x16, "TCOMPORT" for 24x24, "TCOMPORT32" for 32x32, "TCOMPORT128" for
128x128) that you want to support.

I didn't see that part in the guide I tried to follow, but now when you mention it, it's right there in the other guide I found. I did however try with the original TComPort.bmp (24x24) with the resource id TCOMPORT too.
When compiling, the package's .rc file (that has been created automatically by the IDE when I added the .bmp file I guess) is compiled
  c:\program files\embarcadero\studio\19.0\bin\cgrc.exe -c65001 "LynconComPort_resources.rc" -fo.\Win32\Release\LynconComPort_resources.res

It contains:
TCOMPORT BITMAP "TComPort.bmp"


"CGRC.EXE is the compiler-binder that is called by the IDE when you have selected to use the Windows SDK Resource Compiler"

I haven't selected the Windows SDK Resource Compiler - and in Project\Options\Resource Compiler it says brcc32.exe. That's odd ...

Should there be an .rc file called TComPort.rc for it to work? If so, do I need to create that one manually and add it to the project?

So far, creating the .res file using BCB4's editor have been the only thing working - once I figured out how to add it to the project that is.

Correct. If you don't provide an image of a certain size, the IDE will
simply resize one of the images that you do provide. The IDE has
always done that.

Great!

Thanks! / Ted

Edited by: Ted Lyngmo on Feb 1, 2018 4:28 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02