ToolTips on ListView Header

Y

Yura Moldavanov

Hello, All!

I have a problem with putting the ToolTips on ListView Header

ToolTip Text Property must changes depending on column, which is under
mosue cursor.

Problem 1. Standatr .Net class TooTip is not shown, when mouse not in the
client area of ListView.
I trying to solve this through Win Api CreateEx function, SendMessage e t.c.
But therein lies a problem for me that I can't to know which column is under
mouse cursor.

Please help me to find optimal solution how to set ToolTip on LiseView
Header, which show the current column Title...
 
Y

Yura Moldavanov

If you wish I can send full source code to your e-mail.
-------------------------------------------------------

protected override void WndProc(ref Message m)
{
if (m.Msg==WM_NOTIFY )
{
NMHDR nm =(NMHDR) m.GetLParam(typeof(NMHDR));
if (nm.code==HDN_ITEMCHANGEDW)
{
int right=0;
int left=0;
TOOLINFO ti=new TOOLINFO();
ti.cbSize=Marshal.SizeOf(ti);
ti.uFlags=TTF_SUBCLASS;
ti.hWnd=headerHandle;
for (int i=0; i<this.Columns.Count; i++)
{
if (i<this.Columns.Count)
right+=this.Columns.Width;
else
right=this.Width;
ti.uID=i;
if (i<this.Columns.Count)
ti.pszText=this.Columns.Text;
else
ti.pszText="";
Rectangle rect= new System.Drawing.Rectangle(left,0,right,20);
ti.rect=rect;
// SendMessage(toolTipHandle, TTM_DELTOOLW, 0, ref ti);
SendMessage(toolTipHandle, TTM_ADDTOOLW, 0, ref ti);
left=right;
}
}
}
base.WndProc (ref m);
}
 
C

cyrille

Yura said:
protected override void WndProc(ref Message m)
{
if (m.Msg==WM_NOTIFY )
{
NMHDR nm =(NMHDR) m.GetLParam(typeof(NMHDR));
if (nm.code==HDN_ITEMCHANGEDW)
{
int right=0;
int left=0;
TOOLINFO ti=new TOOLINFO();
ti.cbSize=Marshal.SizeOf(ti);
ti.uFlags=TTF_SUBCLASS;
ti.hWnd=headerHandle;
for (int i=0; i<this.Columns.Count; i++)
{
if (i<this.Columns.Count)
right+=this.Columns.Width;
else
right=this.Width;
ti.uID=i;
if (i<this.Columns.Count)
ti.pszText=this.Columns.Text;
else
ti.pszText="";
Rectangle rect= new System.Drawing.Rectangle(left,0,right,20);
ti.rect=rect;
// SendMessage(toolTipHandle, TTM_DELTOOLW, 0, ref ti);
SendMessage(toolTipHandle, TTM_ADDTOOLW, 0, ref ti);
left=right;
}
}
}
base.WndProc (ref m);
}


How do you initialize 'headerHandle' ?

cyrille
 
Y

Yura Moldavanov

headerHandle = (IntPtr)SendMessage((int)Handle, LVM_GETHEADER,0,0);

cyrille said:
Yura said:
protected override void WndProc(ref Message m)
{
if (m.Msg==WM_NOTIFY )
{
NMHDR nm =(NMHDR) m.GetLParam(typeof(NMHDR));
if (nm.code==HDN_ITEMCHANGEDW)
{
int right=0;
int left=0;
TOOLINFO ti=new TOOLINFO();
ti.cbSize=Marshal.SizeOf(ti);
ti.uFlags=TTF_SUBCLASS;
ti.hWnd=headerHandle;
for (int i=0; i<this.Columns.Count; i++)
{
if (i<this.Columns.Count)
right+=this.Columns.Width;
else
right=this.Width;
ti.uID=i;
if (i<this.Columns.Count)
ti.pszText=this.Columns.Text;
else
ti.pszText="";
Rectangle rect= new System.Drawing.Rectangle(left,0,right,20);
ti.rect=rect;
// SendMessage(toolTipHandle, TTM_DELTOOLW, 0, ref ti);
SendMessage(toolTipHandle, TTM_ADDTOOLW, 0, ref ti);
left=right;
}
}
}
base.WndProc (ref m);
}


How do you initialize 'headerHandle' ?

cyrille
 

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