Is your assignment to "Icon" the wc.hIcon structure member or just an outside variable? Also, it the icon you are loading coming straight from the game's exectuable or another executable?
If it is from the executable it is loading from, just do this:
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
"IDI_MYICON" is the ID for the icon that is loaded into your program during compile time.
LoadIcon
well that's the problem, that's actually what i'm trying to do, get the icon onto the executable
Then in your resource file, you need to stipulate the path so that during compiling, the icon itself is loaded into your executable. Then, when you release your program, you do not need to include that icon file since it is already compiled into your executable.
In your resource file:
"icon.ico" is the name of your icon's file name.
Make sure to also include, within your resource header, the resource ID: "#define IDI_PRGM 105" <-105 is arbitrary also without the quotes.
In your resource file:
//~~~~~IconIDI_PRGM ICON DISCARDABLE "icon.ico"
"icon.ico" is the name of your icon's file name.
Make sure to also include, within your resource header, the resource ID: "#define IDI_PRGM 105" <-105 is arbitrary also without the quotes.
i had to make a new resouce file and this is what i have in it by default
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Project.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
where should i put the icon stuff?
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Project.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
where should i put the icon stuff?
//{{NO_DEPENDENCIES}}// Microsoft Visual C++ generated include file.// Used by Project.rc//Icon Resource IDs#define IDI_PRGM 101// Next default values for new objects// #ifdef APSTUDIO_INVOKED#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NEXT_RESOURCE_VALUE 102#define _APS_NEXT_COMMAND_VALUE 40001#define _APS_NEXT_CONTROL_VALUE 1001#define _APS_NEXT_SYMED_VALUE 102#endif#endif
What is the name of the icon's file you are to load?
In your resource file the *.rc extension, type the following:
In your windows class, define your icon file to be loaded when executed as the following:
IDI_PRGM ICON DISCARDABLE "Galaga Icon.ico"
In your windows class, define your icon file to be loaded when executed as the following:
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PRGM));
Quote:Icon = LoadImage(0, (LPCTSTR)m_Icon, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
DWORD Error = GetLastError();
Error is 2. what's that mean?
Error number 2 means that "The system cannot find the file specified." Make sure that m_Icon is the filename of an existing .ico-file. If the path is relative (like "subdir\filename.ico" or just "filename.ico"), it is relative to the working directory (which often, but not always, is the directory of the .exe).
If you want to embed the icon in your exe, then instead listen to Xiachunyi.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement