I've Created a custom .ico with VS2010 for a game I'm making with DirectX
When I set the .ico file as hIcon member of my wndClass, it will show in the taskbar, but not in the title bar.
I've read the other threads about this, I've searched goog开发者_如何学Gole, msdn: no luck... I've tried just about anything I could come up with, it still wouldn't show.
The weird thing is: when I switch the hIcon to a default icon (like IDI_ERROR) it will show both in taskbar and in title bar, but not with my custom made .ico
Can anyone help me?
Here is my code:
HICON Icon = LoadIcon( NULL, MAKEINTRESOURCE(ID_ICON_MYTETRIS) );
WNDCLASS wndClass;
ZeroMemory(&wndClass,sizeof(wndClass));
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndClass.hIcon = Icon;
wndClass.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = _T("WindowClass0");
if (RegisterClass(&wndClass) == false) {
return -1;
}
RECT rc = {0,0,300,225};
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
HWND hWnd = CreateWindow(_T("WindowClass0")
,_T("2D_DirectX_Tetris")
,WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX
,CW_USEDEFAULT
,CW_USEDEFAULT
,rc.right - rc.left
,rc.bottom - rc.top
,NULL
,NULL
,hInstance
,NULL );
if( hWnd == false) {
return -1;
}
ShowWindow( hWnd, iCmdShow );
You have to specify an instance handle in your call to LoadIcon so it knows which module's resources to use. The standard icons require a NULL instance, that's why they work for you.
精彩评论