Hi
I'm trying to create application using C and GDI. I want my EXE file to have an ICON, so I created .bmp file (64x64) and added to resource file. Then I created HICON hIcon using that bitmap image (CreateIconIndirect(...))
Now my problem is, .EXE file still has the default windows application icon but when I run it I see the icon (The on I created) in task bar. Now how can I change .EXE icon (Basically add my ICON to the binary file)?
Thanks
Regards
Mark
main.c
wc.lpfnWndProc = WndProc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = CreateAppIconFromRes(hInstance); /* **** */
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszClassName = szAppName;
wc.lpszMenuName = NULL;
gdi_helper.c
static HICON hAppIcon = NULL;
HICON CreateAppIconFromRes(const HINSTANCE hInst)
{
HDC hDC;
HBITMAP hMask, hBitmap;
ICONINFO iInfo;
hDC = CreateCompatibleDC(NULL);
hMask = CreateCompatibleBitmap(hDC, 64, 64);
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDI_APPICON));
iInfo.fIcon = TRUE; /* TRUE for ICON, FALSE for CURSOR */
iInfo.hbmMask = hMask;
iInfo.hbmColor = hBitmap;
hAppIcon = CreateIconIndirect(&iInfo);
/* Clean Up */
DeleteDC(hDC);
DeleteObject(hMask);
DeleteObject(hBitmap);
return hAppIcon;
}
Resource.h
#define IDI_APPICON 3000
sg_resource.rc
#include "resource.h"
#include "afxres.h"
IDI_APPICON BITMAP "Data\\ICON.bmp"