Placing a Bitmap Picture on the Picture Box

 

Project ProjectIcon

It is time to color the icon, using the tools in the Icon Editor. At this point, you have a 32 by 32 area in which to create the icon, but no colors to work with. If there is no color palette displayed at the far left of the IDE, you must bring one into the IDE.

  1. Right-click on the Image item on the main menu. Click on the Show Colors Window to place the color palette into the IDE (you only have to do this once in the lifetime of the compiler).

  2. There are many tools presented in the colors toolbar at the top of the IDE (two rows below the main menu), but the tool that you need right now is the pencil tool, which is the first icon to the right of the magnifying glass. Click on the pencil tool so you can color the pixels in the icon one at a time. (Or you can drop the pencil tool on a particular pixel and hold the left mouse button down to place the same color on every pixel that you pass over.) Now move the pencil tool cursor to the color palette to select a color. Once the pencil tool appears over a particular color, clicking once on the left mouse button places that color in the pencil tool.

    You can paint the icon using any colors you want. Figure 24-2 is a 32 by 32 pixel KT icon in the colors blue, black, and yellow. (B is black, + is blue, and Y is yellow.)

    image from book
    Figure 24-2: Layout for 32 — 32 KT icon

  3. When you have colored all the pixels in the KT icon, Save All in the project and return to the main window (Form1) template. Now you must make the connection between the icon (Icon1.ico) and the PC operating system (so the icon can be used as a shortcut to the project on the PC desktop).

  4. Move to the Solution Explorer window at the top right of the IDE. Double-click on Properties (under Project Icon) to bring up the following window in the center of the IDE:

    image from book
    Figure 24-3: Property pages

  5. When this window opens, the (Default Icon) setting appears in the Resources area (at the center of the window). There will be no picture of an icon to the left of the setting. Click on the down arrow at the right edge of the Icon list box. Click on the Browse icon at the far right edge of the Icon list box to open an Add existing file to project window. You must use this window to navigate to the icon file in this project (at C:\Visual Studio2005\Projects\DemosSourceCode\ProjectIcon).

    The list of files in the Add existing file to project window will look like Figure 24-4.

    image from book
    Figure 24-4: Add existing file to project window

  6. Double-click on Icon1.ico to place the icon into the project. Immediately a small picture of the icon will appear to the left of the Icon text box. The icon is now a permanent part of this project. If someone chooses to create a shortcut icon to this project later, this is the icon that will appear.

Version 2.0 of the Visual Studio C# compiler embeds this icon into the executable (ProjectIcon.exe in this case), so the icon file, Icon1.ico, need not be transported along with the ProjectIcon.exe executable to other PCs. Version 1.0 required that the programmer keep the icon file in the same directory as the executable, but the version 2.0 architects removed this impediment.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

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