Solved

tool tip

Posted on 2000-02-24
3
287 Views
Last Modified: 2013-11-20
I have created a tooltip in one of the propertypage. And I want to shwit up as the mouse moves over but it's not showing up. I handled it in Pretanslate message by using function realayevent()
. But the problem is this pretranslatemessage is not called up at all!!!!!!
Any ideas???
0
Comment
Question by:Bhaskar_Y
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 60 total points
ID: 2553774
Here is what I do...

In the message map...

ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT,0,0xFFFF,OnToolTipNotify)

In OnInitDialog...

   EnableToolTips(true);

Add a handler to display the tooltip:

BOOL CMyPage::OnToolTipNotify( UINT /*id*/, NMHDR * pNMHDR, LRESULT * /*pResult*/ ) {
    static CString text;
    TOOLTIPTEXT *pTTT = reinterpret_cast<TOOLTIPTEXT*>(pNMHDR);
    UINT nID =pNMHDR->idFrom;
    if (pTTT->uFlags & TTF_IDISHWND) {
        // idFrom is actually the HWND of the tool
        nID = ::GetDlgCtrlID(reinterpret_cast<HWND>(nID));
        if(nID) {
            text = ToolTipString(nID);
            if (! text.IsEmpty()) {
                pTTT->lpszText = const_cast<LPTSTR>((LPCTSTR)text);
                pTTT->hinst = NULL;
                return true;
            }
        }
    }
    return false;
}

fix a 'bug' in CPropertyPage that stops the translation of the messages (this is probably what you are missing?):

BOOL CMyPage::PreTranslateMessage(MSG* pMsg) {
    return CWnd::PreTranslateMessage(pMsg);
}

And finally a function that returns the tooltip text for the control:

CString CMyPage::ToolTipString(UINT id) {
    return // whatever the string is
}

This works for me (I actually do this in a base class from which i derive all by property pages).

0
 

Author Comment

by:Bhaskar_Y
ID: 2553809
Hi thanks for that but What is TTN_NEEDTEXT?
and I am creating many cotrols on the property page at run time. It's not possible to have series of controlIDs.
So tell me why pretanslatemessage could not have been working?.
Tell me the easier thing to do

Thanks
Bhaskar
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2553926
TTN_NEEDTEXT is the message send what a tooltip control wants to know what text to display.

The example I gave is usually the simplest .. you find out the text to display based on the ID.

How do you intend to determine what text to display in the tooltip for each control?  One can probably easilty modify the code I gave for other methods.

PreTranslatemessage may not have been called if you did not get the declaration EXACTLY correct (correct return type, arg types etc).  That is one of the traps in C++ whne overriding virtual functions .. C++ won't tell you if you inadvertanly get the declaration wrong.. it just won't call your function.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

805 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