如何获得CTabCtrl类标签上的文字信息?急用!急用!急用!急用!急用!

zhihuizhilv 2005-10-25 12:00:53
如何获得CTabCtrl类标签上的文字信息?
在tab控件的应用中,我需要获得标签上的标题信息,想通过TCITEM结构中的 item.pszText得到,但没有成功,请问如何实现。谢谢!急用!
...全文
313 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
kenskens 2005-10-25
  • 打赏
  • 举报
回复
TCHAR szBuf[256];
TCITEM item;
item.mask = TCIF_TEXT;
item.pszText = szBuf;
item.cchTextMax = sizeof(szBuf)/sizeof(TCHAR);

m_tbCtr.GetItem(m_tbCtr.GetCurSel(), &item);
SetDlgItemText(IDC_EDIT2, szBuf);
gunney 2005-10-25
  • 打赏
  • 举报
回复
Retrieves information about a tab in a tab control.
BOOL GetItem(
int nItem,
TCITEM* pTabCtrlItem
) const;
Parameters
nItem
Zero-based index of the tab.
pTabCtrlItem
Pointer to a TCITEM structure, used to specify the information to retrieve. Also used to receive information about the tab. This structure is used with the InsertItem, GetItem, and SetItem member functions.
Return Value
Returns TRUE if successful; FALSE otherwise.
Remarks
When the message is sent, the mask member specifies which attributes to return. If the mask member specifies the TCIF_TEXT value, the pszText member must contain the address of the buffer that receives the item text and the cchTextMax member must specify the size of the buffer.
mask
Value specifying which TCITEM structure members to retrieve or set. This member can be zero or a combination of the following values:
TCIF_TEXT The pszText member is valid.
TCIF_IMAGE The iImage member is valid.
TCIF_PARAM The lParam member is valid.
TCIF_RTLREADING The text of pszText is displayed using right-to-left reading order on Hebrew or Arabic systems.
TCIF_STATE The dwState member is valid.
pszText
Pointer to a null-terminated string containing the tab text if the structure contains information about a tab. If the structure is receiving information, this member specifies the address of the buffer that receives the tab text.
cchTextMax
Size of the buffer pointed to by pszText. This member is ignored if the structure is not receiving information.
iImage
Index into the tab control's image list, or – 1 if there is no image for the tab.
lParam
Application-defined data associated with the tab. If there are more than four bytes of application-defined data per tab, an application must define a structure and use it instead of the TCITEM structure. The first member of the application-defined structure must be a TCITEMHEADERstructure. The TCITEMHEADER structure is identical to the TCITEM structure, but without the lParam member. The difference between the size of your structure and the size of the TCITEMHEADER structure should equal the number of extra bytes per tab.
Example
// In this example a CTabCtrl data member, m_tabCtrl, changes the
// text of the tabs in the tab control. A call to GetItem is used
// to get the current text, and then the text is changed. A call
// to SetItem is used to update the tab with the new text.

void CDialogDlg::OnChangeItem()
{
TCITEM tcItem;
CString pszString;

// Get text for the tab item.
GetDlgItemText(IDC_ITEM_TEXT, pszString);

// Get the current tab item text.
tcItem.mask = TCIF_TEXT;
m_tabCtrl.GetItem(0, &tcItem);

// Set the new text for the item.
tcItem.pszText = pszString.GetBuffer(256);

// Set the item in the tab control.
m_tabCtrl.SetItem(0, &tcItem);

}
goodboyws 2005-10-25
  • 打赏
  • 举报
回复
tcItem.mask = TCIF_TEXT;
m_tabCtrl.GetItem(0, &tcItem);
zhihuizhilv 2005-10-25
  • 打赏
  • 举报
回复
谢谢各位,问题解决!

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧