Search in sources :

Example 1 with MONITORINFOEX

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

the class User32Test method testGetMonitorInfo.

@Test
public final void testGetMonitorInfo() {
    HMONITOR hMon = User32.INSTANCE.MonitorFromWindow(User32.INSTANCE.GetDesktopWindow(), WinUser.MONITOR_DEFAULTTOPRIMARY);
    assertTrue(User32.INSTANCE.GetMonitorInfo(hMon, new MONITORINFO()).booleanValue());
    assertTrue(User32.INSTANCE.GetMonitorInfo(hMon, new MONITORINFOEX()).booleanValue());
}
Also used : HMONITOR(com.sun.jna.platform.win32.WinUser.HMONITOR) MONITORINFOEX(com.sun.jna.platform.win32.WinUser.MONITORINFOEX) MONITORINFO(com.sun.jna.platform.win32.WinUser.MONITORINFO) Test(org.junit.Test)

Example 2 with MONITORINFOEX

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

the class MonitorInfoDemo method enumerate.

static void enumerate(HMONITOR hMonitor) {
    System.out.println("Found HMONITOR: " + hMonitor.getPointer().toString());
    MONITORINFOEX info = new MONITORINFOEX();
    User32.INSTANCE.GetMonitorInfo(hMonitor, info);
    System.out.println("Screen " + info.rcMonitor);
    System.out.println("Work area " + info.rcWork);
    boolean isPrimary = (info.dwFlags & WinUser.MONITORINFOF_PRIMARY) != 0;
    System.out.println("Primary? " + (isPrimary ? "yes" : "no"));
    System.out.println("Device " + new String(info.szDevice));
    DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
    Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
    int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();
    System.out.println("HMONITOR is linked to " + monitorCount + " physical monitors");
    PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
    Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);
    for (int i = 0; i < monitorCount; i++) {
        HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
        System.out.println("Monitor " + i + " - " + new String(physMons[i].szPhysicalMonitorDescription));
        enumeratePhysicalMonitor(hPhysicalMonitor);
    }
    Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons);
}
Also used : MONITORINFOEX(com.sun.jna.platform.win32.WinUser.MONITORINFOEX) PHYSICAL_MONITOR(com.sun.jna.platform.win32.PhysicalMonitorEnumerationAPI.PHYSICAL_MONITOR) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE)

Aggregations

MONITORINFOEX (com.sun.jna.platform.win32.WinUser.MONITORINFOEX)2 PHYSICAL_MONITOR (com.sun.jna.platform.win32.PhysicalMonitorEnumerationAPI.PHYSICAL_MONITOR)1 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)1 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)1 HMONITOR (com.sun.jna.platform.win32.WinUser.HMONITOR)1 MONITORINFO (com.sun.jna.platform.win32.WinUser.MONITORINFO)1 Test (org.junit.Test)1