Solved

Hi I wanne make a ToolTipNotify

Posted on 2001-06-13
11
370 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 116
Looking for a specific application/software 2 124
if loop in java 3 174
noX challenge 17 144
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. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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