Under Windows 11, I'm writing a small application which may be opened by some file types like .jpg or .heic, meaning that it may change the default selected application for these types.
The application is created with Visual Studio 2019, and it contains its own icon, which I declared in the following manner:
MyApp.rc
#include "resource.h"
#include "windows.h"
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APPICON ICON "MyAppIcon.ico"
IDI_SMALL ICON "MyAppIcon.ico"
Resources.h
#define IDI_APPICON 100
#define IDI_SMALL 101
main.cpp
...
// resources
#include "resource.h"
...
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
...
WNDCLASSEX wcex = {0};
BOOL bQuit = FALSE;
// register window class
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_OWNDC;
wcex.lpfnWndProc = WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = ::LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
wcex.hIconSm = ::LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SMALL));
wcex.hCursor = ::LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"MyAppClassName";
if (!RegisterClassEx(&wcex))
return 0;
// create main window
g_hWnd = ::CreateWindowEx(0,
L"MyAppClassName",
L"My Application",
WS_DLGFRAME | WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
800,
650,
nullptr,
nullptr,
hInstance,
nullptr);
::ShowWindow(g_hWnd, nCmdShow);
...
}
The .ico file contains the following sizes: 16x16, 32x32, 48x48, 256x256
My application shows the icon correctly everywhere (header, taskbar, uninstall list, ...) except in one location: the Default File Association, and its relative settings, as shown in the below screenshot:
I cannot figure out what is wrong. Can someone explain me why my icon isn't visible only at this location?