 |
|
 |
How to enable tooltip for your dialog controls?[^]
The comment to the article also describes how easy it is to place the CToolTipCtrl on the dialog, and then call AddTool() for each button to specify tooltip.
Another possible solution could be call CWnd::EnableToolTips() in the class inherting from CButton, and then override the function CWnd::OnToolHitTest(CPoint point, TOOLINFO * pTI) so it returns the tooltip text in pTI->lpszText by allocating the text-buffer (The text-buffer will automatically be released again by MFC)
modified on Wednesday, March 18, 2009 7:05 AM
|
| Sign In·View Thread·PermaLink | 3.00/5 (1 vote) |
|
|
|
 |
|
 |
Hello. I use this button in a CDialogBar, But I don't show the toolTip. The PreTranslateMessage of this button isn't call.
Excuse me for my english, i'm frensh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The new operator in the example 'm_ToolTipButton.SetToolTipText(new CString("hello !!!"));' causes memory leak of the CString object. It's better to use LPCTSTR pointer or just at destruction delete the CString object.
|
| Sign In·View Thread·PermaLink | 5.00/5 (2 votes) |
|
|
|
 |
|
 |
Hello I used this button class in a Dialog and it was really fine, now that I am using with CDialogBar and the buttons on the Dilogbar are check boxes, I have checked the button properties as Push Like buttons, I tried to place a Push Button but when I check the owner draw property of it as true then the button doesnt even appear
I am a bit confuesd and need some help
best Regards Muhammad Aftab Alam
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hello. I just want to ask whether we can apply the bitmaps to a button at runtime? I mean we havent created the resource of the bitmap and we, lets say ,click on a bitmap from the list of bitmap files enumerated from a folder and that bitmap is appeared on the button? Is it possible?
Anand.
Anand anand@lambenttek.com Nagpur,India
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there,
Thank you for the free CToolTipButton classes. I have one problem using it with modeless (unmodal) Dialogs. The Tooltip is "behind" the Dialog !!! Any Idea to solve the problem ???
Thanx Jens
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I had the same problem when I used a CToolTipButton in a dialog embedded in a dynamic window. To solve the problem I didn't use the CToolTipButton class. Instead, I set the tooltip text for the desired controls in a handler for the TTN_NEEDTEXT notification in the dialog.
This procedure is explained in MSDN. Search for TTN_NEEDTEXT. The article in question is "Tool Tips in Windows Not Derived from CFrameWnd".
In short, all you have to do is this:
1) Put EnableToolTips(TRUE); in CMyDialog::OnInitDialog()
2) Add the TTN_NEEDTEXT message to your dialog's message map:
BEGIN_MESSAGE_MAP(CMyDialog, CDialog) // Other messages... ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify) // Other messages... END_MESSAGE_MAP() 3) Create a TTN_NEEDTEXT handler similar to this one:
BOOL CMyDialog::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult) { TOOLTIPTEXT * pTTT = (TOOLTIPTEXT *) pNMHDR; HWND hwndTool = (HWND) pNMHDR->idFrom;
if(pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool UINT nID = ::GetDlgCtrlID(hwndTool); CString csTip;
switch(nID) { case IDC_BUTTON_1: csTip.LoadString(IDS_BUTTON_1); break; case IDC_BUTTON_2: csTip.LoadString(IDS_BUTTON_2); break; case IDC_BUTTON_3: csTip.LoadString(IDS_BUTTON_3); break; default: return FALSE; }
_tcscpy(pTTT->lpszText, csTip); pTTT->hinst = AfxGetResourceHandle();
return TRUE; }
return FALSE; }
4) Add the handler's prototype in the CMyDialog class declaration:
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
Hope this helps!
François
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Francois,
I have tried the method you suggest here but the problem I am still having is that while I have the "ON_NOTIFY_EX(TTN_NEEDTEXT, 0, )" in my message map, the "OnToolTipNotify" message is never sent by my buttons!
I have added all the code suggested for this method, but after doing so, I have placed a breakpoint within the "OnToolTipNotify" message handler for my dialog and it never gets hit. The only thing I have been able to find that might be a clue is that because these buttons are set to "owner draw" (due to a bitmap being placed on them) there is a "notify" property that becomes disbled. I cannot figure out why my buttons do not send the "ON_NOTIFY" message when they are approached by the mouse.
Any thoughts?
Thank you,
Hal Roenick
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I checked my code and my buttons use "owner draw" as well so that is probably not the problem.
Make sure you include EnableToolTips(TRUE); in your dialog's OnInitDialog() method.
You can also review the steps in my previous message which I have updated.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Francois,
I have been working on this for quite some time now and have found my problem. I can make tool tips work on all dialogs with 1 exception...If the dialog is Modaless AND is created from within a .dll. Of course, that is what I am trying to do! It seems the windows messages stop being sent from a dialog of this sort.
If you can make that happen, I would love to see the code.
Thanks,
Hal
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello Hal!
I have exactly the same problem that you have met: I can make tool tips work on all dialogs with one exception: if the dialog is Modaless AND is created from within a .dll.
Did you find a solution to solve this problem?
Thank you very much for your help!
Jean-Pierre
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi all,
I had the same problem when I used a CToolTipButton in a dialog bar. To solve the problem I add the default window procedure to the CToolTipButton class.
Sample code: In header file
virtual LRESULT DefWindowProc(UINT nMessage, WPARAM wParam, LPARAM lParam);
In source file LRESULT CToolTipButton::DefWindowProc(UINT nMessage, WPARAM wParam, LPARAM lParam) { CPoint pnt; MSG msg; GetCursorPos(&pnt); msg.hwnd = this->GetSafeHwnd(); msg.lParam = lParam; msg.message = nMessage; msg.pt = pnt; msg.time = 0; msg.wParam = wParam; switch (nMessage) { case WM_MOUSEMOVE: case WM_MOUSELEAVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: m_ttcToolTip.RelayEvent(&msg); break; default: break; } return CButton::DefWindowProc(nMessage, wParam, lParam); }
Regards, Pham Van Hieu
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have problems when I tried to use the file ToolTipButton.h. in this definition CToolTipCtrl m_ToolTip the program generated a lot of mistakes about this definition. This is the mistake: 'm_ToolTip' uses undefined class 'CToolTipCtrl' What can I do?
Yasmin
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |