Solved

Hi I wanne make a ToolTipNotify

Posted on 2001-06-13
11
352 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
  • 5
  • 5
11 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
post your e-mail and i'll send u a sample program
0
 
LVL 30

Expert Comment

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

Author Comment

by:win32
Comment Utility
Year, but it is also possible to set up tooltips for a CButton, and not for the Toolbar, how is that done ?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
//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
Comment Utility
My e-mail is cb_priv@hotmail.com
0
 

Author Comment

by:win32
Comment Utility
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
Comment Utility
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
Comment Utility
Do you have to preTransLateMessage,, Cant you do the same in the MessageMap ??
0
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now