I have a .ico file that I’ve imported into my Visual Studio 2010 project. Within the .ico file, it looks like there are many different images of different sizes.
I am trying to set one of them as the icon for my button control:
HICON hIcon = LoadIcon(HINST_THISCOMPONENT, MAKEINTRESOURCE(IDI_ICON2));
SendMessage(GetDlgItem(hDlg, IDC_BUTTON1), BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
How do I choose which image/size within the .ico file will be displayed on the button?
You can use the
LoadImagefunction to get a bit more control.With
LoadImageyou can specify a desired width and height.If you want even more control then you’re down to parsing the icon resource, which I don’t recommend.