By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,916 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,916 IT Pros & Developers. It's quick & easy.

TreeView call perform DBLCLK

P: n/a
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_LBUTTONDB LCLK,0,pos);

But don't get response in TreeView.DoubleClick event.
Help me please with this question.
Sonia.
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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_LBUTTONDB LCLK,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" <so***@mer.co.il> wrote in message
news:6d**************************@posting.google.c om... 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_LBUTTONDB LCLK,0,pos);

But don't get response in TreeView.DoubleClick event.
Help me please with this question.
Sonia.


Nov 15 '05 #2

P: n/a
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<#y**************@tk2msftngp13.phx.gbl>...
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_LBUTTONDB LCLK,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" <so***@mer.co.il> wrote in message
news:6d**************************@posting.google.c om...
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_LBUTTONDB LCLK,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.B ounds.Y));
UInt32 pos = (UInt32)MakeLParam(point.X,point.Y);
SendMessage(pTreeNode.TreeView.Handle,WM_LBUTTONDB LCLK,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
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.