Advertisement

Resources... (custom icons)

Started by October 04, 2000 12:02 AM
3 comments, last by Peon 24 years, 3 months ago
Maybe I''m just dense, but I don''t think LaMothe explained this very clearly in TOTWPG... I have tried for a long time to get a stupid custom icon loaded, but I keep getting tripped up (I think part of the reason is he sort of introduces two methods at the same time -- very similar methods) So if someone could kinda explain how I could get a simple icon loaded (oh, btw, this icon would simply be for the window itself... I can get the standard windows icons, but can''t seem to get a custom one loaded ) it would be much appreciated. Oh, and this is what I have been doing: 1) Creating a new Win32 project and adding a C++ file with the source for a blank window using the WinAPI 2) Adding a new resource script 3) From there, I import the icon I want; the one from the CD in this case 4) I then try to load it like any other icon, like LoadIcon(hinstance, IDI_APPLICATION), for instance, except I include quotes, like LoadIcon(hinstance, "DirectXIcon") It compiles and all, but the icon remains the standard icon... Sorry if that''s too vague, I''ll try and post again later if things get messy Thanks
Peon
Um.... dont trust me 100% on this particular subject, cuz i just completed that chapter myself... But my best guess is thatyou make sure you haave the right ID for that icon, and make sure its in the samedestination.. also, amke sure u include the resource file into the project.. also remember u have to do the icon thing when u set up a window.. the onw that has like 30 different parameters.. (pain in the ass)

hope it helped..
probaly didnt
Bye
Ryan Lahay
life is short.. live it to the fullest
Advertisement
hicon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ICONID ));


Substitute IDI_ICONID with the ID of the icon in your resource script.

------------------------------
#pragma twice


sharewaregames.20m.com

Just make sure you''re actually placing the LoadIcon() call as a member of your WNDCLASSEX structure prior to registering the class and using it to create a window. If you just have the line:

HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));

sitting in your code somewhere, it''s not gonna do anything except load a handle that doesn''t get used.

-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
Although technically using LoadIcon works, the function is now considered obsolete and has been superseded by LoadImage, as follows:

HICON hIcon = (HICON)LoadImage( hInst, // your stored instance for your application
lpszName, // image identifier, which is the resource unless fuLoad is LR_LOADFROMFILE, in which case it's the file name
uType, // you want this to be IMAGE_ICON, obviously
cxDesired, // resource width if you use 0 here
cyDesired, // resource height if you put 0 here
fuLoad // check MSDN for valid params for this);

Oh, by the way... unless you actually specify that you want this icon used for this particular window (which you do in the WNDCLASS setup...) it won't come up as your default icon for the application. Or you can use SetIcon I suppose, though I always set it in the WNDCLASS so I'm not sure whether it will retain knowledge for the large icon once you lose application scope. My guess is that it would tho.

-fel

Edited by - felisandria on October 4, 2000 10:43:32 AM
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

This topic is closed to new replies.

Advertisement