Most Windows applications are represented by an icon. That icon image will show up when you see the program in Windows Explorer, put a shortcut on the desktop, or on the upper lefthand corner of the applications main screen. If you had not noticed, the Windows applications you have created in this chapter and the last, have icons. However, they are rather unattractive ones. Fortunately, Visual C++ makes it very easy for you to edit existing icons, or to add new ones.

If you will take a look at the last example, you will find a section in resources, where a default icon was created. It has the letters MFC on it, see Figure 16.28.

Figure 16.28: The default icon.

Visual C++ allows you to edit that image. As you can see, there are tools available much like you would find in any basic graphics software package, such as Microsoft Paint. You can use these tools to edit the existing image or create an entirely new image. To create an entirely new image, you right-click on the icon heading under resources, and then choose insert icon. You will get a blank icon, like the one shown in Figure 16.29, and you can then draw anything you like.

Figure 6.29: Drawing your own icon.

However, if your artistic skills are somewhat lacking, you may wish to use some preexisting icon. This is actually quite easy to do. If you right-click on the icon heading in resources and choose import, you will be presented with a dialog box, much like the one shown in Figure 16.30, and you can import any icon that happens to be on your computer.

click to expand
Figure 16.30: Importing existing icons.

Whether you import an existing icon, edit the default icon, or create your own icon, the problem still remains of how to associate that icon with a particular dialog. You will notice that the default icon provided for you by the application wizard, has the ID of IDR_MAINFRAME. If you will simply delete that icon and rename yours as IDR_MAINFRAME, your icon will be used. Changing your icon’s name is shown in Figure 16.31.

click to expand
Figure 16.31: Changing your icon’s ID.

Some programmers ignore details such as the application icon. You should, however, pay close attention to the details of your graphical user interface. Every detail creates an impression on the people using your application, and you want them to see a professional and polished product.

The real advantage to resources in Visual C++ lies in how they are handled when you compile your application. All the resources are actually compiled into the executable. This means that when you distribute your program, you do not have to worry about distributing the icons as well as the .exe file. The icons are already included in the executable.

C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net