RAF,
SendMessage is not the way to simulate a mouse click. It only sends the
message to the control. A mouse click involves a hardware interrupt,
followed by the OS sending a number of messages to the target window, not
just one button down message.
In order to send a click to the tree view, you should find the position
of the node you want to send the mouse click to, and then call the SendInput
API function through the P/Invoke layer.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi,
>
[quoted text clipped - 13 lines]
>
> RAF
Kerem Gümrükcü - 24 Nov 2007 16:42 GMT
>In order to send a click to the tree view, you should find the position of
>the node you want to send the mouse click to, and then call the SendInput
>API function through the P/Invoke layer.
Yes, i agree,...would be the best solution for this!
Regards
Kerem

Signature
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
R.A.F. - 24 Nov 2007 19:07 GMT
Sorry Nicholas but i did not find anything in VS2008 help about
SendInput API.
By the way, why do you not support the SendMessage method for such topic ?
I finally adapt it from C++ to C# and it works great :-)
RAF
> RAF,
>
[quoted text clipped - 6 lines]
> position of the node you want to send the mouse click to, and then call
> the SendInput API function through the P/Invoke layer.
Nicholas Paldino [.NET/C# MVP] - 24 Nov 2007 19:34 GMT
RAF,
Here is a link to the documentation for SendInput:
http://msdn2.microsoft.com/en-us/library/ms646310.aspx
The reason I don't like calling SendMessage in this case is that you are
only sending the left mouse button down message. However, a true mouse
click consists of a click event, as well as a mouse down and a mouse up
event and possibly more. The control is also free to respond to any of
these messages as it sees fit.
It just so happens that sending the message is doing what you want, but
it isn't the same as sending a mouse click.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Sorry Nicholas but i did not find anything in VS2008 help about SendInput
> API.
[quoted text clipped - 15 lines]
>> position of the node you want to send the mouse click to, and then call
>> the SendInput API function through the P/Invoke layer.
> Hi,
>
[quoted text clipped - 13 lines]
>
> RAF
Maybe I'm missing something here, but if you want to make sure that
that a specific node is selected when your form opens, why not simply
set the SelectedNode property of the tree?
Since the most common way to use a tree for navigation is to handle
the AfterSelect event, this should result in the same behavior as
actually clicking on the node.
hth,
Kevin Wienhold