Link to home
Start Free TrialLog in
Avatar of NickRepin
NickRepin

asked on

Icon index

Microsoft VC++ 6.0 /SP3

I'm creating the shell shortcuts for my app. I need to specify an icon index for the shortcut.
The question is: what should I do to assign the certain icon index to the icon resource?

Usually, I declare the icons by names, not by numbers (see below).
I tried both ways. I placed the icons to the beginning of the RC file and in alphabetical order.
Nothing helps.

Here is my RC file. The first two icons must have the indexes 0 and 1.

I tried:

1)   1  ICON "App.ico"        
     2  ICON "Apptrace.ico"  

Result:
Encprop_Icon has index 0
Lock_Icon has index 1
(Encprop_Icon is a first in the alphabetical order among all other icons, Lock_Icon is a second one).


2)   App1  ICON "App.ico"        
     App2  ICON "Apptrace.ico"  

Result:
App1 has index 0 (as required).
Lock_Icon has index 1

What is going on?



// RC file ********************
#include <commctrl.h>
#include <winnt.rh>

1        ICON "App.ico"          // MUST HAVE INDEX 0
2        ICON "Apptrace.ico"     // MUST HAVE INDEX 1

#include "Auxstr.rc"
#include "Getstr.rc"
...
#include "Logprop.rc"  // CONTAINS AN ICON "Logprop_Icon"
#include "Winerr.rc"
#include "Userinfo.rc"
#include "Verinfo.rc"

#include "Data.rc"      // CONTAINS AN ICON "Encprop_Icon"
#include "Inout.rc"     // All these files contain icons.
#include "Nuser.rc"
#include "Skt.rc"
#include "Users.rc"

... OTHER RESOURCES

MicCtrl_Icon   ICON     "Micctrl.ico"
MicMuted_Icon  ICON     "Micmuted.ico"
Lock_Icon      ICON     "Lock.ico"
Status_Bmp     BITMAP   "Status.bmp"
Call_Wav       WAVE     "Call.wav"
Chat_Cursor    CURSOR   "Chatwait.cur"
Miscprop_Icon  ICON     "Mscprop.ico"
...
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickRepin
NickRepin

ASKER

Still there is problem with the icon with index 1.

I found the workaround. I use the numeric id for the second icon and then specify its negative value as the icon index.

Anyway, thanks. Now I exactly know what to do with the icon to be displayed near the exe name in the Explorer window .

It seems that this article was written before NT4, because my NT chooses the icon to display as Win95 described here.