It's correct in my code, just mistyped it here.
passed to DllMain.
Still, the global LoadImage succeeds while class version fails.
Lisa Pearlson <no@spam.plz> wrote:
As for the LoadIcon one.. no, it's not the reason for the problem..
but it is strange to me why following occurs, which may be related:
CSomeClass
{
CSomeClass(HINSTANCE hInstance) { m_hInstance = hInstance; };
virtual ~CSomeClass(){};
HINSTANCE m_hInstance;
HICON LoadIcon(UINT nID) {
return (HICON)LoadImage(m_hInstance,
MAKEINTRESOURCE(IDI_APP_ICON),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
Is it your intention that LoadIcon ignore its parameter and use a
hard-coded ID of IDI_APP_ICON instead?
// exported func
void SomeExportedFunc()
{
CSomeClass* p = new CSomeClass(g_hInstance);
HICON hIcon;
// this FAILS
hIcon = p->LoadIcon(IDI_ICON);
// this SUCCEEDS
hIcon = (HICON)LoadImage(m_hInstance,
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON,
16, 16, LR_DEFAULTCOLOR);
What's m_hInstance? As far as I can tell, it's an undeclared identifier at
this point.
As to why p->LoadIcon fails and LoadImage succeeds, note that the two
calls pass different IDs to LoadImage. Could it be that IDI_APP_ICON is
not a valid ID, while IDI_ICON is?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925