CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    25

    Visual C++ 6.0 Resource Icon ?

    I'm pretty new to Visual C++, but proficient in Microsoft 'C'. When using VC++, with a Win 32 App, I am trying to import a 16x16 icon to display at the top left of the top border next to the Application Name. After I import my .ico file as a resource, it is labelled as IDI_ICON1. But, when I put IDI_ICON1 as the argument in LoadIcon(), I get 'undeclared identifier IDI_ICON1'. Any ideas on how to get VC++ to recognize my new icon?

  2. #2
    Join Date
    Sep 2002
    Posts
    924

    Re: Visual C++ 6.0 Resource Icon ?

    Originally posted by dodge55
    But, when I put IDI_ICON1 as the argument in LoadIcon(), I get 'undeclared identifier IDI_ICON1'. Any ideas on how to get VC++ to recognize my new icon?
    How are using IDI_ICON as an argument?

    Should be:
    MAKEINTRESOURCE(IDI_ICON)

  3. #3
    Join Date
    Mar 2004
    Posts
    25

    Re:

    In the standard WinAPI shell skeleton, there is a LoadIcon(NULL,IDI_APPLICATION) which puts the standard default icon next to the Application name. I thought if I defined my own icon (.ico), I could change IDI_APPLICATION to IDI_ICON1 or whatever the resource name for my icon is.

  4. #4
    Join Date
    Sep 2002
    Posts
    924
    IDI_APPLICATION is not really a resource ID, it is name for a pre-defined icon (Default application icon).

    See LoadIcon in the Platform SDK: Windows User Interface documentation for more info.

    You can specify your own icon, but you need to use MAKEINTRESOURCE to create the value to be used for lpIconName, from your resource ID.

    Again this is explained in the docs for LoadIcon.

    LoadIcon Function

    Example:
    Code:
    wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    Last edited by RussG1; March 31st, 2004 at 11:18 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured