|
-
March 30th, 1999, 12:04 AM
#1
Help me in Tool Tips
Hello everybody,
I have an edit box on my dialog template. When I move the mouse on it, it should display a Tool tip for the edit box say "12 bytes" as a Tool tip text. How to implement this. Please help me out.
Regards
Bala
-
March 30th, 1999, 12:29 AM
#2
Re: Help me in Tool Tips
Hi,
Enable the ToolTips using the EnableToolTips() function.
When you get the focus on your edit box, use OnToolHitTest() to display your tool tip.
Good Luck.
-
March 30th, 1999, 12:37 AM
#3
Re: Help me in Tool Tips
1. create a variable for your tooltip ctrl in the dialog class:
CToolTipCtrl m_tooltip;
2. Put the following codes in OnInitDialog() after the CDialog::OnInitDialog():
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
.......
.......
{
// Create the ToolTip control.
m_tooltip.Create(this, TTS_ALWAYSTIP);
m_tooltip.Activate(TRUE);
// TODO: Use one of the following forms to add controls:
m_tooltip.AddTool(GetDlgItem(IC_MYEDITBOX), "12 bytes" ;
}
return TRUE;
}
3. save and re-compile.
Also, you can do the following to insert MFC ToolTip control to your dialog:
choose "Project" -> "Add to Projects" -> "Components and Controls"
select "Developer Studio Components" folder, then select "ToolTip Support". You can insert into any dialogs of yout
project.
Hope this will help. Good luck.
Allen
-
March 30th, 1999, 12:54 AM
#4
Re: Help me in Tool Tips
Hi,
Apart from the code posted by Allen you will have to do the following too:-
You will have to call the PreTranslateMessage.
virtual BOOL PreTranslateMessage( MSG* pMsg );
And in this you will have to call the RelayEvent. The following is given in the
VC++ help:
CToolTipCtrl::RelayEvent
void RelayEvent( LPMSG lpMsg );
Parameters
lpMsg Pointer to a MSG structure that contains the message to relay.
Remarks
Call this function to pass a mouse message to a tool tip control for
processing. A tool tip control processes only the following messages,
which are sent to it by RelayEvent:
Thanks,
Aparna.
-
March 30th, 1999, 04:31 AM
#5
Re: Help me in Tool Tips
Hi
Thank you for the method you have given. I have tried all the methods that has been mentioned still the tool tip doesnt
appear. What to do. Am I missing anything...
This is one method i tried.
TOOLINFO s1;
s1.cbSize = sizeof(TOOLINFO);
s1.hwnd = (HWND)GetDlgItem(IDC_EDIT1);
s1.lpszText = "12 bytes";
m_tooltip.OnToolHitTest(CPoint(100,100),&s1);
This is the other method I tried
OnInitDialog()
{
....
...
...
m_tooltip.Create(this);
m_tooltip.Activate(TRUE);
m_tooltip.AddTool(GetDlgItem(IDC_EDIT1), "12 bYTES" ;
return TRUE;
}
I have also given the RelayEvent function on PreTranslateMessage(MSG)
BOOL CEx1Dlg::PreTranslateMessage(MSG* pMsg)
{
// CG: The following block was added by the ToolTips component.
{
// Let the ToolTip process this message.
m_tooltip.RelayEvent(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
}
what is the mistake I m doing here.
Thanks and Regards
Bala
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|