Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:29:34+00:00 2026-05-14T15:29:34+00:00

(I’m using Visual Studio 2008, though I remember having similar problems with older versions

  • 0

(I’m using Visual Studio 2008, though I remember having similar problems with older versions as well.)

I’ve tried several different methods (many of them mentioned in this other question), but I am still having some strange issues:

  1. When including an icon as a resource, it does show up as the executable file’s icon immediately, but for the icon to show up on the taskbar, I have to restart the computer. Until then, it continues to show up as whatever the previous icon was. Cleaning the solution, restarting VS, doesn’t have any effect. Not a really big issue, as it won’t affect a released exe, but it would be nice to know where it’s keeping the old icon cached and how to get rid of it.

  2. No matter what I do, the icon displayed when alt-tabbing is the default app icon (square and white and generic). This includes embedding the icon in the executable, as well as setting ICON_BIG with WM_SETICON.

As for the second matter, my code looks something like:

   hIcon = (HICON)(
      LoadImage( NULL, szFilename, IMAGE_ICON, 32, 32, LR_LOADFROMFILE ) );
   if( hIcon )
      SendMessage( hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon );

However, after sending WM_SETICON, GetLastError() returns 6, “The handle is invalid.”. hWnd is a valid window handle, and hIcon appears to be a valid icon handle. I’ve tried searching for reasons why WM_SETICON could cause that error, and at the very least, to figure out WHICH handle it thinks is invalid, but no luck yet. I’ve cleared the error code immediately before calling SendMessage(), so it has to be set somewhere in the processing of the message.

I tried an alternate method, loading the icon from the exe itself, where the ID of the resource is 101 (it’s the first and only resource included):

   hIcon = (HICON)(
      LoadImage( GetModuleHandle( NULL ), MAKEINTRESOURCE( 101 ),
      IMAGE_ICON, 48, 48, 0 ) );
   if( hIcon )
      SendMessage( hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon );

… but the same thing happens; after calling SendMessage(), GetLastError() gives the same error status.

I’ve tried different dimensions (such as 48×48, all of which are present in the icon file), but to no different effect. I know it’s definitely finding and loading the images, because if I specify a size that doesn’t exist or an invalid resource ID or the wrong filename (depending on how I am loading it), it fails out long before SendMessage().

Strangely, if I specify ICON_SMALL instead of ICON_BIG, the call succeeds with no error status, but from the docs, I need to use ICON_BIG to set the icon used while alt-tabbing. Also, if I use ICON_BIG but load the 16×16 icon, I get no error status, but nothing changes.

Any ideas about what could be causing WM_SETICON to fail? Anything terribly wrong with any of the code I’ve posted (aside from formatting/style/casting issues, as it’s simplified to just the basics)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:29:35+00:00Added an answer on May 14, 2026 at 3:29 pm

    I’ve revisited this to see if I can close out my question. I have been unable to get the app’s icon to show up in the alt-tab list just through embedding it in the executable; it will show up in the taskbar, as the file’s icon in Explorer, and elsewhere just fine.

    I figured I’d try something simpler for setting the icon manually, and went with LoadIcon() instead, as the code below shows:

    HICON hIcon = LoadIcon( GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1) );
    if( hIcon )
    {
       SendMessage( GetHandle(), WM_SETICON, ICON_BIG, (LPARAM)hIcon );
       DestroyIcon( hIcon );
    }
    // ... Same for ICON_SMALL
    

    This seems to have done the trick. I really don’t know why, but so far it’s the only change that had any effect. It’s really not an issue I should spend any more time on, so I’ll just go with this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Let me guess, you are using xampp oder zend server… May 15, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer I think you probably meant "ASP.NET MVC" technology when you… May 15, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer You can't solve this problem by examining only the URL.… May 15, 2026 at 8:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.