Search in sources :

Example 26 with User32

use of com.sun.jna.platform.win32.User32 in project jna by java-native-access.

the class Shell32Test method testResizeDesktopFromTop.

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 = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN) - RESIZE_DELTA;
    data.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
    queryPos(data);
    UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(new DWORD(ShellAPI.ABM_SETPOS), data);
    assertNotNull(h);
    assertTrue(h.intValue() >= 0);
    removeAppBar();
}
Also used : DWORD(com.sun.jna.platform.win32.WinDef.DWORD) UINT_PTR(com.sun.jna.platform.win32.WinDef.UINT_PTR) APPBARDATA(com.sun.jna.platform.win32.ShellAPI.APPBARDATA) PointerByReference(com.sun.jna.ptr.PointerByReference)

Example 27 with User32

use of com.sun.jna.platform.win32.User32 in project jna by java-native-access.

the class User32Test method testGetClassLongPtr.

@Test
public void testGetClassLongPtr() {
    if (System.getProperty("os.arch", "unknown").equalsIgnoreCase("amd64")) {
        DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");
        assertNotNull("Could not find explorer.exe process", explorerProc);
        ULONG_PTR result = User32.INSTANCE.GetClassLongPtr(explorerProc.getHWND(), WinUser.GCLP_HMODULE);
        assertNotEquals(0, result.intValue());
    } else {
        System.err.println("GetClassLongPtr only supported on x64");
    }
}
Also used : ULONG_PTR(com.sun.jna.platform.win32.BaseTSD.ULONG_PTR) DesktopWindow(com.sun.jna.platform.DesktopWindow) Test(org.junit.Test)

Example 28 with User32

use of com.sun.jna.platform.win32.User32 in project jna by java-native-access.

the class User32Test method testGetCursorPos.

@Test
public void testGetCursorPos() {
    POINT cursorPos = new POINT();
    boolean result = User32.INSTANCE.GetCursorPos(cursorPos);
    assertTrue("GetCursorPos should return true", result);
    assertTrue("X coordinate in POINT should be >= 0", cursorPos.x >= 0);
    assertTrue("Y coordinate in POINT should be >= 0", cursorPos.y >= 0);
}
Also used : POINT(com.sun.jna.platform.win32.WinDef.POINT) Test(org.junit.Test)

Example 29 with User32

use of com.sun.jna.platform.win32.User32 in project jna by java-native-access.

the class User32Test method testSetCursorPos.

@Test
public void testSetCursorPos() {
    POINT cursorPos = new POINT();
    boolean result = User32.INSTANCE.GetCursorPos(cursorPos);
    assertTrue("GetCursorPos should return true", result);
    assertTrue("X coordinate in POINT should be >= 0", cursorPos.x >= 0);
    boolean scpResult = User32.INSTANCE.SetCursorPos(cursorPos.x - 20, cursorPos.y);
    assertTrue("SetCursorPos should return true", scpResult);
    POINT cursorPos2 = new POINT();
    boolean result2 = User32.INSTANCE.GetCursorPos(cursorPos2);
    assertTrue("GetCursorPos should return true", result2);
    assertTrue("X coordinate in POINT should be original cursor position - 20", cursorPos2.x == cursorPos.x - 20);
}
Also used : POINT(com.sun.jna.platform.win32.WinDef.POINT) Test(org.junit.Test)

Example 30 with User32

use of com.sun.jna.platform.win32.User32 in project jna by java-native-access.

the class User32Test method testAdjustWindowRect.

@Test
public final void testAdjustWindowRect() {
    RECT lpRect = new RECT();
    lpRect.left = 100;
    lpRect.top = 200;
    lpRect.bottom = 300;
    lpRect.right = 500;
    assertTrue(User32.INSTANCE.AdjustWindowRect(lpRect, new DWORD(WinUser.WS_THICKFRAME), new BOOL(1)).booleanValue());
    assertTrue(lpRect.left < 100);
    assertTrue(lpRect.top < 200);
    assertTrue(lpRect.bottom > 300);
    assertTrue(lpRect.right > 500);
}
Also used : RECT(com.sun.jna.platform.win32.WinDef.RECT) BOOL(com.sun.jna.platform.win32.WinDef.BOOL) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 HWND (com.sun.jna.platform.win32.WinDef.HWND)20 HDC (com.sun.jna.platform.win32.WinDef.HDC)10 LPARAM (com.sun.jna.platform.win32.WinDef.LPARAM)8 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)8 Pointer (com.sun.jna.Pointer)7 LRESULT (com.sun.jna.platform.win32.WinDef.LRESULT)7 WPARAM (com.sun.jna.platform.win32.WinDef.WPARAM)7 RECT (com.sun.jna.platform.win32.WinDef.RECT)6 PIXELFORMATDESCRIPTOR (com.sun.jna.platform.win32.WinGDI.PIXELFORMATDESCRIPTOR)6 BufferedImage (java.awt.image.BufferedImage)5 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)4 HICON (com.sun.jna.platform.win32.WinDef.HICON)4 POINT (com.sun.jna.platform.win32.WinDef.POINT)4 PointerByReference (com.sun.jna.ptr.PointerByReference)4 File (java.io.File)4 Memory (com.sun.jna.Memory)3 DesktopWindow (com.sun.jna.platform.DesktopWindow)3 DWORD (com.sun.jna.platform.win32.WinDef.DWORD)3 HBITMAP (com.sun.jna.platform.win32.WinDef.HBITMAP)3