Exploring the GrabAPicture Application (Part 4)

In the previous post, Exploring the GrabAPicture Application (Part 3), you completed configuring the forms for this application. This post adds an icon to the application. Icons can be a problem because there is so much conflicting documentation about them. Some people actually go so far as to say you must create your icon in an external environment because Visual Studio doesn’t support 32-bit icon development.

One of the things I decided to experiment with is the minimum requirements for icons in Windows 7—the most demanding icon environment to date. Here are my conclusions:

 

  • You can development icons in Visual Studio without any problem.
  • Icons can be 4-bit graphics, despite what you have read elsewhere.
  • To see the icon in all Internet Explorer views, you must supply the following sizes:16×16, 32×32, 48×48, and 256×256.
  • All of the icons must appear in a separate file with a .ICO extension.

Anything else you might have heard is simply wrong. I created the icons for this example using Visual Studio with 4-bit graphics. They show up just fine in Internet Explorer, the Start Menu, the Taskbar, and everywhere else I’ve tried. I’m not much of an artist, but these icons will do just fine.

GrabAPicture0401

Now that you have an icon to use, you need to perform a number of tasks to see it.

 

  1. Save the icon to the application’s development folder on disk.
  2. Look for the icon in Solution Explorer. If you don’t see it, right click the project entry and choose Add | Existing Item from the context menu. Locate the .ICO file in the Add Existing Item dialog box and click Add.
  3. Select the icon in Solution Explorer and choose Embedded Resource in the Build Action property of the Properties window. Ensure that the Copy to Output Directory property is set to Do Not Copy.
  4. Select each form in turn and set its Icon property to the .ICO file you created. You’ll see the icon appear in the usual location in the upper left corner of the form.
  5. Right click the project entry in Solution Explorer and choose Properties from the context menu. You’ll see the project’s Property window open.
  6. Select the Application tab. In the application tab, set the Icon property to the .ICO file you created earlier. You’ll see the icon appear on the page as shown here.
    GrabAPicture0402


At this point, you can build your application and see the results. Unfortunately, Windows may not cooperate with you. You may see the original application icon. It seems that Microsoft decided to create an icon cache to make application performance faster. This cache causes problems because it stores your old icon, rather than the one you just created. The following steps will help you see your new icon (these steps will work in Windows 7 and should also work with VistaWindows XP developers will have to modify the steps to meet their needs).

 

  1. Close all copies of Internet Explorer and Windows Explorer.
  2. Right click the Desktop and choose Personalize from the context menu. You see the Personalization window.
  3. Set the theme to Windows 7 Basic. Windows changes the theme for you. Using this theme gives you access to an important feature.
  4. Click Window Color near the bottom of the Personalization window. You see the Window Color and Appearance dialog box shown here.
    GrabAPicture0403
  5. Select Icon in the Item field.
  6. Type 33 in the Size field and click Apply. This step forces Windows to clear the cache. However, the icons are now at an unusable size.
  7. Type 32 in the Size field and click OK. You’ve set the icon size back to its original size.


At this point, you should see your new icon used everywhere the application’s executable appears. Open a copy of Windows Explorer to see for yourself. If you still don’t see the new icon, close all copies of Internet Explorer and Windows Explorer manually and reboot the system. Let me know if you have any trouble with this process at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the GrabAPicture Application (Part 5).

 

Author: John

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 99 books and over 600 articles to date. The topics range from networking to artificial intelligence and from database management to heads-down programming. Some of his current books include a Web security book, discussions of how to manage big data using data science, a Windows command -line reference, and a book that shows how to build your own custom PC. His technical editing skills have helped over more than 67 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Compute magazines. He has also contributed articles to magazines such as Software Quality Connection, DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer. Be sure to read John’s blog at http://blog.johnmuellerbooks.com/. When John isn’t working at the computer, you can find him outside in the garden, cutting wood, or generally enjoying nature. John also likes making wine and knitting. When not occupied with anything else, he makes glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at John@JohnMuellerBooks.com. John is also setting up a website at http://www.johnmuellerbooks.com/. Feel free to take a look and make suggestions on how he can improve it.