Search in sources :

Example 1 with HMONITOR

use of com.sun.jna.platform.win32.WinUser.HMONITOR 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 HMONITOR

use of com.sun.jna.platform.win32.WinUser.HMONITOR 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)

Example 3 with HMONITOR

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

the class MonitorInfoDemo method main.

/**
	 * @param args (ignored)
	 */
public static void main(String[] args) {
    System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));
    User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {

        @Override
        public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam) {
            enumerate(hMonitor);
            return 1;
        }
    }, new LPARAM(0));
}
Also used : HMONITOR(com.sun.jna.platform.win32.WinUser.HMONITOR) RECT(com.sun.jna.platform.win32.WinDef.RECT) HDC(com.sun.jna.platform.win32.WinDef.HDC) LPARAM(com.sun.jna.platform.win32.WinDef.LPARAM) MONITORENUMPROC(com.sun.jna.platform.win32.WinUser.MONITORENUMPROC)

Example 4 with HMONITOR

use of com.sun.jna.platform.win32.WinUser.HMONITOR 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

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