diff --git a/CHANGES.md b/CHANGES.md
index eb4d9dadaa..85cb9c89ac 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,7 +7,7 @@ NOTE: JNI native support is typically incompatible between minor versions, and a
Features
--------
-* [##241](https://github.com/twall/jna/issues/241) - Add support function SHAppBarMessage from ShellApi
+* [#241](https://github.com/twall/jna/issues/241) - Add support function SHAppBarMessage from ShellApi
* Added ASL licensing to facilitate distribution - [@twall](https://github.com/twall).
* [#109](https://github.com/twall/jna/issues/109): Set default Java compatibility level to 1.6 - [@twall](https://github.com/twall).
* [#209](https://github.com/twall/jna/issues/209): Improved default performance saving last error results - [@twall](https://github.com/twall).
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java b/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java
index 540b782a82..302766d272 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java
@@ -16,6 +16,7 @@
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.INT_PTR;
+import com.sun.jna.platform.win32.WinDef.UINT_PTR;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
@@ -172,61 +173,39 @@ INT_PTR ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpPara
/**
* SHAppBarMessage function
-4 out of 8 rated this helpful - Rate this topic
-Sends an appbar message to the system.
-Syntax
-C++
-
-UINT_PTR SHAppBarMessage(
- _In_ DWORD dwMessage,
- _Inout_ PAPPBARDATA pData
-);
-
-Parameters
-dwMessage [in]
-Type: DWORD
-Appbar message value to send. This parameter can be one of the following values.
-ABM_NEW (0x00000000)
-Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar.
-ABM_REMOVE (0x00000001)
-Unregisters an appbar, removing the bar from the system's internal list.
-ABM_QUERYPOS (0x00000002)
-Requests a size and screen position for an appbar.
-ABM_SETPOS (0x00000003)
-Sets the size and screen position of an appbar.
-ABM_GETSTATE (0x00000004)
-Retrieves the autohide and always-on-top states of the Windows taskbar.
-ABM_GETTASKBARPOS (0x00000005)
-Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app barsÑthe working area available to your applicationÑ, use the GetMonitorInfo function.
-ABM_ACTIVATE (0x00000006)
-Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate.
-ABM_GETAUTOHIDEBAR (0x00000007)
-Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
-ABM_SETAUTOHIDEBAR (0x00000008)
-Registers or unregisters an autohide appbar for an edge of the screen.
-ABM_WINDOWPOSCHANGED (0x00000009)
-Notifies the system when an appbar's position has changed.
-ABM_SETSTATE (0x0000000A)
-Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes.
-pData [in, out]
-Type: PAPPBARDATA
-A pointer to an APPBARDATA structure. The content of the structure on entry and on exit depends on the value set in the dwMessage parameter. See the individual message pages for specifics.
-Return value
-Type: UINT_PTR
-This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar message sent. Links to those documents are given in the See Also section.
-Requirements
-Minimum supported client
-Windows XP [desktop apps only]
-Minimum supported server
-Windows 2000 Server [desktop apps only]
-Header
-Shellapi.h
-Library
-Shell32.lib
-DLL
-Shell32.dll (version 4.0 or later)
-
+ *
+ * @param dwMessage
+ * Appbar message value to send. This parameter can be one of the following values.
+ * {@link ShellAPI#ABM_NEW} Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar.
+ * {@link ShellAPI#ABM_REMOVE} Unregisters an appbar, removing the bar from the system's internal list.
+ * {@link ShellAPI#ABM_QUERYPOS} Requests a size and screen position for an appbar.
+ * {@link ShellAPI#ABM_SETPOS} Sets the size and screen position of an appbar.
+ * {@link ShellAPI#ABM_GETSTATE} Retrieves the autohide and always-on-top states of the Windows taskbar.
+ * {@link ShellAPI#ABM_GETTASKBARPOS} Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app barsÑthe working area available to your applicationÑ, use the GetMonitorInfo function.
+ * {@link ShellAPI#ABM_ACTIVATE} Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate.
+ * {@link ShellAPI#ABM_GETAUTOHIDEBAR} Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
+ * {@link ShellAPI#ABM_SETAUTOHIDEBAR} Registers or unregisters an autohide appbar for an edge of the screen.
+ * {@link ShellAPI#ABM_WINDOWPOSCHANGED} Notifies the system when an appbar's position has changed.
+ * {@link ShellAPI#ABM_SETSTATE} Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes.
+ *
+ * @param pData
+ * A pointer to an APPBARDATA structure. The content of the structure on entry and on exit depends on the value set in the dwMessage parameter. See the individual message pages for specifics.
+ *
+ * @return This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar message sent.
+ *
+ * @see ABM_NEW
+ * @see ABM_REMOVE
+ * @see ABM_QUERYPOS
+ * @see ABM_SETPOS
+ * @see ABM_GETSTATE
+ * @see ABM_GETTASKBARPOS
+ * @see ABM_ACTIVATE
+ * @see ABM_GETAUTOHIDEBAR
+ * @see ABM_SETAUTOHIDEBAR
+ * @see ABM_WINDOWPOSCHANGED
+ * @see ABM_SETSTATE
+ *
*/
- HANDLE SHAppBarMessage( DWORD dwMessage, APPBARDATA pData );
+ UINT_PTR SHAppBarMessage( DWORD dwMessage, APPBARDATA pData );
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java
index 2645e092fd..0ce46115d7 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java
@@ -125,61 +125,85 @@ public String encodePaths(String[] paths) {
}
- // Appbar message value to send. This parameter can be one of the following values.
+ /**
+ * Appbar message value to send. This parameter can be one of the following
+ * values.
+ */
int ABM_NEW = 0x00000000;
- //Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar.
+ /**
+ * Registers a new appbar and specifies the message identifier that the
+ * system should use to send notification messages to the appbar.
+ */
int ABM_REMOVE = 0x00000001;
- //Unregisters an appbar, removing the bar from the system's internal list.
+ /** Unregisters an appbar, removing the bar from the system's internal list.*/
int ABM_QUERYPOS = 0x00000002;
- //Requests a size and screen position for an appbar.
+ /** Requests a size and screen position for an appbar. */
int ABM_SETPOS = 0x00000003;
- //Sets the size and screen position of an appbar.
+ /** Sets the size and screen position of an appbar. */
int ABM_GETSTATE = 0x00000004;
- //Retrieves the autohide and always-on-top states of the Windows taskbar.
+ /** Retrieves the autohide and always-on-top states of the Windows taskbar. */
int ABM_GETTASKBARPOS = 0x00000005;
- //Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app barsÑthe working area available to your applicationÑ, use the GetMonitorInfo function.
+ /**
+ * Retrieves the bounding rectangle of the Windows taskbar. Note that this
+ * applies only to the system taskbar. Other objects, particularly toolbars
+ * supplied with third-party software, also can be present. As a result,
+ * some of the screen area not covered by the Windows taskbar might not be
+ * visible to the user. To retrieve the area of the screen not covered by
+ * both the taskbar and other app barsÑthe working area available to your
+ * applicationÑ, use the GetMonitorInfo function.
+ */
int ABM_ACTIVATE = 0x00000006;
- //Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate.
+ /**
+ * Notifies the system to activate or deactivate an appbar. The lParam
+ * member of the APPBARDATA pointed to by pData is set to TRUE to activate
+ * or FALSE to deactivate.
+ */
int ABM_GETAUTOHIDEBAR = 0x00000007;
- //Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
+ /**
+ * Retrieves the handle to the autohide appbar associated with a particular
+ * edge of the screen.
+ */
int ABM_SETAUTOHIDEBAR = 0x00000008;
- //Registers or unregisters an autohide appbar for an edge of the screen.
+ /** Registers or unregisters an autohide appbar for an edge of the screen. */
int ABM_WINDOWPOSCHANGED = 0x00000009;
- //Notifies the system when an appbar's position has changed.
+ /** Notifies the system when an appbar's position has changed. */
int ABM_SETSTATE = 0x0000000A;
- int ABE_LEFT = 0; // Left edge.
- int ABE_TOP = 1; // Top edge.
- int ABE_RIGHT = 2; // Right edge.
- int ABE_BOTTOM = 3; // Bottom edge.
-
+ /** Left edge. */
+ int ABE_LEFT = 0;
+ /** Top edge. */
+ int ABE_TOP = 1;
+ /** Right edge. */
+ int ABE_RIGHT = 2;
+ /** Bottom edge. */
+ int ABE_BOTTOM = 3;
+
/**
* Contains information about a system appbar message.
*/
public static class APPBARDATA extends Structure {
- public static class ByReference extends APPBARDATA implements Structure.ByReference {}
+ public static class ByReference extends APPBARDATA implements Structure.ByReference {
+ }
- public DWORD cbSize;
- public HWND hWnd;
- public UINT uCallbackMessage;
- public UINT uEdge;
- public RECT rc;
- public LPARAM lParam;
+ public DWORD cbSize;
+ public HWND hWnd;
+ public UINT uCallbackMessage;
+ public UINT uEdge;
+ public RECT rc;
+ public LPARAM lParam;
- public APPBARDATA() {
- super();
+ public APPBARDATA() {
+ super();
}
- public APPBARDATA(Pointer p) {
- super(p);
- }
+ public APPBARDATA(Pointer p) {
+ super(p);
+ }
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("cbSize", "hWnd", "uCallbackMessage", "uEdge",
- "rc", "lParam");
- }
-
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList("cbSize", "hWnd", "uCallbackMessage", "uEdge", "rc", "lParam");
+ }
}
}
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
index 1002c12896..a5f932e2a4 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
@@ -18,7 +18,7 @@
import com.sun.jna.platform.win32.ShellAPI.APPBARDATA;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.RECT;
-import com.sun.jna.platform.win32.WinNT.HANDLE;
+import com.sun.jna.platform.win32.WinDef.UINT_PTR;
import com.sun.jna.ptr.PointerByReference;
@@ -35,12 +35,6 @@ public static void main(String[] args) {
junit.textui.TestRunner.run(Shell32Test.class);
}
- public void setup() {
-
- APPBARDATA ABData = new APPBARDATA();
-
-
- }
public void testSHGetFolderPath() {
char[] pszPath = new char[WinDef.MAX_PATH];
assertEquals(W32Errors.S_OK, Shell32.INSTANCE.SHGetFolderPath(null,
@@ -62,8 +56,9 @@ public final void testSHGetSpecialFolderPath() {
assertTrue(Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, ShlObj.CSIDL_APPDATA, false));
assertFalse(Native.toString(pszPath).isEmpty());
}
+
- private boolean AppBar_Register() {
+ private void newAppBar() {
DWORD dwABM = new DWORD();
APPBARDATA ABData = new APPBARDATA.ByReference();
@@ -71,83 +66,79 @@ private boolean AppBar_Register() {
ABData.cbSize.setValue( ABData.size() );
dwABM.setValue(ShellAPI.ABM_NEW);
- return (null!=Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData));
+ UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData);
+ assertNotNull(result );
}
- private boolean AppBar_Unregister() {
+ private void removeAppBar() {
+
DWORD dwABM = new DWORD();
APPBARDATA ABData = new APPBARDATA.ByReference();
ABData.cbSize.setValue( ABData.size() );
dwABM.setValue(ShellAPI.ABM_REMOVE);
- return (null!=Shell32.INSTANCE.SHAppBarMessage(dwABM, ABData));
+ UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData);
+ assertNotNull(result );
+
}
- public void queryPos( APPBARDATA ABData ) {
+ private void queryPos( APPBARDATA ABData ) {
DWORD dwABM = new DWORD();
dwABM.setValue(ShellAPI.ABM_QUERYPOS);
- HANDLE h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData );
+ UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData );
assertNotNull(h);
+ assertTrue(h.intValue()>0);
- System.out.printf( "ABData.rc[%d,%d,%d,%d]\n",
- ABData.rc.top,
- ABData.rc.left,
- ABData.rc.bottom,
- ABData.rc.right);
-
}
public void testResizeDesktopFromBottom() throws InterruptedException {
+ newAppBar();
+
DWORD dwABM = new DWORD();
- assertTrue( AppBar_Register() );
- APPBARDATA ABData = new APPBARDATA.ByReference();
- System.out.printf( "APPBARDATA sizeof [%d]\n", ABData.size());
+ APPBARDATA data = new APPBARDATA.ByReference();
- ABData.uEdge.setValue(ShellAPI.ABE_BOTTOM);
- ABData.rc.top = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN) - RESIZE_HEIGHT;
- ABData.rc.left = 0;
- ABData.rc.bottom = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN);
- ABData.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
+ data.uEdge.setValue(ShellAPI.ABE_BOTTOM);
+ data.rc.top = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN) - RESIZE_HEIGHT;
+ data.rc.left = 0;
+ data.rc.bottom = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN);
+ data.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
- queryPos(ABData);
+ queryPos(data);
dwABM.setValue(ShellAPI.ABM_SETPOS);
- HANDLE h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData );
+ UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, data );
assertNotNull(h);
-
-
- Thread.sleep( 5 * 1000 );
- assertTrue( AppBar_Unregister() );
-
+ assertTrue(h.intValue()>=0);
+
+ removeAppBar();
}
public void testResizeDesktopFromTop() throws InterruptedException {
+ newAppBar();
DWORD dwABM = new DWORD();
- assertTrue( AppBar_Register() );
-
- APPBARDATA ABData = new APPBARDATA.ByReference();
- ABData.uEdge.setValue(ShellAPI.ABE_TOP);
- ABData.rc.top = 0;
- ABData.rc.left = 0;
- ABData.rc.bottom = RESIZE_HEIGHT;
- ABData.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
-
- queryPos(ABData);
+ APPBARDATA data = new APPBARDATA.ByReference();
+ data.uEdge.setValue(ShellAPI.ABE_TOP);
+ data.rc.top = 0;
+ data.rc.left = 0;
+ data.rc.bottom = RESIZE_HEIGHT;
+ data.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
+
+ queryPos(data);
dwABM.setValue(ShellAPI.ABM_SETPOS);
- HANDLE h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData );
+ UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, data );
assertNotNull(h);
+ assertTrue(h.intValue()>=0);
- Thread.sleep( 5 * 1000 );
- assertTrue( AppBar_Unregister() );
+ removeAppBar();
}