Icon Behavior

I have written a stand-alone program called "Lamb Lion Net Conversion Utility" which you can find here --

http://www.lamblion.net/Links/links.htm

Just scroll down to the bottom to find it.

When you run it you'll notice that the icon appears exactly as it should be, i.e., the background is transparent.

Here's the problem --

I have also made this conversion utility a module in one of my other programs, only in this program the icon has a white background. In other words, it's not transparent.

I have used the SAME icon and the SAME code and characteristis as in the stand-alone, so I cannot for the life of me figure out why this so.

Does anybody have any ideas why the icon would be transparent in the stand-alone but has a white background in the module?
Last edited on
How are you setting the transparency flag? A lot of times libraries will try to get "close enough" to the color that you are trying to tell it, but in some cases it can lead to issues like this. I would say open up the source image and make sure that white is really white in this image and not some off-white color. This happens a lot to me if I keep changing the file type.
I'm not sure I understand. I am using the same icon and the same resource info in both programs, only the icon works fine in the stand-alone but has the white background in the module.

If there is a transparency flag, I don't know about it. Is there? And if so, how do I set it?
I should have said Transparency Mask, but now that I've re-read your post I don't think I was on the right track. I'll have to do some research into this one.
The link does not provide any source code, so I cannot examine it carefully and what follows is only guesses.

How is your icon linked into the code?
Did you create an ICO file?
Did you link using a Windows Resource file?
What code do you use to apply the icon to the program's window? (Something is definitely amiss here, since when I use my task-switch program I don't see the proper icon.)

Post back!
The link is only to show you how the icon appears perfeclty in the stand-alone program.

I have used the EXACT same code in my other program where I have made this a module instead of a stand-alone, but in the module the icon shows up with a white background.

My code for creating the icon is straightforward. Here it is in my resource file --

1
2
3
4
5
IDI_LLNCONVERT ICON "llnconvert.ico"

And then in the dialog procedure --

ICON  IDI_LLNCONVERT, IDC_STATIC, 141, 102, 25, 25, SS_ICON


In other words, I have not done one thing different except make it a module. Also, in my other dialog boxes in this program, which are also modules, the icons display properly.

It is ONLY in this module that the icon has a white background instead of a transparent background as in the standalone at the link I provided.

Very strange.
Last edited on
Yet you ignored the part where I notice that something is not right, as your stand-alone program does not properly provide the icon when displayed in my task switcher application (the thing you see when you press Alt-Tab).

What is the code you use to set the icon as your program's main icon?
If you didn't explicitly write any such thing, what framework are you using?
I don't know what you mean when you say the icon does not properly display because it displays perfectly on my computers and on others.

In the stand-alone in my register class I do this --

llncv.hIcon= LoadIcon(NULL, MAKEINTRESOURCE(IDI_LLNCONVERT));

Then in my rc file I do what I did in the previous post bove. Of course, I #define IDI_LLNCONVERT in my header file so that it is referenced properly.

So here is the entire resource file --

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// =======================================================
// Lamb Lion Net Conversion Utility
// llnconvert.rc
// =======================================================

#include "llnconvert.h"

// ICONS =============================================================
IDI_LLNCONVERT ICON "llnconvert.ico"
//============================================================

// SOUNDS ============================================================
IDS_SPLASH SOUND "splash.wav"
IDS_SKIP SOUND "skip.wav"
IDS_COPY SOUND "copy.wav"
//===========================================================

// MAIN DIALOG =================================================
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_LLNCONVERT DIALOGEX 0, 0, 185, 127
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | 
		WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_GROUP | WS_SYSMENU
EXSTYLE WS_EX_OVERLAPPEDWINDOW | WS_EX_APPWINDOW
CLASS szClassName
CAPTION "Lamb Lion Net Conversion Utility"
FONT 10, "Ms Shell Dlg 2", 400, 0, 1
{
    PUSHBUTTON      "1", IDC_ONE, 126, 23, 15, 12
    PUSHBUTTON      "2", IDC_TWO, 142, 23, 15, 12
    PUSHBUTTON      "3", IDC_THREE, 158, 23, 15, 12
    PUSHBUTTON      "4", IDC_FOUR, 126, 36, 15, 12
    PUSHBUTTON      "5", IDC_FIVE, 142, 36, 15, 12
    PUSHBUTTON      "6", IDC_SIX, 158, 36, 15, 12
    PUSHBUTTON      "7", IDC_SEVEN, 126, 49, 15, 12
    PUSHBUTTON      "8", IDC_EIGHT, 142, 49, 15, 12
    PUSHBUTTON      "9", IDC_NINE, 158, 49, 15, 12
    PUSHBUTTON      "0", IDC_ZERO, 126, 62, 15, 12
    PUSHBUTTON      ".", IDC_PERIOD, 142, 62, 15, 12
    PUSHBUTTON      "C", IDC_CLEAR, 158, 62, 15, 12
    PUSHBUTTON      "Copy", IDM_COPY_CONVERT, 126, 81, 47, 12
    
EDITTEXT IDE_INPUT, 15, 24, 100, 12, ES_AUTOHSCROLL

COMBOBOX IDC_CONV_1, 15, 42, 100, 12, WS_VSCROLL | WS_BORDER | CBS_DROPDOWNLIST | CBS_AUTOHSCROLL
COMBOBOX IDC_CONV_2, 15, 62, 100, 12, WS_VSCROLL | WS_BORDER |CBS_DROPDOWNLIST | CBS_AUTOHSCROLL

EDITTEXT  IDE_RESULT, 15, 81, 100, 12, ES_AUTOHSCROLL | ES_NUMBER | ES_READONLY

	PUSHBUTTON      "Help", IDB_HELP, 15, 98, 48, 12
	PUSHBUTTON      "About", IDB_ABOUT, 66, 98, 48, 12    
	PUSHBUTTON      "Options", IDB_OPTIONS, 15, 111, 48, 12	
	PUSHBUTTON      "Close", IDOK, 66, 111, 48, 12

    ICON  IDI_LLNCONVERT, IDC_STATIC, 141, 102, 25, 25, SS_ICON
}
// END MAIN DIALOG ===================================================

// OPTIONS DIALOG ====================================================
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_OPTBOX DIALOG 0, 0, 142, 43
STYLE WS_POPUP | DS_CENTER | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
CAPTION "Conversion Utility Options"
FONT 8, "Ms Shell Dlg"
{
    DEFPUSHBUTTON   "Save", IDOK, 82, 15, 50, 14
    AUTOCHECKBOX    "Play Sounds", IDC_CHKOPT, 12, 13, 60, 8
    AUTOCHECKBOX    "Copy Two Lines", IDC_TWOLINE, 12, 23, 60, 8
}
// END OPTIONS DIALOG ======================================= 
Last edited on
You won't believe this... Problem solved!

For some reason IDC_STATIC was not defined in the program containing the module, at least not for this particular module.

So I changed IDC_STATIC to -1 and it now works perfectly, i.e., the icon displays with a transparent background, just like in the stand-alone.

The reason the compiler didn't burp on this is because the main program defines IDC_STATIC, but the above module doesn't have access to that declaration.

In any case, there you go!

Thanks for your help.
Glad to have been, well, almost of help.
I often find that I solve a problem when trying to describe it to others...
:-)
That's exactly what happened. You forced me to examine each line of my RC file, and this led to the solution. I don't think I would have caught it, at least not this soon, unless we had had this conversation.
Topic archived. No new replies allowed.