我在将图标资源添加到 C++ Win32 项目时遇到问题。我按照下面图片中的步骤进行操作,但我们运行 program.exe,菜单栏中没有我的图标(只有默认图标)。*.exe 文件具有应有的新图标。
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
LPCWSTR className = L"MyWindow";
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = className;
wc.hIconSm = LoadIcon(NULL, MAKEINTRESOURCE( IDI_ICON1));
if(!RegisterClassEx(&wc))
{
MessageBox(NULL,L"Error, registration of class faild", L"ERROR", MB_OK);
return 0;
}