Tool tip

In my dialog based application for some components I would like to show the tooltip. I am doing this code.
In header file dlg.h
 CToolTpCtrl tooltip;
In cpp file dlg.cpp
  in the method           m_ToolTip.AddTool((CButton*)GetDlgItem(IDOK),"Open",NULL,0);
  in  OnMouseMove()
    m_ToolTip.Activate(true);
    m_ToolTip.SetDelayTime(10);
But tooltip is notvisible. Can you please help me out in this regardd??
Thanks

bmuralimohanAsked:
Who is Participating?
 
wooperConnect With a Mentor Commented:
Your code is right bmuralimohan, you've just to add the following method in your class in order to able the ToolTip control to process its message:

In the header:

      BOOL PreTranslateMessage(MSG* pMsg);

in the implementation:

BOOL YOUCLASSHERE::PreTranslateMessage(MSG* pMsg)
{
      // Let the ToolTip process this message.
      mytooltip.RelayEvent(pMsg);
      return CDialog::PreTranslateMessage(pMsg); // used for a dialog based application.
}


Note: You can do all the tooltip's initialisation at the same time, so you don't have to use it into your OnMouseMove method.

BOOL YOUCLASSHERE::OnInitDialog()
{
      CDialog::OnInitDialog();

      mytooltip.Create(this);
      mytooltip.Activate(TRUE);
      mytooltip.AddTool(GetDlgItem(IDOK), "This is a sample");

0
All Courses

From novice to tech pro — start learning today.