Skip to content

Commit 44e26ef

Browse files
authored
feat: Implements WebViewExtWindows::hwnd and InnerWebView::hwnd handler (#1712)
1 parent e279967 commit 44e26ef

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

.changes/forward-hwnd-handler.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": minor
3+
---
4+
5+
On Windows, Add `WebViewExtWindows::hwnd` getter to access the child HWND containing the webview.

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,9 @@ pub trait WebViewExtWindows {
22552255

22562256
/// Attaches this webview to the given HWND and removes it from the current one.
22572257
fn reparent(&self, hwnd: isize) -> Result<()>;
2258+
2259+
/// Returns the child HWND hosting this webview.
2260+
fn hwnd(&self) -> windows::Win32::Foundation::HWND;
22582261
}
22592262

22602263
#[cfg(target_os = "windows")]
@@ -2282,6 +2285,11 @@ impl WebViewExtWindows for WebView {
22822285
fn reparent(&self, hwnd: isize) -> Result<()> {
22832286
self.webview.reparent(hwnd)
22842287
}
2288+
2289+
/// Returns the child HWND hosting this webview.
2290+
fn hwnd(&self) -> windows::Win32::Foundation::HWND {
2291+
self.webview.hwnd()
2292+
}
22852293
}
22862294

22872295
/// Additional methods on `WebView` that are specific to Linux.

src/webview2/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,11 @@ impl InnerWebView {
13721372
&self.id
13731373
}
13741374

1375+
#[inline]
1376+
pub fn hwnd(&self) -> HWND {
1377+
self.hwnd
1378+
}
1379+
13751380
pub fn eval(
13761381
&self,
13771382
js: &str,

0 commit comments

Comments
 (0)