TTF_TRANSPARENT tooltip

T

Terence Lee

Dear all,

Anybody have some sample code for setting the TTF_TRANSPARENT style of a
.net tooltip?

Thx,
 
T

Terence Lee

I have a list view control. As usual, the columns may not be wide enough
to display the data. Therefore, I create a ToolTip and in cause the data
has been truncated, I display a ToolTip to show them. In my case, I move
the ToolTip so that it will exactly overlap with the cell but then, I
will need to set the ToolTip's TTF_TRANSPARENT flag so that all mouse
action will be passed to the underlying list view control.

Following is the code fragment.

if (width > ch.Width)
{
tipDetails.SetToolTip(lvwDetails, item.SubItems[sub].Text);
// Find the ToolTip window handle using EnumWindows.
if (ttHandle == IntPtr.Zero)
{
EnumWindows(new WNDENUMPROC(processEnumWindow),
Parent.Parent.Parent.Handle);
}

SetWindowPos(ttHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);

TOOLINFO ti = new TOOLINFO();

ti.cbSize = (uint)Marshal.SizeOf(ti);
ti.uFlags = TTF_TRANSPARENT | TTF_SUBCLASS;
ti.hwnd = lvwDetails.Handle;
GetClientRect(lvwDetails.Handle, ref ti.rect);
SendMessage(ttHandle, TTM_SETTOOLINFO, 0, ref ti);
// This line returns 0. But TTF_TRANSPARENT is not working.
System.Diagnostics.Debug.WriteLine("Win32 error: " +
Marshal.GetLastWin32Error());

SetWindowPos(ttHandle, IntPtr.Zero, l.X, l.Y, 0, 0, SWP_NOSIZE |
SWP_NOZORDER | SWP_NOACTIVATE);
System.Diagnostics.Debug.WriteLine(item + ", sub item is " + sub +
", not wide enough, repeat count is " + repeatSubItem);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top