Re: Transparent tooltip gets focus with the manifest-style under Windo
On Thu, 21 Jun 2007 09:17:01 -0700, ASCO DATA GmbH
<ASCODATAGmbH@discussions.microsoft.com> wrote:
I
don't know, how Microsoft
use in the VC6.0 in the Workarea-Window also an tooltip-window, because they
haven't the same problem.
I'm sorry, but I don't understand what you really would like to do...
The following source-code is from my test-application. The program is a
simple MFC-dialog-program,
the dialog includes an OK- and Cancel-button. m_wndToolTip is from
CToolTipCtrl.
void CTooltiptestDlg::OnOK()
{
....This seems to me a strange way of showing tool-tips, also because
when you press OnOK in dialog-box apps the dialog-box closes and if it
is the main dialog, the app terminates...
You might find this interesting:
http://www.codersource.net/mfc_tool_tip_ctooltipctrl.html
Moreover, the following code could be somehow corrected to make it
Unicode aware, to protect against buffer overflows, etc.
e.g.:
// This macro could be useful to clear structures and set
// their size:
#define PREPARE_STRUCT( s ) { ZeroMemory( &(s), sizeof(s) ); (s).cbSize = sizeof(s); }
char caText[1024];
Better using CString here and CString::Format, it is easier and more
robust than char and sprintf. Moreover, CString is Unicode aware.
CString text;
text.Format( _T("nIndex = %d"), nIndex );
memset(&TI, 0, sizeof(TI));
TI.cbSize = sizeof(TI);
You might use:
PREPARE_STRUCT( TI )
TI.lpszText = caText;
Using C++ casts, you might do:
TI.lpszText = const_cast< LPTSTR >(
static_cast< LPCTSTR >( text ) );
The first cast converts from CString to LPCTSTR, the second cast
removes the const-attribute.
The whole thing follows:
<CODE>
void CToolTipTestDlg::ToolTipTest()
{
TOOLINFO TI;
static long nIndex = 0;
CRect rectTemp;
CFont* pfont;
CWnd* pwndOK;
CString text;
text.Format( _T("nIndex = %d"), nIndex );
PREPARE_STRUCT( TI )
TI.lpszText = const_cast< LPTSTR >( static_cast< LPCTSTR >( text )
);
if(IsWindow(m_wndToolTip) == FALSE)
{
m_wndToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
m_wndToolTip.SetMaxTipWidth(SHRT_MAX);
//Add tool
TI.uFlags = TTF_TRACK | TTF_TRANSPARENT;
m_wndToolTip.SendMessage(TTM_ADDTOOL, 0, (LPARAM)&TI);
}
else
{
//Modify the text of the tooltip.
m_wndToolTip.SendMessage(TTM_UPDATETIPTEXT, 0, (LPARAM)&TI);
}
//Take over the font from the dialog.
pfont = GetFont();
if(pfont != NULL)
{
m_wndToolTip.SetFont(pfont);
}
//Set the position of the tooltip.
pwndOK = GetDlgItem(IDOK);
pwndOK->GetWindowRect(&rectTemp);
m_wndToolTip.SendMessage(TTM_TRACKPOSITION,
0, (LPARAM)MAKELONG(rectTemp.left, rectTemp.top));
//Show tooltip
PREPARE_STRUCT( TI )
m_wndToolTip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&TI);
//Increment the static index
nIndex++;
}
</CODE>
Can anybody help me???
I'm sorry I cannot better help, but I've not understood your goal nor
the way you are using tool-tips in response to IDOK button click...
MrAsm