我在向C ++ Win32 Project添加图标资源时遇到问题。我按照下面的图片中的步骤,但我们运行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;
}
答案 0 :(得分:2)
您的窗口样式为0.
尝试:
wc.style = WS_SYSMENU;
答案 1 :(得分:0)
wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1)); wc.hIconSm = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));