开发者

No icon in title bar after switching from WNDCLASS to WNDCLASSEX

I just switched the game to use WNDCLASSEX so I can change the hIconSm, but for some reason there isn't an icon in the title bar anymore. The cursor and icon on the task bar and the icon for the EXE are all working fine though. Here is the main part of the window creation code:

 WNDCLASSEX wc;

 wc.cbSize = sizeof(WNDCLASSEX);
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.style = CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc = WinProc;
 wc.hInstance = hInstance;
 wc.hIcon = LoadIcon(NULL, IDI_ERROR);
 wc.hIconSm = LoadIcon(NULL, IDI_ASTERISK);
 wc.hCursor = LoadCursorFromFile((LPCSTR)"FierceCursor.cur");
 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
 wc.lpszClassName = "FierceWindow";

 RegisterClassEx(&wc);

 game->hinstance = hInstance;

 hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,
                          "FierceWindow", "Fierce",
                          开发者_开发技巧WS_OVERLAPPED, 400, 100,
                          game->SCREEN_WIDTH, game->SCREEN_HEIGHT,
                          NULL, NULL, hInstance, NULL);

I've tried a few different settings for CreateWindowEx in hopes that maybe I used a style without an icon, but no luck. I'm using default icons right now to test.


Won't compile:

error: cast from 'CHAR*' to 'WORD' loses precision

Thanks for the edit btw.

Edit - Got it to compile by changing it to:

    wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(32513));
wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(32513));


It's because of your window style. The icon appears only if you add WS_SYSMENU style.

WS_OVERLAPPED|WS_SYSMENU

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜