Solved

Change ActiveX Icon

Posted on 2001-07-27
7
245 Views
Last Modified: 2010-04-06
I wrote an ActiveX control(ActiveForm), it has a default icon. How can I change it?
Thanks,
ysimon
0
Comment
Question by:ysimon
  • 4
  • 3
7 Comments
 
LVL 21

Expert Comment

by:gemarti
ID: 6328675
Create a binary resource file (.RES) with Image Editor.

Create a 24Y24 bitmap. Give the bitmap a numeric name (2 for example).

Link the resource file to the ActiveX project with the $R compiler directive. (Linking resources was discussed on Day 8, "Creating Applications in Delphi" and is discussed further on Day 20, "Creating Components.")

Modify the ActiveX class factory creation routine in the implementation unit (the ActiveForm's .PAS file). A typical class factory creation routine looks like this (it's in the initialization section at the bottom of the unit):

TActiveFormFactory.Create(
    ComServer,
    TActiveFormControl,
    TMyFormX,
    Class_MyFormX,
    1,                    { Change this number. }
    `',
    OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,
    tmApartment);

Notice the line marked with a comment. This parameter of TActiveFormFactory.Create is the resource number of the bitmap you want displayed on the Component palette. If you saved the new bitmap with a name of 2, you would replace the 1 in this code snippet with a 2.

5. Rebuild, reregister, import, and install the ActiveForm again. The new bitmap should now show up in the Component palette.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6328698
Just in case your not sure how to link the resource file:

{$R *.res}     { links in resource file }
0
 

Author Comment

by:ysimon
ID: 6329029
There was a .res file in project files already. I found that the project didn't use it. If I change that number from 1 to 2, it will use a Delphi5 default icon. If I change ActiveX icon (1) and keep that number as 1, the icon is not changed. Do I create a new res file?

ysimon
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 21

Expert Comment

by:gemarti
ID: 6329739
Basically you create a new resource file. call it ...test.res

You add you ICONS and BITMAPS

You include the resource file in your activeX compilation...{$R test.res}

Build the project.
Close the project.
Click on Components | Import ActiveX control
Locate your ActiveX Form and and click install
If you get a warning that the file already exists tell it yes overwrite(make sure its your activeXform!)
It will want to compile it into dclusr.dpk. I selected okay here.
Click on the compile button
You should get a message that it has added the form to your activeX pallet.

Good luck.

0
 

Author Comment

by:ysimon
ID: 6332363
Yes, it works, thank you very much.

ysimon
0
 
LVL 21

Accepted Solution

by:
gemarti earned 50 total points
ID: 6332368
Glad to help. I guess you can close this question out.....
0
 

Author Comment

by:ysimon
ID: 6332646
Thanks again,
ysimon
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question