How do I change icon and small icon for a windows class
-
Hi all, I was trying to change the application icon through the windows class by changing the icon macros loaded into windows class as shown below, but no matter what icon macro I choose the icon displayed is the application icon from IDI_APPLICATION macro.
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); //default Icon ... ... windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
Could please tell how to change the icons by icon macros. Any help would be greatly appriciated. Thanks Scody -
Hi all, I was trying to change the application icon through the windows class by changing the icon macros loaded into windows class as shown below, but no matter what icon macro I choose the icon displayed is the application icon from IDI_APPLICATION macro.
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); //default Icon ... ... windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
Could please tell how to change the icons by icon macros. Any help would be greatly appriciated. Thanks Scodyif you run this code
wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
what happens? From the MSDN HICON LoadIcon(HINSTANCE hInstance,LPCTSTR lpIconName); hInstance [in] Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded
WhiteSky
-
Hi all, I was trying to change the application icon through the windows class by changing the icon macros loaded into windows class as shown below, but no matter what icon macro I choose the icon displayed is the application icon from IDI_APPLICATION macro.
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); //default Icon ... ... windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
Could please tell how to change the icons by icon macros. Any help would be greatly appriciated. Thanks Scodyopen the resource header file, find the definition for the icons. Give the icon you want the smaller number. The default Icon for an exe is the first icon found (the one with the smallest number).
-
Hi all, I was trying to change the application icon through the windows class by changing the icon macros loaded into windows class as shown below, but no matter what icon macro I choose the icon displayed is the application icon from IDI_APPLICATION macro.
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); //default Icon ... ... windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
Could please tell how to change the icons by icon macros. Any help would be greatly appriciated. Thanks ScodyYou can override PreCreateWindow() to use your custom window class instead of the default... This example assumes szMyRegisteredWindowClass points to the class name associated with your "windowClass"
BOOL MyWindowClass::PreCreateWindow(CREATESTRUCT& cs)
{
// Let base class fill in the default CREATESTRUCTif( !CBaseWndClass::PreCreateWindow(cs) ) return FALSE; // Now alter CREATESTRUCT with our custom settings cs.lpszClass = szMyRegisteredWindowClass; cs.style = ; cs.dwExStyle = ; return TRUE;
}
-
if you run this code
wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
what happens? From the MSDN HICON LoadIcon(HINSTANCE hInstance,LPCTSTR lpIconName); hInstance [in] Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded
WhiteSky
Hi WhiteSky, I have just tried the code as you suggested
windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WndProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = hInstance; windowClass.hIcon = LoadIcon(windowClass.hInstance, (LPCTSTR)IDI_WINLOGO); //default Icon windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); //default arrow cursor windowClass.hbrBackground = NULL; //don't need background windowClass.lpszMenuName = NULL; // no menu windowClass.lpszClassName = "AeroClass"; windowClass.hIconSm = LoadIcon(windowClass.hInstance, (LPCTSTR)IDI_WINLOGO);
but still the default application icon is displayed. I would like to use standard icon Windows logo to be displayed on my application window, so I was using NULL in my code in the previous posting. All I want to do is change the icon on my application window to Windows logo using standard icon macro IDI_WINLOGO. Any help would be greatly appriciated. Thanks Scody