Although it would have been a tad more useful if he showed adding your own icon as the application icon as that's the more common case then sticking it in a picture box.-MilesAhead
Perhaps he followed the MSVS resource editors behavior a bit too closely, as I've always found it to be a bit of a PITA for much the same reason.
-Stoic Joker
Heh. As soon as I wrote that it prompted me to look at his one liner for setting the dialog icon again. I got it to work by using the same trick MS programmers do in the win32 template. Copy hInstance given in WinMain to the global
hInst. Then just use MAKEINTRESOURCE macro for my custom icon id. More elegant than the use of LoadImage as shown in the MSDN example.
Instead of his init dialog line
SetClassLongPtr(hDlg, GCLP_HICON, (long)LoadIcon(0, IDI_APPLICATION));
I just used
SetClassLongPtr(hDlg, GCLP_HICON, (long)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON)));
bah... I hate making all the newb mistakes all over again though. Not linking with MT switch and getting dll dependency booby trapped all over again!!
But at least it's a way of doing stand-alone exe with a gui editor that emits pretty small code for small utils.