In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use label controls in VC5, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
In VC5, label controls are supported by the CTabCtrl class. To make a label control, there are mainly the following steps:
First, add TABCTRL (such as MYTABCTRL) to the dialog box of the ResourceView tab (the second item of the label control on the left of VC5).
Second, associate a CTabCtrl variable (such as mytab) with the newly added label control in ClassWizard.
Third, add items to the label control.
Fourth, at this point, a label control is done. Now you can use ClassWizard to add a message mapping to the label control.
The following focuses on how to add items to a label control.
The CTabCtrl class has a member function, InsertItem, whose prototype is:
BOOL InsertItem (int nItem,TC_ITEM*pTabCtrlItem)
The first parameter is the sequence number of the added project, which will be returned when another member function of CTabCtrl, GetCurSel (), is called. Corresponding to GetCurSel () is SetCurSel (int nItem), and the SetCurSel function changes the item currently selected by the label control, where nItem is the serial number of the item.
The key to InsertItem lies in the second parameter, PTabCtrlItem. This is a pointer to the TC_ITEM structure.
The TC_ITEM structure is defined as follows:
Typedef struct_TC_ITEM
{
Type of UINT mask; / / label control
UINT lnReserved1; / / VC reserved, do not use
UINT lnReserved2; / / VC reserved, do not use
Project text of the LPSTR pszText; / / label control
Length of int cchTextMax; / / pszText
Graphic serial number of int iImage; / / label control
LPARAM lParam; / / data for exchange
} TC_ITEM
In programming, only three member variables, mask, pszText, and iImage, are often used.
1.mask
Specifies the type of label control. It can be the following three values:
TCIF_TEXT pszText member is valid
TCIF_IMAGE iImage member is valid
TCIF_PARAM iParam member is valid
If you want to use multiple attributes, you should connect with bitwise or operator "|". For example, to make pszText and iImage members valid at the same time, use TCIF_TEXT | TCIF_IMAGE as the value of mask.
2.pszText
The item text of the label control, which can be assigned a string value directly. The type of the label control must have TCIF_TEXT at this time.
3.iImage
The graphic serial number of the label control, which is a member variable that must be used to add graphics to the label control. This label control must have a TCIF_IMAGE.
When assigning values, you only need to assign values to these three (sometimes two) variables.
Here is an introduction to the use of iImage.
What is stored in iImage is the drawing serial number of the project. The graphics corresponding to this serial number (possibly icons and bitmaps) will be displayed to the left of the item text of the label control. These shapes can be of any size, but they must be the same size.
The iImage of each item of the label control forms a sequence, and the graphics corresponding to this sequence are managed by another class CImageList. Let's take a look at the usage of CImageList.
When I use CImageList, I only use the following member functions:
1.BOOL Create (int cx,int cy,UINT nFlags,int nInitial,int nGrow)
This function creates an empty CImageList; with nGrow graphs (each graph is cx long, and the cy height takes nInitial as the initial value: usually 0). It has a nFlages parameter, which is used to specify the color attribute of the graph, and its value can only be one of the following values:
ILC_COLOR uses the default color (usually 16 colors)
ILC_COLOR4 uses 4-bit colors (16 colors)
ILC_COLOR8 uses 8-bit colors (256 colors)
ILC_COLOR16 uses 16-bit colors (64K colors)
ILC_COLOR24 uses 24-bit colors (16m colors)
ILC_COLOR32 uses 32-bit colors (4G colors)
ILC_COLORDDB uses the system's current color
2.BOOL Create (UINT nBitmapID,int cx,int nGrow,COLORREF crMask)
This function creates a CImageList with nGrow graphics (each cx) based on the bitmap represented by nBitmapID (defined in the rc file, similar to the bitmap that defines the toolbar).
Where crMask specifies what color in the bitmap will be replaced with black, which is usually black (RGB (0mem0re0)).
3.int Add (CBitmap*pbmImage,COLORREF crMask)
This function appends a bitmap to CImageList. NbmImage can be obtained by defining a CBitmap pointer and then using LoadBitman, a member of CBitmap. For example:
CBitmap*mvbitmap
Mvhitmap=new CBitmap ()
Mvbitmap- > LoadBitmap (MYPICTURE); / / MYPICTURE is the defined bitmap resource crMask parameter as before.
4.int Add (HICON hIcon):
This function appends an icon to the CImageList.
HIcon can be obtained with AfxGetApp ()-> LoadIcon (UINT nIDResource). For example: AfxGetApp ()-> LoadIcon (MYICON); / / where MYICON is the defined icon resource. When CImageList is customized, call SetImageList, the member function of CTabCtrl. The prototype is as follows:
CImageList*SetImageList (CImageList*pImageList)
The pImageList is the pointer to the CImageList object we just customized, and the previous iImage parameter is the graphic serial number in CImageList. In this way, a label control with graphics is done.
The above is all the content of the article "how to use label controls in VC5". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.