mirror of https://github.com/dahall/Vanara.git
Added new SendMessage overload for WM_GETTEXT use case (#191).
parent
06027d381a
commit
feba58dafb
|
@ -2065,7 +2065,7 @@ namespace Vanara.PInvoke
|
|||
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
|
||||
[PInvokeData("Winuser.h", MSDNShortId = "ms644950")]
|
||||
[System.Security.SecurityCritical]
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, IntPtr wParam = default, IntPtr lParam = default);
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, [In] IntPtr wParam = default, [In] IntPtr lParam = default);
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
|
@ -2099,7 +2099,7 @@ namespace Vanara.PInvoke
|
|||
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
|
||||
[PInvokeData("Winuser.h", MSDNShortId = "ms644950")]
|
||||
[System.Security.SecurityCritical]
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, IntPtr wParam, string lParam);
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, [In] IntPtr wParam, string lParam);
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
|
@ -2135,6 +2135,40 @@ namespace Vanara.PInvoke
|
|||
[System.Security.SecurityCritical]
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, ref int wParam, [In, Out] StringBuilder lParam);
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Sends the specified message to a window or windows. The <c>SendMessage</c> function calls the window procedure for the specified
|
||||
/// window and does not return until the window procedure has processed the message.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// To send a message and return immediately, use the <c>SendMessageCallback</c> or <c>SendNotifyMessage</c> function. To post a
|
||||
/// message to a thread's message queue and return immediately, use the <c>PostMessage</c> or <c>PostThreadMessage</c> function.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="hWnd">
|
||||
/// <para>
|
||||
/// A handle to the window whose window procedure will receive the message. If this parameter is <c>HWND_BROADCAST</c>
|
||||
/// ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows,
|
||||
/// overlapped windows, and pop-up windows; but the message is not sent to child windows.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Message sending is subject to UIPI. The thread of a process can send messages only to message queues of threads in processes of
|
||||
/// lesser or equal integrity level.
|
||||
/// </para>
|
||||
/// </param>
|
||||
/// <param name="msg">
|
||||
/// <para>The message to be sent.</para>
|
||||
/// <para>For lists of the system-provided messages, see System-Defined Messages.</para>
|
||||
/// </param>
|
||||
/// <param name="wParam">Additional message-specific information.</param>
|
||||
/// <param name="lParam">Additional message-specific information.</param>
|
||||
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
|
||||
// LRESULT WINAPI SendMessage( _In_ HWND hWnd, _In_ UINT Msg, _In_ WPARAM wParam, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx
|
||||
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
|
||||
[PInvokeData("Winuser.h", MSDNShortId = "ms644950")]
|
||||
[System.Security.SecurityCritical]
|
||||
public static extern IntPtr SendMessage(HWND hWnd, uint msg, [In] IntPtr wParam, [In, Out] StringBuilder lParam);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
|
||||
/// and does not return until the window procedure has processed the message.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Vanara.InteropServices;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
|
@ -102,10 +103,13 @@ namespace Vanara.PInvoke.Tests
|
|||
[Test()]
|
||||
public void SendMessageTest1()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var length = 256;
|
||||
var sb = new StringBuilder(length);
|
||||
Assert.That(SendMessage(FindWindow("Progman", null), (uint)WindowMessage.WM_GETTEXT, (IntPtr)sb.Capacity, sb).ToInt32(), Is.GreaterThanOrEqualTo(1));
|
||||
TestContext.WriteLine(sb);
|
||||
}
|
||||
|
||||
[Test()]
|
||||
[Test()]
|
||||
public void SendMessageTest2()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
Loading…
Reference in New Issue