Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix code formatting
  • Loading branch information
bsorrentino committed Jun 22, 2013
1 parent 46fb75c commit 1646c3c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 105 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - [@bsorrentinoJ](https://github.com/bsorrentinoJ).
* [#241](https://github.com/twall/jna/issues/241) - Add support function SHAppBarMessage from ShellApi - [@bsorrentinoJ](https://github.com/bsorrentino).
* 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).
Expand Down
31 changes: 15 additions & 16 deletions contrib/platform/src/com/sun/jna/platform/win32/Shell32.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,23 @@ INT_PTR ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpPara
* SHAppBarMessage function
*
* @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.
* 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.
* 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 <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787951(v=vs.85).aspx">ABM_NEW</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787955(v=vs.85).aspx">ABM_REMOVE</a>
Expand All @@ -206,6 +206,5 @@ INT_PTR ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpPara
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787961(v=vs.85).aspx">ABM_SETSTATE</a>
*
*/

UINT_PTR SHAppBarMessage( DWORD dwMessage, APPBARDATA pData );
}
22 changes: 11 additions & 11 deletions contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ public String encodePaths(String[] paths) {
* Appbar message value to send. This parameter can be one of the following
* values.
*/
int ABM_NEW = 0x00000000;
DWORD ABM_NEW = new DWORD(0x00000000);
/**
* 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;
DWORD ABM_REMOVE = new DWORD(0x00000001);
/** Unregisters an appbar, removing the bar from the system's internal list.*/
int ABM_QUERYPOS = 0x00000002;
DWORD ABM_QUERYPOS = new DWORD(0x00000002);
/** Requests a size and screen position for an appbar. */
int ABM_SETPOS = 0x00000003;
DWORD ABM_SETPOS = new DWORD(0x00000003);
/** Sets the size and screen position of an appbar. */
int ABM_GETSTATE = 0x00000004;
DWORD ABM_GETSTATE = new DWORD(0x00000004);
/** Retrieves the autohide and always-on-top states of the Windows taskbar. */
int ABM_GETTASKBARPOS = 0x00000005;
DWORD ABM_GETTASKBARPOS = new DWORD(0x00000005);
/**
* Retrieves the bounding rectangle of the Windows taskbar. Note that this
* applies only to the system taskbar. Other objects, particularly toolbars
Expand All @@ -152,22 +152,22 @@ public String encodePaths(String[] paths) {
* both the taskbar and other app barsÑthe working area available to your
* applicationÑ, use the GetMonitorInfo function.
*/
int ABM_ACTIVATE = 0x00000006;
DWORD ABM_ACTIVATE = new DWORD(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.
*/
int ABM_GETAUTOHIDEBAR = 0x00000007;
DWORD ABM_GETAUTOHIDEBAR = new DWORD(0x00000007);
/**
* Retrieves the handle to the autohide appbar associated with a particular
* edge of the screen.
*/
int ABM_SETAUTOHIDEBAR = 0x00000008;
DWORD ABM_SETAUTOHIDEBAR = new DWORD(0x00000008);
/** Registers or unregisters an autohide appbar for an edge of the screen. */
int ABM_WINDOWPOSCHANGED = 0x00000009;
DWORD ABM_WINDOWPOSCHANGED = new DWORD(0x00000009);
/** Notifies the system when an appbar's position has changed. */
int ABM_SETSTATE = 0x0000000A;
DWORD ABM_SETSTATE = new DWORD(0x0000000A);

/** Left edge. */
int ABE_LEFT = 0;
Expand Down
139 changes: 62 additions & 77 deletions contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
public class Shell32Test extends TestCase {

private static final int RESIZE_HEIGHT = 500;
private static final int WM_USER = 0x0400;
private static final int WM_USER = 0x0400;

public static void main(String[] args) {
public static void main(String[] args) {
junit.textui.TestRunner.run(Shell32Test.class);
}

Expand Down Expand Up @@ -59,87 +59,72 @@ public final void testSHGetSpecialFolderPath() {


private void newAppBar() {
DWORD dwABM = new DWORD();

APPBARDATA ABData = new APPBARDATA.ByReference();
ABData.uCallbackMessage.setValue( WM_USER + 1);
ABData.cbSize.setValue( ABData.size() );
dwABM.setValue(ShellAPI.ABM_NEW);

UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData);
assertNotNull(result );
APPBARDATA data = new APPBARDATA.ByReference();
data.cbSize.setValue(data.size());
data.uCallbackMessage.setValue(WM_USER + 1);

UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage(ShellAPI.ABM_NEW, data);
assertNotNull(result);
}

private void removeAppBar() {

DWORD dwABM = new DWORD();
APPBARDATA ABData = new APPBARDATA.ByReference();
ABData.cbSize.setValue( ABData.size() );
dwABM.setValue(ShellAPI.ABM_REMOVE);
UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData);
assertNotNull(result );
private void removeAppBar() {
APPBARDATA data = new APPBARDATA.ByReference();
data.cbSize.setValue(data.size());
UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage(ShellAPI.ABM_REMOVE, data);
assertNotNull(result);

}

private void queryPos( APPBARDATA ABData ) {
DWORD dwABM = new DWORD();

dwABM.setValue(ShellAPI.ABM_QUERYPOS);
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData );
private void queryPos(APPBARDATA data) {
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(ShellAPI.ABM_QUERYPOS, data);

assertNotNull(h);
assertTrue(h.intValue() > 0);

}

public void testResizeDesktopFromBottom() throws InterruptedException {

newAppBar();

APPBARDATA data = new APPBARDATA.ByReference();

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(data);

UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(ShellAPI.ABM_SETPOS, data);

assertNotNull(h);
assertTrue(h.intValue() >= 0);

removeAppBar();
}

public void testResizeDesktopFromTop() throws InterruptedException {

newAppBar();

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);

UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(ShellAPI.ABM_SETPOS, data);

assertNotNull(h);
assertTrue(h.intValue() >= 0);

removeAppBar();

assertNotNull(h);
assertTrue(h.intValue()>0);

}

public void testResizeDesktopFromBottom() throws InterruptedException {

newAppBar();

DWORD dwABM = new DWORD();


APPBARDATA data = new APPBARDATA.ByReference();

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(data);

dwABM.setValue(ShellAPI.ABM_SETPOS);
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, data );

assertNotNull(h);
assertTrue(h.intValue()>=0);

removeAppBar();
}

public void testResizeDesktopFromTop() throws InterruptedException {
newAppBar();

DWORD dwABM = new DWORD();

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);
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, data );

assertNotNull(h);
assertTrue(h.intValue()>=0);

removeAppBar();

}

}

0 comments on commit 1646c3c

Please sign in to comment.