-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of function SHAppBarMessage from ShellApi #245
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,23 @@ | |
import junit.framework.TestCase; | ||
|
||
import com.sun.jna.Native; | ||
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.WinDef.UINT_PTR; | ||
import com.sun.jna.ptr.PointerByReference; | ||
|
||
|
||
/** | ||
* @author dblock[at]dblock[dot]org | ||
* @author markus[at]headcrashing[dot]eu | ||
*/ | ||
public class Shell32Test extends TestCase { | ||
|
||
public static void main(String[] args) { | ||
private static final int RESIZE_HEIGHT = 500; | ||
private static final int WM_USER = 0x0400; | ||
|
||
public static void main(String[] args) { | ||
junit.textui.TestRunner.run(Shell32Test.class); | ||
} | ||
|
||
|
@@ -48,4 +56,90 @@ public final void testSHGetSpecialFolderPath() { | |
assertTrue(Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, ShlObj.CSIDL_APPDATA, false)); | ||
assertFalse(Native.toString(pszPath).isEmpty()); | ||
} | ||
|
||
|
||
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 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra space after |
||
} | ||
|
||
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 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another extra space, can you plese cleanup all these similar things? There're a few others, some functions have spaces in parameters, some don't like |
||
|
||
} | ||
|
||
private void queryPos( APPBARDATA ABData ) { | ||
DWORD dwABM = new DWORD(); | ||
|
||
dwABM.setValue(ShellAPI.ABM_QUERYPOS); | ||
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage( dwABM, ABData ); | ||
|
||
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(); | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add your name, similar to the other items below.