Posted on 2013-03-25 09:25
盛勝 閱讀(759)
評論(0) 編輯 收藏 引用 所屬分類:
ActionScript3.0(as 3)
在VC中,也常常為一些圖片按鈕添加一些功能提示。下面講解實現(xiàn)過程:該功能的實現(xiàn)主要是用CToolTipCtrl類。該類在VC msdn中有詳細說明。
首先在對話框的頭文件中加入初始化語句:public:下,加入:CToolTipCtrl m_Mytip;
然后在初始化對話框函數(shù)中加入:
m_Mytip.Create(this);
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON), "你想要添加的提示信息" ); //IDC_BUTTON為你要添加提示信息的按鈕的ID
m_Mytip.SetDelayTime(200); //設置延遲
m_Mytip.SetTipTextColor( #0000ff ); //設置提示文本的顏色
m_Mytip.SetTipBkColor( #ffffff); //設置提示框的背景顏色
m_Mytip.Activate(TRUE); //設置是否啟用提示
然后在類向導中添加PreTranslateMessage消息響應函數(shù)
BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_MOUSEMOVE)
m_Mytip.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
注:如果要為多個按鈕添加功能提示只需在
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON), "你想要添加的提示信息" );
的下面再加上類似語句,如
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON1), "你想要添加的提示信息1" );
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON2), "你想要添加的提示信息2" );
。。。。。。。。
例子:
聲明:
CToolTipCtrl m_Tip;
初始化:
BOOL C***Dlg::OnInitDialog()
{
省略部分。。。。。。。。。。
//按鈕浮動提示
m_Tip.Create(this);
m_Tip.AddTool(&m_BtnPlay,"播放");
m_Tip.SetDelayTime(100);
m_Tip.Activate(TRUE);
}
類視圖中重寫:
BOOL C****Dlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加專用代碼和/或調用基類
m_Tip.RelayEvent(pMsg);
}