Sunday, March 27, 2011

Using Own Icon In the Application ( .exe)

First you must provide your icon for your program. You can either use one of the collection included with VFP or create your own. To use one of the included ones, check out the graphics directory on your computer. For example, with the default installation of VFP6, the directory is "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\".

To create your own icons, you need an icon creation utility. Gimp or IconForge is very powerfull image processing application to make any icons.

The images used for application icon must be 16 colors only. If you use 256 colors, the FoxPro logo icon will be shown instead of your own. You must also include the correct size images in the icon.

An icon file can contain several images with different sizes. Windows selects the appropriate size to display the file. For example, if you are browsing a folder with Windows Explorer and you have your view set to "list" or "details", you will see the small version of the icon. However, if you're view is set to "icons" or "thumbnails", you will see a larger version. For VFP .exe files, you must create an icon with 16x16 and 32x32 pixels sizes.

When your icon is ready, then you must add it into your project. Click on the "Other" tab in the Project Manager window, click on "other files" and click on the "Add" button. Select "icon" from the file type drop-down then select the icon file and click on "OK".

Next add the icon to the .exe file. While your project is open, Press Ctrl-J to open the Project Properties Information box. Make sure to check the "Attach icon" check box and click on the "Icon" button to browse. Now use the Open box to select your own icon.

If you would like to change the title bar icon in Windows with that icon, add this code to the main program of your application project:

_screen.icon=".ICO"
Compile your project into .exe then browse the folder containing the compiled file in Windows Explorer to see how the icon looks.