PostMessage help

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey everyone,
Im just having trouble with trying to send the command "WM_COMMAND" to another application.
Ive used Spy++ to get wParam and lParam however when I put them into PostMessage, it doesnt work.
This is what it looks like in Spy++:
<img src="http://social.microsoft.com/Forums/getfile/57362/" alt="

And here is my code:

<div style="color:black; background-color:white
<pre> [DllImport(<span style="color:#a31515 "user32.dll")]
<span style="color:blue public <span style="color:blue static <span style="color:blue extern <span style="color:blue bool PostMessage(IntPtr hWnd, Int32 Msg, Int32 wParam, Int32 lParam);


<span style="color:blue private <span style="color:blue void button2_Click(<span style="color:blue object sender, EventArgs e)
{
Window wind = listBox1.SelectedItem <span style="color:blue as Window;
<span style="color:blue try
{
PostMessage(wind.Handle, 0x111, Convert.ToInt32(<span style="color:#a31515 "18000002"), Convert.ToInt32(textBox2.Text));
}
<span style="color:blue catch (Exception)
{ <span style="color:blue return; }
}

<span style="color:blue public <span style="color:blue class Window
{
<span style="color:blue public <span style="color:blue string Title { <span style="color:blue get; <span style="color:blue set; }
<span style="color:blue public IntPtr Handle { <span style="color:blue get; <span style="color:blue set; }

<span style="color:blue public Window(<span style="color:blue string title, IntPtr handle)
{
Title = title;
Handle = handle;
}

<span style="color:blue public <span style="color:blue override <span style="color:blue string ToString()
{
<span style="color:blue return Title;
}
}
}
[/code]


And this is what it looks like when Ive done PostMessage with lParam as "0":
<img src="http://social.microsoft.com/Forums/getfile/57364/" alt="
There are some notable differences..
<br/>
Now Ive tried various things, like UInt32 for Msg, switching around Msg to 0x1800 (copying Spy++ wNotifyCode), no lParam for PostMessage, copying lParam from Spy++ quickly, and many others.
Maybe Im just missing something.
Could anyone help me out?

Thanks!
<br/>

View the full article
 
Back
Top