Solved

Change ActiveX Icon

Posted on 2001-07-27
7
243 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now