#### Archived

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

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

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

## 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 on other sites
umm, I speak for everybody here when I say, huh? Are you speaking english?

##### Share on other sites
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 on other sites
Yeah, sorry Fel but I don''t mess with that dusty corner.

##### 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)

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 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 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 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 messagecase 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 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 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

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633311
• Total Posts
3011313
• ### Who's Online (See full list)

There are no registered users currently online

×