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

4 364 0
Tài liệu Thêm Tooltip cho các control trong VISUAL C++6.0 pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

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 vcnam@fit.hcmuns.edu.vn, ndhha@fit.hcmuns.edu.vn 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. SetMaxTipWidth Sets the maximum width for a tool tip window. GetTipBkColor Retrieves the background color in a tool tip window. SetTipBkColor Sets the background color in a tool tip window. GetTipTextColor Retrieves the text color in a tool tip window. SetTipTextColor Sets the text color in a tool tip window. Activate Activates and deactivates the tool tip control. AddTool Registers a tool with the tool tip control. DelTool Removes a tool from the tool tip control. HitTest Tests a point to determine whether it is within the bounding rectangle of the given tool and, if so, retrieves information about the tool. RelayEvent Passes a mouse message to a tool tip control for processing. SetToolRect Sets a new bounding rectangle for a tool. UpdateTipText Sets the tool tip text for a tool. Update Forces the current tool to be redrawn. Pop Removes a displayed tool tip window from view. THÊM TOOLTIP CHO MT CONTROL Trong phn này, tôi ch trình bày vic thêm tooltip cho đi tng trên dialog (dialog - based) bi vì vic thêm tooltip cho các đi tng trong ch đ Document - View có th đc thc hin thông qua String Resource. Các bc thc hin : - Bc 1 : Thêm vào trong lp ca Dialog (C…Dlg) mt con tr kiu CToolTipCtrl : CToolTipCtrl* m_pToolTip; - Bc 2: Trong hàm OnInitDialog(), thêm vào các dòng lnh sau : m_pToolTip = new CToolTipCtrl; //Khai báo con tr kiu CWnd đ dùng trong vic thêm tooltip cho đi tng CWnd* pWnd; //cp b nh thành công if (m_pToolTip) { //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. BOOL CToolTipDlg::PreTranslateMessage(MSG* pMsg) { if (m_pToolTip!=NULL) { m_pToolTip->RelayEvent(pMsg); } return CDialog::PreTranslateMessage(pMsg); } Hình nh minh ha khi chy đon chng trình trên . view. THÊM TOOLTIP CHO MT CONTROL Trong phn này, tôi ch trình bày vic thêm tooltip cho đi tng trên dialog (dialog - based) bi vì vic thêm tooltip. 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

Ngày đăng: 17/02/2014, 23:20

Hình ảnh liên quan

// Ly hình ch n ht bao quanh IDOK - Tài liệu Thêm Tooltip cho các control trong VISUAL C++6.0 pdf

y.

hình ch n ht bao quanh IDOK Xem tại trang 3 của tài liệu.
Hình nh minh ha khi ch y đ on ch ng trình trên - Tài liệu Thêm Tooltip cho các control trong VISUAL C++6.0 pdf

Hình nh.

minh ha khi ch y đ on ch ng trình trên Xem tại trang 4 của tài liệu.

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan