diff --git a/CHANGES.md b/CHANGES.md index f258b9a91e..e07e7bade6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Features * [#1337](https://github.com/java-native-access/jna/pull/1337): Add `REG_NOTIFY_THREAD_AGNOSTIC` to `c.s.j.p.win32.WinNet` and update `REG_LEGAL_CHANGE_FILTER` - [@Dani-Hub](https://github.com/Dani-Hub). * [#1338](https://github.com/java-native-access/jna/pull/1338): Add `RegNotifyChangeKeyValue` to `c.s.j.p.win32.Advapi32` - [@Dani-Hub](https://github.com/Dani-Hub). * [#1340](https://github.com/java-native-access/jna/issues/1340): Added `CM_Get_DevNode_Registry_Property` to `c.s.j.p.win32.Cfgmgr32` and corresponding util in `c.s.j.p.win32.Cfgmgr32Util` - [@dbwiddis](https://github.com/dbwiddis). +* [#1352](https://github.com/java-native-access/jna/pull/1352): Add `BringWindowToTop` to `c.s.j.p.win32.User32` - [@kahgoh](https://github.com/kahgoh) Bug Fixes --------- diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index 8179155716..4c86920638 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -359,6 +359,18 @@ public interface User32 extends StdCallLibrary, WinUser, WinNT { */ boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data); + + /** + * Brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If + * the window is a child window, the top-level parent window associated with the child window is activated. + * + * @param hWnd + * A handle to the window to bring to the top of the Z order. + * @return If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. + * To get extended error information, call GetLastError. + */ + boolean BringWindowToTop(HWND hWnd); + /** * The FlashWindowEx function flashes the specified window. It does not * change the active state of the window. diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index 7c2b890777..a35073e190 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -439,6 +439,12 @@ public void testGetActiveWindow() { assertNull("GetActiveWindow result should be null (there is no active window)", result); } + @Test + public void testBringWindowToTop() { + boolean result = User32.INSTANCE.BringWindowToTop(null); + assertFalse("BringWindowToTop result should be false", result); + } + @Test public void testSendMessage() { DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");