在资源中添加ICO图标,获取属性名,在主窗口文件中的函数InitWindow或OnCreate中添加如下代码:
SetIcon(IDR_MAINFRAME);
修改EXE显示图标,在主窗口中加入如下代码:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { CPaintManagerUI::SetInstance(hInstance); CCFrameDraw duiFrame; duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); HICON hIcon = ::LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON2)); ::SendMessage(duiFrame.GetHWND(),STM_SETICON,IMAGE_ICON,(LPARAM)(UINT)hIcon); duiFrame.CenterWindow(); duiFrame.ShowModal(); return 0; }