Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hi I wanne make a ToolTipNotify

Posted on 2001-06-13
11
Medium Priority
?
384 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 120 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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