Solved

tool tip

Posted on 2000-02-24
3
301 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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