Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ATL Toolbar button, does not receive  TTN_NEEDTEXT notification when I enable WinXP styles

Posted on 2004-09-15
8
Medium Priority
?
1,308 Views
Last Modified: 2013-11-25
ATL Toolbar button, does not receive  TTN_NEEDTEXT notification when I enable WinXP styles


here's my message map


class CMyToolBar : public CWindowImpl<CMyToolBar, CToolBarCtrl>

{

....
BEGIN_MSG_MAP(CMyToolBar)

NOTIFY_CODE_HANDLER(TTN_NEEDTEXT, OnToolTipNotify)

DEFAULT_REFLECTION_HANDLER()

END_MSG_MAP()

.....
LRESULT OnToolTipNotify(int idCtrl, LPNMHDR pNotifyStruct, BOOL& bHandled);  <----function signature
}






to get the toolbar to display with WinXP theme/style, I need to include this in my resource file

2 RT_MANIFEST "res\\MyManifest.manifest"

(manifest file is xml stuff)

When I include this in resource file my tooltips don't work.

When I comment out the line in the resource file, I don't get WinXP style for my toolbar buttons, but my tooltips are restored and do work.

In other words, when using WinXP style-I get no tooltips, when I disable WinXP style by commenting out line, my toolbar button tooltips work

(ie I receive the TTN_NEEDTEXT message, where-as when WinXP style is enabled I don't seem to receive this TTN_NEEDTEXT  message)




(PS It's ATL Toolbar NOT MFC Toolbar)
0
Comment
Question by:esgi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
ID: 12072817
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12073676
Better try to watch with SPY++ who catches that message.
0
 

Author Comment

by:esgi
ID: 12075621
Using message hook would not be good solution, too much overhead.

I originally tried using Spy++, and that didn't help. All I could see were the standard NCHITTEST messages + WM_PAINT, etc...

Let me just back track a second.
Originally I did this...
class CMyToolBar : public CWindowImpl<CMyToolBar, CToolBarCtrl>

{

BEGIN_MSG_MAP(CMyToolBar)

NOTIFY_CODE_HANDLER(TTN_NEEDTEXT, OnToolTipNotify)

DEFAULT_REFLECTION_HANDLER()

END_MSG_MAP()

LRESULT OnToolTipNotify(int idCtrl, LPNMHDR pNotifyStruct, BOOL& bHandled);

}

LRESULT CMyToolBar::OnToolTipNotify(int idCtrl, LPNMHDR pNotifyStruct, BOOL& bHandled)
    {
    const int MAX = 100;
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNotifyStruct;
    UINT nID = pNotifyStruct->idFrom;

    if ((nID > 0) && (nID < idUserCommand)) // ID'S OF BUTTONS I'm interested in......
        {
        CString str;
        str.LoadString(nID);
        strcpy(pTTT->szText, (const char*)str);
        pTTT->hinst = _AtlBaseModule.m_hInst;
        return(TRUE);
        }
    return(FALSE);
    }


The tooltips worked perfectly.
When I added the

2 RT_MANIFEST "res\\MyManifest.manifest"    (manifest file is xml stuff)

This enabled the toolbar buttons to display in WinXP style....BUT now my tooltips were blown away. No tooltips showed, not even tooltips with garbage text.

I tried this as one possible solution.....

MESSAGE_HANDLER(WM_NOTIFY, OnToolTipNotify)

LRESULT CMyToolBar::OnToolTipNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
    USES_CONVERSION;
    NMTTDISPINFO *ttdi;
    ttdi = (NMTTDISPINFO *)lParam;

    if(ttdi->hdr.code & TTN_NEEDTEXT)
        {
        NMTTDISPINFO* pNotifyStruct=(NMTTDISPINFO*)lParam;
        UINT nID = pNotifyStruct->hdr.idFrom;
        TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNotifyStruct;
        if ((nID > 0) && (nID < idUserCommand))
            {
            CString str;
            str.LoadString(nID);
            strcpy(pTTT->szText, (const char*)str);
            pTTT->hinst = _AtlBaseModule.m_hInst;
           bHandled = TRUE;
            }
        }
    bHandled = FALSE;
    return 0L;
    }



but for some reason, the code inside the (NOTE: INSIDE BLOCK....since of course their will be other notification I'm not interested in)

  if(ttdi->hdr.code & TTN_NEEDTEXT)
        {...}


does get hit, but still no tool tip, oddly, the notification gets called repeated till the stack is blown,

as if the notification is not removed from message queue.


0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:esgi
ID: 12079478
will close case, I found solution, will post it tomorrow..
0
 

Author Comment

by:esgi
ID: 12162968
admins, please close question
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12167425
0
 

Accepted Solution

by:
esgi earned 0 total points
ID: 12173369
When not using WinXP style, the original post on doing tooltips is sufficient, note especially this line of code

 strcpy(pTTT->szText, (const char*)str);

But when using WinXP style toolbar buttons it must instead be done this way...


    BEGIN_MSG_MAP(CMyToolBar)
        MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
        DEFAULT_REFLECTION_HANDLER()
    END_MSG_MAP()


LRESULT CMyToolBar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
    // need to handle both ANSI and UNICODE versions of the message
    NMTTDISPINFO* pNMHDR=(NMTTDISPINFO*)lParam;

    if ((pNMHDR->hdr.code == TTN_NEEDTEXT) || (pNMHDR->hdr.code == TTN_NEEDTEXTA) || (pNMHDR->hdr.code == TTN_NEEDTEXTW))
        {
        UINT nID = 0;
        CString strTipText;

        TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
        TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
        TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

        nID = pNMHDR->hdr.idFrom;

        if ((nID > 0) && (nID < idUserCommand))
            {
            strTipText.LoadString(nID);
            if (strTipText.GetLength() == 0)
                return FALSE;
            }

        static TCHAR szBuff[200] = { 0 }; //needs to be static
        memset(szBuff, 0, sizeof(szBuff));
        UINT s = sizeof(szBuff);
        pTTTA->lpszText = (LPSTR)szBuff;  <-- NOTE THE MOST IMPORTANT CHANGE. I use lpszText NOT szText field



        if (OSIsNT())// ALSO NEED TO COPY DIFFERENTLY FOR DIFFERENT OS's
            {
            if ((pNMHDR->hdr.code == TTN_NEEDTEXT) || (pNMHDR->hdr.code == TTN_NEEDTEXTA))
                lstrcpyn(szBuff, strTipText, sizeof(szBuff));
            else // if (pNMHDR->hdr.code == TTN_NEEDTEXTW)
                _mbstowcsz((wchar_t*)szBuff, strTipText, sizeof(szBuff));
            }

        return TRUE;    // message was handled
        }

    return FALSE;    // message was NOT handled
    }
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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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