Add BrowserWindow.GetNativeWindowHandle()

This commit is contained in:
kdl
2020-06-11 22:45:18 +02:00
parent 8c8115f3bd
commit 490440c23a
4 changed files with 29 additions and 1 deletions

View File

@@ -1809,6 +1809,25 @@ namespace ElectronNET.API
return taskCompletionSource.Task;
}
/// <summary>
/// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
/// </summary>
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
public Task<string> GetNativeWindowHandle()
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("browserWindow-getNativeWindowHandle-completed", (nativeWindowHandle) =>
{
BridgeConnector.Socket.Off("browserWindow-getNativeWindowHandle-completed");
taskCompletionSource.SetResult(nativeWindowHandle.ToString());
});
BridgeConnector.Socket.Emit("browserWindowGetNativeWindowHandle", Id);
return taskCompletionSource.Task;
}
/// <summary>
/// Sets the pathname of the file the window represents,
/// and the icon of the file will show in windows title bar.