I have a problem with loading icons from external resource files in main application. I'll try to explain how application is set right now. The resources of the main application includes external dialog *.rc and appropriate *.h. And linker includes dialog implementation (CDialog/CFormView) which resides in external static library *.lib.
External *.rc has:
IDI_MY_ICON ICON "my_icon.ico"
External *.h has:
#define IDI_MY_ICON 10000
Dialog implementation in static lib *.cpp has:
HICON MyDialog::GetNeededIcon()
{
return AfxGetApp()->LoadIcon(IDI_MY_ICON);
}
I thought that it should reside in the same folder as external *.rc file is. I also tried to place them in the main app folder, but application still doesn't load them. Could someone explain me where my_icon.ico is searched in?
P.S. - Contents of files are only examples here.
AfxGetApp()->LoadIcon(IDI_MY_ICON); tries to load the icon from the current app (exe).
If you want to load it from another module, you will either have to remember the handle returned from LoadLibrary, or call GetModuleHandle to retrieve it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With