That's what I thought at first too, but on taking a closer look at the MAKEINTRESOURCE macro it seems that it doesn't exactly mimic a resource name:
Originally Posted by
MSDN
The MAKEINTRESOURCE macro converts an integer value to a resource type compatible with the resource-management functions. This macro is used in place of a string containing the name of the resource...The return value should be passed only to functions which explicitly indicate that they accept MAKEINTRESOURCE as a parameter."
From this I gather that it mimics a resource name, but is not quite the same thing, and can only be used where explicitly accepted (CreateWindow does not indicate its acceptance for static controls).
But just in case, here is my code:
Code:
CreateWindowEx(0, WC_STATIC, MAKEINTRESOURCE(ID_MYICON), WS_CHILD | WS_VISIBLE | SS_ICON,
x, y, 0, 0, hwnd, (HMENU)IDC_STATIC, hInst, NULL);
If it makes any difference, my only other suspicion is that, because my icon is a shared resource, the LoadIcon call being implicitly done in CreateWindow is messing up somehow, only working properly when I explicitly call LoadImage in a subsequent STM_SETIMAGE message, like so:
Code:
HWND h = CreateWindowEx(0, WC_STATIC, NULL,
WS_CHILD | WS_VISIBLE | SS_ICON,
x, y, 0, 0, hwnd, (HMENU)IDC_STATIC, hInst, NULL);
SendMessage(h, STM_SETICON,
(WPARAM)(HICON)LoadImage(hInst, MAKEINTRESOURCE(ID_MYCON), IMAGE_ICON, 32, 32, LR_SHARED), 0);