CMFECToolTip m_toolTip;//声明对象
BOOL CMouseInfoTipDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_toolTip.Create( this );//创建提示框对象
CStringArray straInfo;
//“添加”按钮提示框
straInfo.RemoveAll();
straInfo.Add( "向列表框中添加记录" );
m_toolTip.AddControlInfo( IDC_ADD, straInfo, RGB(220,174,208), RGB( 0,0,162) );
//退出按钮提示框
straInfo.RemoveAll();
straInfo.Add( "关闭窗口" );
m_toolTip.AddControlInfo( IDCANCEL, straInfo, RGB(220,174,208), RGB( 0,0,162) );
//编辑框提示框
straInfo.RemoveAll();
straInfo.Add( "输入书籍名称" );
m_toolTip.AddControlInfo( IDC_EDIT1, straInfo, RGB(220,174,208), RGB( 0,0,162) );
//列表框提示框
straInfo.RemoveAll();
straInfo.Add( "显示添加的图书记录" );
straInfo.Add( "实现自动排序:" );
m_toolTip.AddControlInfo( IDC_LIST1, straInfo, RGB(220,174,208), RGB( 0,0,162) );
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CMouseInfoTipDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message == WM_MOUSEMOVE )//鼠标移动
{
POINT pt = pMsg->pt;
ScreenToClient( &pt );//转换为客户区坐标
m_toolTip.ShowToolTip( (CPoint)pt );//显示提示框
}
return CDialog::PreTranslateMessage(pMsg);
}