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

ICON will not load

143 views
Skip to first unread message

Robert Paul Dyer

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
When I attempt to load an icon from the resource file
using the Win32 function ::LoadIcon, it fails. I use
this code for the function call:

hIcon = LoadIcon(NULL,
MAKEINTRESOURCE(IDR_MAINFRAME));

Note that other resources like a dialog box, and the
accelerator table load just fine. Incidentally,
I am using a different entry point than WinMain to
make my program as small as possible. However after
switching back to use WinMain I had the same problem.

GetLastError gives error code 1814, which is described here:

1814 The specified resource name cannot be found in the image file.
ERROR_RESOURCE_NAME_NOT_FOUND

The icon with the symbol IDR_MAINFRAME IS in the image file --
that is of course the resource file, so this error code does not
make any sense to me.

Any ideas on how to troubleshoot this further? I get precisely the
same error when I call ::FindResource instead of ::LoadIcon.
I can see no reason whatsoever why this icon should not be loading.
The icon is in the resource file, and other resources load without any
problem.

Thanks,
Robert Paul Dyer
.


William DePalo [MVP]

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
Robert Paul Dyer wrote in message <35F6E4C9...@pobox.com>...
>
> hIcon = LoadIcon(NULL,
> MAKEINTRESOURCE(IDR_MAINFRAME));

>
>GetLastError gives error code 1814, which is described here:
>
>1814 The specified resource name cannot be found in the image file.
>ERROR_RESOURCE_NAME_NOT_FOUND

You say the icon exists, Windows says it does not. The only way you can both
be write in a rational world is if IDR_MAINFRAME is different in your source
than in the resource script.

I think it is politically incorrect but I detest the MAKEINTRESOURCE()
macro. I always name the resources and pass string names to the function.

Regards,
Will

Jamie

unread,
Sep 14, 1998, 3:00:00 AM9/14/98
to
Hi, to make sure it is in their open up the EXE in the resource
compiler and see if the Icon is there, and it has the correct
identifier. It maybe the wrong size, some icons require LoadImage if
it's not the standard Icon size.

Hope this helps

Jamie O'Brien
jam...@interworx.com.au


Strohm Armstrong

unread,
Sep 15, 1998, 3:00:00 AM9/15/98
to
By passing NULL as the HINSTANCE, you are telling LoadIcon to get the icon
from the system. The system doesn't have an IDR_MAINFRAME icon. You need to
pass your application's instance handle to LoadIcon.

Robert Paul Dyer wrote in message <35F6E4C9...@pobox.com>...

>When I attempt to load an icon from the resource file
>using the Win32 function ::LoadIcon, it fails. I use
>this code for the function call:
>
> hIcon = LoadIcon(NULL,
> MAKEINTRESOURCE(IDR_MAINFRAME));
>
>Note that other resources like a dialog box, and the
>accelerator table load just fine. Incidentally,
>I am using a different entry point than WinMain to
>make my program as small as possible. However after
>switching back to use WinMain I had the same problem.
>

>GetLastError gives error code 1814, which is described here:
>
>1814 The specified resource name cannot be found in the image file.
>ERROR_RESOURCE_NAME_NOT_FOUND
>

0 new messages