VC Programming Program Control Parts Class Htcontrol Chtgdimanager GDI resource management Class usage parsing _c language

Source: Internet
Author: User

This paper mainly introduces the VC programmable control parts Class Htcontrol Chtgdimanager GDI resource Management Class Usage, MFC provides the CBitmap class LoadBitmap interface can only obtain the bitmap from the exe inside, but in many cases need to obtain from the EXE outside, The Chtgdimanager class provides an interface for obtaining bitmaps from outside the EXE, using the following methods:

M_hbmpbtnclosenormal = M_htgdimanager.getbitmap (_t (". \\pic\\btn_close_normal.png"));

#if!defined (__chtgdimanager_h__) #define __CHTGDIMANAGER_H__ class Afx_class_export Chtgdimanager {Public:chtgdimana
 Ger (void);
~chtgdimanager (void); /****************************************************************************
| function function: Get bitmap from File | | Input Parameters: | | Szpicpath: Picture file path | | Prect: Take a part of the picture null means to take the whole picture | | Output parameters: none | | Return value: Successfully returned bitmap handle failed return Null | |
Description: This type of destructor deletes this bitmap, and the user does not have to delete | /Hbitmap Getbitmap (tchar* Szpicpath,
rect* prect = NULL); /****************************************************************************
| function function: Get bitmap from resources | | Input Parameters: | | IPICID: Resource ID | | Prect: Take a part of the picture null means to take the whole picture | | Output parameters: none | |             Return value: Successfully returned bitmap handle failed return null    |
|
Description: This type of destructor deletes this bitmap, and the user does not have to delete | /hbitmap getbitmap (int ipicid, rect*
Prect = NULL); /****************************************************************************
| function function: Get the specified font | | Input Parameters: | | Lheight: Font Size | | Lweight: Coarse Degree | | Szfacename: Font name | | Bunderline: Whether with bottom horizontal line | | Bitalic: Italic | | Output parameters: none | | Return value: Successful return of font handle failed return Null | |
Description: This type of destructor deletes this font, the user does not have to delete | /Hfont GetFont (Long lheight, long
 Lweight, tchar* szfacename, bool Bunderline = FALSE, bool Bitalic = false);
 void Deletebitmap (Hbitmap hbitmap);
 void Deleteallbitmap (Hbitmap hbitmap);
 void Deletefont (Hfont hfont); void DeletealLfont (Hfont hfont);
 private:hbitmap* M_hbitmap;
 hfont* M_hfont;
 int m_ibitmapindex;
 int m_ifontindex;
 int m_ibitmapcount;
int m_ifontcount;
};

 #endif//!__chtgdimanager_h__

MFC provides encapsulation classes for a variety of GDI objects, and many custom WIN32 APIs developed (SDK development) may not like to use these classes (anyway, I don't like to use them, personally think these classes are not very good encapsulation), but rather used to use the API directly to create, In many cases, you will need to use the handles of these GDI objects directly. The revocation of the GDI object, which is undone when the GDI object is used to prevent resource leaks. Chtgdimanager revokes all GDI objects created by the class destructor, and the user does not need to undo it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.