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());
}
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());
}
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));
}
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);
}
}
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());
}
Aggregations