TreeView call perform DBLCLK

  • Thread starter Thread starter Sonia Igla
  • Start date Start date
S

Sonia Igla

Hi. I need to perform DBLCLK on TreeView Node.
I try the following:

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam,
UInt32 lParam);
private const UInt32 WM_LBUTTONDBLCLK = 0x203;


pTreeNode.TreeView.SelectedNode = pTreeNode;
UInt32 pos = (UInt32)pTreeNode.Bounds.X;
pos |= (UInt32)pTreeNode.Bounds.Y;
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,0,pos);

But don't get response in TreeView.DoubleClick event.


Help me please with this question.
Sonia.
 
Hi Sonia,
UInt32 pos = (UInt32)pTreeNode.Bounds.X;
pos |= (UInt32)pTreeNode.Bounds.Y;

First, these lines look suspicious. You should not only OR the X and Y, but
you should also shift one of them right by 16 bits (don't remember which one
exactly). Second, ensure you should supply the coordinates in the client
coordinate system and not the screen one.
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,0,pos);

What response do you expect? Wouldn't it be simplier to invoke the event
handler method directly?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Sonia Igla said:
Hi. I need to perform DBLCLK on TreeView Node.
I try the following:

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam,
UInt32 lParam);
private const UInt32 WM_LBUTTONDBLCLK = 0x203;


pTreeNode.TreeView.SelectedNode = pTreeNode;
UInt32 pos = (UInt32)pTreeNode.Bounds.X;
pos |= (UInt32)pTreeNode.Bounds.Y;
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,0,pos);

But don't get response in TreeView.DoubleClick event.


Help me please with this question.
Sonia.
 
Dmitriy Lapshin said:
Hi Sonia,
UInt32 pos = (UInt32)pTreeNode.Bounds.X;
pos |= (UInt32)pTreeNode.Bounds.Y;

First, these lines look suspicious. You should not only OR the X and Y, but
you should also shift one of them right by 16 bits (don't remember which one
exactly). Second, ensure you should supply the coordinates in the client
coordinate system and not the screen one.
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,0,pos);

What response do you expect? Wouldn't it be simplier to invoke the event
handler method directly?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Sonia Igla said:
Hi. I need to perform DBLCLK on TreeView Node.
I try the following:

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam,
UInt32 lParam);
private const UInt32 WM_LBUTTONDBLCLK = 0x203;


pTreeNode.TreeView.SelectedNode = pTreeNode;
UInt32 pos = (UInt32)pTreeNode.Bounds.X;
pos |= (UInt32)pTreeNode.Bounds.Y;
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,0,pos);

But don't get response in TreeView.DoubleClick event.


Help me please with this question.
Sonia.

Thank you Dmitriy for your help.
Now I use the following with nothing success:

static IntPtr MakeLParam(int LoWord, int HiWord)
{
return (IntPtr) ((HiWord << 16) | (LoWord & 0xffff));
}


TreeView trv = pTreeNode.TreeView;
trv.SelectedNode = pTreeNode;
Point point = trv.PointToClient(new
System.Drawing.Poin(pTreeNode.Bounds.X,pTreeNode.Bounds.Y));
UInt32 pos = (UInt32)MakeLParam(point.X,point.Y);
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDBLCLK,MK_LBUTTON,pos);
What response do you expect?

I will response in:

treeView1.DoubleClick += new
System.EventHandler(treeViewOnDoubleClick);
private void treeViewOnDoubleClick(object sender, System.EventArgs e)
{
MessageBox.Show("My DBLCLICK");
}

Wouldn't it be simplier to invoke the event
handler method directly?

Can you tell me more practice?

Thanks Sonia
 
Back
Top