Skip to content

Commit

Permalink
Add BringWindowToTop to User32
Browse files Browse the repository at this point in the history
  • Loading branch information
kahgoh committed Jun 5, 2021
1 parent b7b48c9 commit 11216ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
12 changes: 12 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/User32.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 11216ed

Please sign in to comment.