Tài liệu Thêm Tooltip cho các control trong VISUAL C++6.0 - Pdf 10



Thêm ToolTip cho các control trong
VISUAL C++ 6.0

Vn Chí Nam, Nguyn c Hoàng H
Khoa Công ngh Thông tin, trng H KHTN TP.HCM
[email protected], [email protected]
Phiên bn cp nht ngày 15/05/2005

Tooltip là mt dòng đn chú thích hin ra bên cnh control khi chut di chuyn
phía trên "khu vc" ca đi tng. Tooltip thng đc dùng nh là mt ghi chú hng
dn ngi s dng chc nng ca đi tng đang hng đn.
MFC h tr mt lp đ thc hin công vic này. ó là lp CToolTipCtrl.
GII THIU V CTOOLTIPCTRL
Các chc nng cu lp này chúng ta có th tìm hiu thêm  MSDN,  đây tôi ch
ghi li tóm tt các hàm có th dùng ca CToolTipCtrl :
Create Creates a tool tip control and attaches it to a CToolTipCtrl object.
GetText Retrieves the text that a tool tip control maintains for a tool.
GetToolInfo Retrieves the information that a tool tip control maintains about a
tool.
SetToolInfo Sets the information that a tool tip maintains for a tool.
GetToolCount Retrieves a count of the tools maintained by a tool tip control.
GetDelayTime Retrieves the initial, pop-up, and reshow durations currently set for
a tool tip control.
SetDelayTime Sets the initial, pop-up, and reshow durations for a tool tip control.
GetMargin Retrieves the top, left, bottom, and right margins set for a tool tip
window.
SetMargin Sets the top, left, bottom, and right margins for a tool tip window.
GetMaxTipWidth Retrieves the maximum width for a tool tip window.

{
//Khi to con tr Tooltip
if (!m_pToolTip->Create(this))
{
MessageBox("Khong the tao ToolTip");
OnOK();
}
/*
Nu mun thêm tooltip cho đi tng IDOK thìly con tr pWnd t IDOK
*/
pWnd = GetDlgItem(IDOK);
CRect rect;
//Ly hình ch nht bao quanh IDOK
pWnd->GetClientRect(rect);
/*Thêm vào đi tng tooltip mt tool mi*/
/* Tham s th nht : con tr ch đn đi tng cn thêm tooltip
Tham s th hai : Chui th hin trong tooltip
Tham s th ba : Hình ch nht bao quanh tooltip
Tham s th t : S hiu cu tool trong tooltip control (IDTool)
*/
m_pToolTip->AddTool(pWnd,"Bam vao day de
thoat",rect,1);
}

- Bc 3 : Thêm vào lp CTamDlg hàm PreTranslateMessage, hàm này có tác
dng x lý thông đip trc khi gi đn ca s. Thông đip phi đc đa đn cho tooltip
control trc. Dùng hàm RelayEvent cu CToolTipCtrl đ làm công vic x lý thông đip
cho tooltip.


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status