Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

felisandria

Tooltips and toolbars in MFC, or: why my life sucks right now.

This topic is 5092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a relatively complex little app that has 3 splitter windows. The window on the far right has a toolbar in the edge of its frame that I do border negotiations to accomodate the viewing of. The window on the far right is a fram with 6 views that take turns being shown, maximized. Although I can get command messages from the toolbar docked at the right edge of the frame, I can''t get the text down at the bottom or the tooltip to show for the toolbar. The parent window is a CFrameWnd derivative so it should do it natively. I already tried overriding TTN_NEEDTEXT notification everywhere I can think of... it never gets called at all. Has anyone else had problems with getting tooltips to show in toolbars that are docked to subframes in splitter windows, or is it just me? Also, my mainframe toolbar will show the tooltips for the 3 report views I have, but not for the graphical views when they''re the current active windows on the right. I''ve tried notification overrides there too, no luck. I''m starting to wonder if it isn''t that the graphical views have a timer and that might interfere with the OnIdle while a graphical is the active view, but that really shouldn''t be the case. I''m baffled. Suggestions? -fel

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by WORF
umm, I speak for everybody here when I say, huh? Are you speaking english?


No, you don''t speak for everybody. felisandria is perfectly comprehensible; I just happen to have not tried that particular situation with MFC before (speaking for myself).

Share this post


Link to post
Share on other sites
Sorry Fel.
I can't help either. Haven't even come close to this situation.
------------------------------------------
Edit. I gave a search through our product, and there was a reference to TTN_NEEDTEXT:

ON_NOTIFY(TTN_NEEDTEXT, 0, OnGetTooltipText)

But it sounds like you already had this.

Here is the function:

void CMapView::OnGetTooltipText(NMHDR* pNMHDR, LRESULT *plRes)

// See C++ Q&A by Paul DiLascia, MSJ, March 1997 pp. 109 - 112.

{
TOOLTIPTEXT& ttt = *((TOOLTIPTEXT *) pNMHDR);

const CPoint pt(pNMHDR->idFrom);

strncpy(ttt.szText, GetSymbolName(pt), sizeof(ttt.szText));
}


Edited by - Gorky on September 26, 2001 10:40:01 AM

Share this post


Link to post
Share on other sites
I liberally sprinkled TTN_NEEDTEXT handlers throughout every view and frame that this toolbar gets anywhere near, and none of them get hit, at all *sigh*

I don''t know where it''s routing, or even IF it''s routing. Command messages work fine, tooltip notification is apparently nonexistent.

-fel

Share this post


Link to post
Share on other sites
I may have a slight bit of insight, something I found out last night working on my little board game. "Message routing" and "Command routing" are two different things. Only the WM_COMMAND messages get sent through the whole chain--from the view to the frame to the doc to the app or whatever the whole order is. All other messages look like they''re only sent to their target window. Since the tooltip stuff is latched onto WM_NOTIFY, not WM_COMMAND, I don''t think it''s routed anywhere.

I''m about 50% sure this doesn''t apply to the problem at hand, but just thought I''d throw it up in case it does. Best I can do right now.

Share this post


Link to post
Share on other sites
I''m not sure this will help but here''s a win32 code I wrote for a button with a tool tip. Tooltips are in string resource file.

  
// Common controls sent this message

case WM_NOTIFY:
switch(((LPNMHDR)lParam)->code)
{
// Main toolbar wants tooltip string info

case TTN_GETDISPINFO:
g_FrameWnd.DisplayToolbarTooltips(lParam);
break;
}
}
break;

void CToolbar::DisplayTooltips(LPARAM lParam)
{
/*
// LOAD TOOLTIP STRINGS FROM STRINGTABLE
*/

((LPNMTTDISPINFO)lParam)->hinst = GetModuleHandle(NULL);
((LPNMTTDISPINFO)lParam)->uFlags = TTF_DI_SETITEM;

// Retain the string info and don''t ask for it again


switch(((LPNMHDR)lParam)->idFrom)
{
case CMDID_FILENEW:
((LPNMTTDISPINFO)lParam)->lpszText = MAKEINTRESOURCE(IDS_NEW);
break;
}

Share this post


Link to post
Share on other sites
Well, I''m aware that NOTIFY is supposed to be restricted to the parent window but I''m not picking it up there.

I know I can write my own into a derived CToolBar class, but... I wince at the thought. *sigh*

-fel

Share this post


Link to post
Share on other sites
On a related note, has anyone ever managed to get tooltips to work for any control other than a bog standard label? (in a normal window, not toolbars) I dont seem to able to do this, despite spending weeks playing about, manually subclassing the controls etc. Nothing seems to work.

The controls I am particularly interested in getting tooltips working for are checkboxes and slider bars. I am not using MFC either, just bog standard common or garden Win32.

Any suggestions?


Edited by - Sandman on September 27, 2001 11:37:18 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!