Click to See Complete Forum and Search --> : Help me in Tool Tips


bala
March 29th, 1999, 11:04 PM
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

Bala
March 29th, 1999, 11:04 PM
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

Nambi
March 29th, 1999, 11:29 PM
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.

Allen
March 29th, 1999, 11:37 PM
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

Aparna
March 29th, 1999, 11:54 PM
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.

bala
March 30th, 1999, 03:31 AM
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

Bala
March 30th, 1999, 03:31 AM
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