Solved

Change ActiveX Icon

Posted on 2001-07-27
7
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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