Move edit window lookup too

This commit is contained in:
Yaakov 2020-05-21 17:40:53 +10:00
parent 75db9915a5
commit e512889b17
2 changed files with 8 additions and 2 deletions

View file

@ -85,8 +85,7 @@ namespace Microsoft.Extensions.Logging
static void WriteToNotepad(string message)
{
IntPtr hwnd = WindowFinder.FindNotepadWindow();
IntPtr edit = NativeMethods.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null);
NativeMethods.SendMessage(edit, NativeMethods.EM_REPLACESEL, (IntPtr)1, message);
NativeMethods.SendMessage(hwnd, NativeMethods.EM_REPLACESEL, (IntPtr)1, message);
}
}
}

View file

@ -5,6 +5,13 @@ namespace Microsoft.Extensions.Logging
static class WindowFinder
{
public static IntPtr FindNotepadWindow()
{
var hwnd = FindMainWindow();
IntPtr edit = NativeMethods.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null);
return edit;
}
static IntPtr FindMainWindow()
{
IntPtr hwnd;