Article ID: 141758
Article Last Modified on 11/21/2006
CAboutDialog::PreTranslateMessage(MSG* pMsg)
{
if (NULL != m_pToolTip)
m_pToolTip->RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
} class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CButton m_btOK;
//}}AFX_DATA
CToolTipCtrl* m_pToolTip;
//...
}; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
m_pToolTip = NULL;
}
CAboutDlg::~CAboutDlg()
{
delete m_pToolTip;
} BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//Set up the tooltip
m_pToolTip = new CToolTipCtrl;
if(!m_pToolTip->Create(this))
{
TRACE("Unable To create ToolTip\n");
return TRUE;
}
if(m_pToolTip->AddTool(this, "About Box"))
{
TRACE("Unable to add Dialog to the tooltip\n");
}
if (m_pToolTip->AddTool(&m_btOK,"OK Button"))
{
TRACE("Unable to add OK button to the tooltip\n");
}
m_pToolTip->Activate(TRUE);
return TRUE;
} class CTooltipsApp : public CWinApp
{
//...
public:
HWND m_hwndDialog;
CToolTipCtrl* m_gpToolTip;
//...
}; CTooltipsApp::CTooltipsApp()
{
m_hwndDialog = NULL;
m_gpToolTip = NULL;
} BOOL CTooltipsApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
if (m_hwndDialog != NULL)
if (lpMsg->hwnd == m_hwndDialog ||
::IsChild(m_hwndDialog, lpMsg->hwnd))
{
if (NULL != m_gpToolTip)
m_gpToolTip->RelayEvent(lpMsg);
}
return CWinApp::ProcessMessageFilter(code, lpMsg);
} class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CButton m_btOK;
//}}AFX_DATA
CToolTipCtrl* m_pToolTip;
//...
}; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
m_pToolTip = NULL;
}
CAboutDlg::~CAboutDlg()
{
delete m_pToolTip;
} BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
((CTooltipsApp*)AfxGetApp())->m_hwndDialog=m_hWnd;
if (!m_pToolTip)
{
m_pToolTip = new CToolTipCtrl;
if(!m_pToolTip->Create(this))
{
TRACE("Unable To create ToolTip\n");
return TRUE;
}
((CTooltipsApp*)AfxGetApp())->m_gpToolTip = m_pToolTip;
if(m_pToolTip->AddTool(this, "About Box"))
{
TRACE("Unable to add Dialog to the tooltip\n");
}
if (m_pToolTip->AddTool(&m_btOK,"OK Button"))
{
TRACE("Unable to add OK button to the tooltip\n");
}
m_pToolTip->Activate(TRUE);
}
return TRUE;//return TRUE unless you set the focus to a control
//EXCEPTION: OCX Property Pages should return FALSE
} void CAboutDlg::PostNcDestroy( )
{
CDialog::PostNcDestroy();
((CToolTipsApp*)AfxGetApp())->m_hwndDialog= NULL;
((CToolTipsApp*)AfxGetApp())->m_gpToolTip= NULL;
}Additional query words: 2.10 2.20 3.10 3.20 4.00 alwaysupdate dskbsweep
Keywords: kbhowto kbtooltip kbuidesign kbdlg kbcode KB141758