Solved

Hi I wanne make a ToolTipNotify

Posted on 2001-06-13
11
376 Views
Last Modified: 2013-11-20
I am trying to catch the OnToolTipNotify in my MESSAGE_MAP like this

BEGIN_MESSAGE_MAP(CBasicGrid, CWnd)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
END_MESSAGE_MAP

This is in a subwindow of main.. The tooltip works fine like this in the main, but not in this CWnd, that is put "Over" main..

What can the resons be that the MESSAGE_MAP does'nt catch the TTN_NEEDTEXT ??

Do I need some init to be done ?
0
Comment
Question by:win32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 30 total points
ID: 6185598
thid is how i implemented OnToolTipNotify:

     afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMH, LRESULT *pResult);

BOOL CGridCtrl::OnToolTipNotify(UINT    id,
                                NMHDR   *pNMH,
                                LRESULT *pResult)
{
    LPTOOLTIPTEXT lpttt;

    lpttt = (LPTOOLTIPTEXT)pNMH;
.
.
.

}

BOOL CGridCtrl::PreTranslateMessage(MSG* pMsg)
{
    switch(pMsg->message)
    {
        case WM_LBUTTONDOWN:
        case WM_MOUSEMOVE:
        case WM_LBUTTONUP:
        case WM_MBUTTONDOWN:
        case WM_MBUTTONUP:
        case WM_RBUTTONDOWN:
        case WM_RBUTTONUP:

        if (m_pToolTip)
        {
            CPoint ptCurrentPos;

            //
            // offset the current position by the
            // amount the window is scrolled
            //
            ptCurrentPos.x = LOWORD(pMsg->lParam);
            ptCurrentPos.y = HIWORD(pMsg->lParam);
        if (m_rectSearch.PtInRect(ptCurrentPos) == FALSE)
            {
                m_pToolTip->Activate(FALSE);
            }

            // this will reactivate the tooltip
            m_pToolTip->Activate(TRUE);
            m_pToolTip->RelayEvent(pMsg);
        }
    }

    return CWnd::PreTranslateMessage(pMsg);

} // end PreTranslateMessage

0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6185601
void CGridCtrl::CreateTooltips()
{
    if (m_pToolTip == NULL)
    {
        //
        // Create the tooltip control and set the tool rectangle to be the
        // whole window rectangle.  This will cause the tooltip control to
        // request text whenever the mouse stops over the grid window.
        //
        CRect rect;
        GetClientRect(rect);
       
        // create a tooltip control
        m_pToolTip = new CToolTipCtrl;
        if(!m_pToolTip)
        {
            MessageBox(_T("Unable to allocate memory for ToolTips!"));
        }
        else
        {
            if( !m_pToolTip->Create(this, TTS_ALWAYSTIP) )
            {  
                MessageBox(_T("Unable to Create ToolTips for Grid!"));
            }
            else
            {
                m_pToolTip->AddTool(this, LPSTR_TEXTCALLBACK, rect, 1);
                m_pToolTip->Activate(TRUE);

                // Send message to extend the life of the tooltips.
                m_pToolTip->SendMessage(TTM_SETDELAYTIME,
                                        TTDT_AUTOPOP,
                                        30000);
                EnableToolTips(TRUE);
            }
        }
    }
} // end CreateTooltips
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6185604
post your e-mail and i'll send u a sample program
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 31

Expert Comment

by:Zoppo
ID: 6185694
BTW, maybe you only need to call EnableToolTips() for the window...
0
 

Author Comment

by:win32
ID: 6185767
Year, but it is also possible to set up tooltips for a CButton, and not for the Toolbar, how is that done ?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6185909
//CToolTipCtrl m_Tooltips;


     //Set up tooltips
     m_Tooltips.Create(this);
     m_Tooltips.Activate(TRUE);

//example of adding controls for tooltiping
m_Tooltips.AddTool(GetDlgItem(IDC_RADIO11),_T("Test 1"));
m_Tooltips.AddTool(GetDlgItem(IDC_RADIO12),_T("Test 2"));

and override PreTranslateMessage:
BOOL CMyDlg :: PreTranslateMessage(MSG* pMsg)
{
     if (m_hWnd)
          {
          m_Tooltips.RelayEvent(pMsg);
          return CDialog::PreTranslateMessage(pMsg);
          }
     return FALSE;
}


good luck
0
 

Author Comment

by:win32
ID: 6185946
My e-mail is cb_priv@hotmail.com
0
 

Author Comment

by:win32
ID: 6194098
So what you say sedqwick is that if you have a toolbar, you don't have to create a seperate tooltip control.. but if you have, like a button in a window, you will need to make a control for that button ??

CB.
0
 

Author Comment

by:win32
ID: 6194100
I am using the OnNotify, to get tooltips in the toolbar, is OnNotify never going to work with eg. a button in a window ?

CB.
0
 

Author Comment

by:win32
ID: 6194228
Do you have to preTransLateMessage,, Cant you do the same in the MessageMap ??
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6199364
if u create your own button or tooltip whatever, the tooltip message is not been notify so u need to use PreTranslateMessage() to pump the message
0

Featured Post

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question