Solved

Hi I wanne make a ToolTipNotify

Posted on 2001-06-13
11
361 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
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 86
deburging in oracle form 12 99
sumDigits challenge 9 150
lucky13 challenge 11 144
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 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