Solved

tool tip

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

19 Experts available now in Live!

Get 1:1 Help Now