Thank you that is exactly what I was looking for.
"Adam" <Adam@discussions.microsoft.com> wrote in message
news:321E993B-6B3D-43FA-9A2C-EAB52A3AC800@microsoft.com...
> ME,
>
> If you look at MSDN for the SendMessageCallback function, you'll be
> directed
> to the SendAsyncProc function definition for the callback function:
>
>
http://msdn2.microsoft.com/en-us/library/ms644949(VS.85).aspx
>
> From there, you can derive the delegate:
>
> delegate void SendAsyncProc(IntPtr hwnd, uint uMsg, UIntPtr dwData, IntPtr
> lResult);
>
> Here is a simple example:
>
> [DllImport("user32.dll")]
> private static extern bool SendMessageCallback(IntPtr hWnd, uint Msg,
> IntPtr
> wParam, IntPtr lParam, SendAsyncProc lpCallback, UIntPtr dwData);
> private delegate void SendAsyncProc(IntPtr hwnd, uint uMsg, UIntPtr
> dwData,
> IntPtr lResult);
> private const uint WM_USER = 0x400;
>
> private void button1_Click(object sender, EventArgs e)
> {
> SendAsyncProc del = new SendAsyncProc(SendMessage_Callback);
> SendMessageCallback(this.Handle, WM_USER, IntPtr.Zero, IntPtr.Zero,
> del,
> UIntPtr.Zero);
> }
>
> private void SendMessage_Callback(IntPtr hwnd, uint uMsg, UIntPtr dwData,
> IntPtr lResult)
> {
> // Here is your callback!
> return;
> }
>
> I just used a button click event to show this work. I send the WM_USER
> message to the form, which does nothing special to handle it.
>
> Hope this helps.
>
> Adam
>
> "ME" wrote:
>
>> What is the proper way to use the User32 function SendMessageCallback
>> with
>> in C# so that it will call back a C# delegate? Seems all I can find is
>> people talking about how SendMessageCallback returns immediately but will
>> callback a delegate. I can't seem to find any examples though of how
>> this
>> done in C#. Pinvoke.net only had the signature, but lacked the delegate
>> definition. An example of how to use this function would be very helpful
>> if
>> you know how.
>>
>> Thanks,
>>
>> Matt
>>
>>
>>