GDI+ Objects: Icons |
|
Practical Learning: Creating Icons |
Using an Icon |
To support icons, the GDI+ library provides the Icon class. To use an icon in your application, you can first declare a pointer to Icon using one of the class' constructors. If the icon is stored in a file, the simplest constructor to use it has the following syntax: public: Icon(String *filename); With this constructor, the name or path to the icon file is passed as argument. After creating the icon, if you want to use only one size version, you can use one the following constructors to declare the variable: public: Icon(Icon *original, Size size); public: Icon(Icon *original, int width, int height); After initializing an Icon variable, if you want to get its dimensions, you can access its Width and its Height properties, or its Size property. As mentioned already, there are various ways an icon can be used. For example, you can display it in a control by drawing it. To do this, you can call the Graphics::DrawIcon() method which is overloaded with two versions: public: void DrawIcon(Icon *icon, Rectangle targetRect); public: void DrawIcon(Icon *icon, int x, int y); The first version allows you to specify the location and dimensions of the icon. The second version allows you to specify only the location of the icon. |
Practical Learning: Using an Icon |
private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e) { Drawing::Icon *icoMain = new Drawing::Icon(S"Diamond.ico"); this->Icon = icoMain; } |
|
||
Home | Copyright © 2004-2010 FunctionX, Inc. | |
|