Search in sources :

Example 31 with User32

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

the class User32Test method testCopyIcon.

@Test
public void testCopyIcon() {
    HICON result = User32.INSTANCE.CopyIcon(null);
    assertNull("CopyIcon result should be false", result);
    assertEquals("GetLastError should be ERROR_INVALID_CURSOR_HANDLE.", WinError.ERROR_INVALID_CURSOR_HANDLE, Native.getLastError());
}
Also used : HICON(com.sun.jna.platform.win32.WinDef.HICON) Test(org.junit.Test)

Example 32 with User32

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

the class User32Test method testGetAncestor.

@Test
public void testGetAncestor() {
    HWND desktopWindow = User32.INSTANCE.GetDesktopWindow();
    assertNotNull("Failed to get desktop window HWND", desktopWindow);
    HWND result = User32.INSTANCE.GetAncestor(desktopWindow, WinUser.GA_PARENT);
    assertNull("GetAncestor result should be null", result);
    assertEquals("GetLastError should be ERROR_SUCCESS.", WinError.ERROR_SUCCESS, Native.getLastError());
}
Also used : HWND(com.sun.jna.platform.win32.WinDef.HWND) Test(org.junit.Test)

Example 33 with User32

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

the class User32Test method testMonitorFromPoint.

@Test
public final void testMonitorFromPoint() {
    int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY;
    POINT pt = new POINT(0, 0);
    assertNotNull(User32.INSTANCE.MonitorFromPoint(pt, dwFlags));
}
Also used : POINT(com.sun.jna.platform.win32.WinDef.POINT) Test(org.junit.Test)

Example 34 with User32

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

the class User32Test method testGetIconInfo.

@Test
public void testGetIconInfo() throws Exception {
    final ICONINFO iconInfo = new ICONINFO();
    final HANDLE hImage = User32.INSTANCE.LoadImage(null, new File(getClass().getResource("/res/test_icon.ico").toURI()).getAbsolutePath(), WinUser.IMAGE_ICON, 0, 0, WinUser.LR_LOADFROMFILE);
    try {
        // obtain test icon from classpath
        if (!User32.INSTANCE.GetIconInfo(new HICON(hImage), iconInfo))
            throw new Exception("Invocation of User32.GetIconInfo() failed: " + Kernel32Util.getLastErrorMessage());
        iconInfo.read();
    } finally {
        if (iconInfo.hbmColor != null && iconInfo.hbmColor.getPointer() != Pointer.NULL)
            GDI32.INSTANCE.DeleteObject(iconInfo.hbmColor);
        if (iconInfo.hbmMask != null && iconInfo.hbmMask.getPointer() != Pointer.NULL)
            GDI32.INSTANCE.DeleteObject(iconInfo.hbmMask);
    }
}
Also used : ICONINFO(com.sun.jna.platform.win32.WinGDI.ICONINFO) HICON(com.sun.jna.platform.win32.WinDef.HICON) HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE) File(java.io.File) AWTException(java.awt.AWTException) Test(org.junit.Test)

Example 35 with User32

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

the class Dxva2Test method setUp.

@Before
public void setUp() {
    HMONITOR hMonitor = User32.INSTANCE.MonitorFromWindow(User32.INSTANCE.GetDesktopWindow(), WinUser.MONITOR_DEFAULTTOPRIMARY);
    DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
    assertTrue(Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors).booleanValue());
    monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();
    physMons = new PHYSICAL_MONITOR[monitorCount];
    assumeTrue(Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons).booleanValue());
}
Also used : HMONITOR(com.sun.jna.platform.win32.WinUser.HMONITOR) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference)

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