Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

makeintresource/LoadIcon fails in ATL dll

365 views
Skip to first unread message

Gernot Frisch

unread,
Aug 13, 2002, 3:04:07 AM8/13/02
to
Hello,

I've got a ATL/COM dll that has an icon: IDI_RED. I used this icon in the
dialog editor and it works. Now I want to load it with:
AfxGetApp()->LoadIcon(IDI_RED);
but it fails. When I trace inside it seems that a call to MAKEINTRESOURCE
returns 0x00000e = "" as string. This seems really strange. Any ideas?

Thank you,

Gernot

__________________________
DREAM DESIGN ENTERTAINMENT
http://www.Dream-D-Sign.de
__________________________


Gernot Frisch

unread,
Aug 13, 2002, 5:07:46 AM8/13/02
to

"Gernot Frisch" <Gernot...@no.spam.Dream-D-Sign.de> schrieb im
Newsbeitrag news:ajaarv$19dhsa$1...@ID-37212.news.dfncis.de...

> Hello,
>
> I've got a ATL/COM dll that has an icon: IDI_RED. I used this icon in the
> dialog editor and it works. Now I want to load it with:
> AfxGetApp()->LoadIcon(IDI_RED);
> but it fails. When I trace inside it seems that a call to MAKEINTRESOURCE
> returns 0x00000e = "" as string. This seems really strange. Any ideas?

icon=LoadIcon(NULL, MAKEINTRESOURCE(IDI_RED));

returns this error:

1813 The specified resource type cannot be found in the image file.
ERROR_RESOURCE_TYPE_NOT_FOUND


Has this to do with ATL and / or DLL instead of usual exe program?

Thank you,
Gernot


Gernot Frisch

unread,
Aug 13, 2002, 5:26:45 AM8/13/02
to

"Gernot Frisch" <Gernot...@no.spam.Dream-D-Sign.de> schrieb im
Newsbeitrag news:ajai41$19v1ks$1...@ID-37212.news.dfncis.de...

... and this works!
icon = ((CStatic*)(GetDlgItem(IDC_STATIC_RED)))->GetIcon();

Ah - come on! What is going on here? I'm really desperated now.

Gernot.

Tim Robinson

unread,
Aug 13, 2002, 5:52:50 AM8/13/02
to
Gernot Frisch <Gernot...@no.spam.Dream-D-Sign.de> wrote:
| icon=LoadIcon(NULL, MAKEINTRESOURCE(IDI_RED));
|
| returns this error:
|
| 1813 The specified resource type cannot be found in the image
| file. ERROR_RESOURCE_TYPE_NOT_FOUND
|
|
| Has this to do with ATL and / or DLL instead of usual exe program?

Check the HINSTANCE parameter to LoadIcon. NULL refers to the main EXE;
anything else refers to a particular DLL. You obtain the HINSTANCE to your
DLL in DllMain, or through the _Module object in ATL
(_Module.GetResourceInstance() works).

--
Tim Robinson
http://www.themoebius.org.uk/

Gernot Frisch

unread,
Aug 13, 2002, 6:12:12 AM8/13/02
to
Wohooo! Yes, that was it!

Also I've got a problem: when I close the dialog, which I inserted
afterwards in my ATL Dll (using CMyDlg d; d.DoModal()) after the window
closes the function CDialog::DestroyWindow fails here:
ASSERT(m_hWnd == hWndOrig);

But when I compile a release version it does not make any difference - so
why bother. But it would be nice if you know a solution to this as well...


Anyway thank you very very much,
Gernot.

"Tim Robinson" <t...@gaat.freeserve.co.uk> schrieb im Newsbeitrag
news:ajakpg$19km6b$1...@ID-103400.news.dfncis.de...

joan...@gmail.com

unread,
Jan 30, 2014, 3:14:57 AM1/30/14
to
Use s_hInstanceDll instead of HINSTANCE hInst = AfxGetInstanceHandle(); or NULL

example


#if (_ATL_VER >= 0x0700)
HINSTANCE s_hInstanceDll = ATL::_AtlBaseModule.GetResourceInstance();
#else // !(_ATL_VER >= 0x0700)
HINSTANCE s_hInstanceDll = _Module.GetResourceInstance();
#endif // !(_ATL_VER >= 0x0700)





hBitmap = HBITMAP( ::LoadImage( s_hInstanceDll,
MAKEINTRESOURCE( IDB_BITMAP_NO_VIDEO ),IMAGE_BITMAP,0,0,
/*LR_LOADFROMFILE|*/LR_CREATEDIBSECTION ) );



Deanna Earley

unread,
Jan 30, 2014, 4:20:37 AM1/30/14
to
On 30/01/2014 08:14, joan...@gmail.com wrote:
> Use s_hInstanceDll instead of HINSTANCE hInst = AfxGetInstanceHandle(); or NULL

If you're going to reply to a thread from over a decade ago, at least
quote some context please.

--
Deanna Earley (dee.e...@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be printed, shredded then fed
to the rats. Please reply to the group.)
0 new messages