// Set the icon - this doesn''t seem to be working
HICON hIcon = LoadIcon( main_instance, MAKEINTRESOURCE( "Icon" ) );
SendMessage( main_window_handle, WM_SETICON, ICON_BIG, (LPARAM) hIcon ); // Set big icon
SendMessage( main_window_handle, WM_SETICON, ICON_SMALL, (LPARAM) hIcon ); // Set small icon
Todd M. Gillissie
setting the window icon
I''ve taken the following code from one of the sample programs in the dx8 sdk, but game window never shows the icon. Is there something wrong with this approach? This code is place right before the main loop in winmain.
the "Icon" identifier has to be specified in a resource file (.rc) where it is linked to an icon filename. You''ll find it in the same sample program.
It is. I guess I assumed everybody would assume that much. The icon for the executable works, but not the window and task bar.
Todd M. Gillissie
gillissie@yahoo.com
Todd M. Gillissie
gillissie@yahoo.com
It is much eaiser to set the icons in the CreateWindowEx function call. There are parameters for Icon and SmallIcon.
here is some code
Hope this helps
-----------------------------
kevin@mayday-anime.com
http://dainteractive.mayday-anime.com
here is some code
ATOM RegisterWndClass(HINSTANCE hInstance){ WNDCLASSEX wndClass; //////////////////////// // Sets the size of the window class structure wndClass.cbSize = sizeof(WNDCLASSEX); //////////////////////// // Class Style is set here. Allows for Double Clicks, Vertical and Horizontal // redraw. wndClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; //////////////////////// // This is the function that is called when a message is posted to the window wndClass.lpfnWndProc = (WNDPROC)WindowProc; //////////////////////// // This is a simple window, this setting is not needed wndClass.cbClsExtra = 0; //////////////////////// // Same as above wndClass.cbWndExtra = 0; //////////////////////// // The instance of the window wndClass.hInstance = hInstance; ///////////////////////// // Definition of the Icon for the application loaded from the // resource file, but since we don''t have one here, just load the default wndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)); ///////////////////////// // Definition of the Cursor for the application loaded from the // resource file, but since we don''t have one here, just load the default wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); ////////////////////////// // Sets the background color of the window wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); /////////////////////////// // Name of the Menu system, but we don''t have one, so it is NULL wndClass.lpszMenuName = NULL; /////////////////////////// // Title of your Window Class wndClass.lpszClassName = WINDOW_CLASS_NAME; //////////////////////////// // Small Icon for the Application, we don''t have one, thus the value // is set to 0; wndClass.hIconSm = 0; ///////////////////////////// // Returns the registered structure. This call registers the window // with the OS, so it can be set to send and recieve messages return RegisterClassEx(&wndClass);}// End RegisterWndClass()
Hope this helps
-----------------------------
kevin@mayday-anime.com
http://dainteractive.mayday-anime.com
The large icon works great, but the taskbar button for the game still doesn''t show an icon. That is where the small icon would show up, right? It''s not happenin''
Todd M. Gillissie
Todd M. Gillissie
When you create your window, do you specify that it should have a window menu (the necessary style is
WS_SYSMENU
) either directly or through one of those styles that combines a bunch of others? If the window has no window menu, no icon will display either on the title bar or next to the title in the taskbar button.
Here''s how I set the icon (Works for taskbar and title bar):
I mostly use it to set icons for dialog boxes though...
- Goblineye Entertainment
The road to success is always under construction
// hinstance -> The instance of the process// hWnd -> handle to window (duhh :))HICON hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_ICON1));SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)hIcon); // Tell the dialog to use it
I mostly use it to set icons for dialog boxes though...
- Goblineye Entertainment
The road to success is always under construction
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement