Search in sources :

Example 11 with User32

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

the class User32Test method testGetActiveWindow.

@Test
public void testGetActiveWindow() {
    HWND result = User32.INSTANCE.GetActiveWindow();
    assertNull("GetActiveWindow 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 12 with User32

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

the class User32Test method testSetWinEventHook.

@Test
public void testSetWinEventHook() {
    HANDLE result = User32.INSTANCE.SetWinEventHook(0, 0, null, null, 0, 0, 0);
    assertNull("SetWinEventHook result should be null", result);
    assertEquals("GetLastError should be ERROR_INVALID_FILTER_PROC.", WinError.ERROR_INVALID_FILTER_PROC, Native.getLastError());
}
Also used : HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE) Test(org.junit.Test)

Example 13 with User32

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

the class User32Test method testMonitorFromWindow.

@Test
public final void testMonitorFromWindow() {
    int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY;
    HWND hwnd = new HWND();
    assertNotNull(User32.INSTANCE.MonitorFromWindow(hwnd, dwFlags));
}
Also used : HWND(com.sun.jna.platform.win32.WinDef.HWND) Test(org.junit.Test)

Example 14 with User32

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

the class User32Test method testFindWindowEx.

@Test
public void testFindWindowEx() {
    HWND result = User32.INSTANCE.FindWindowEx(null, null, null, null);
    assertNotNull("FindWindowEx result should not 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 15 with User32

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

the class OpenGL32Test method testGetStringGLVersion.

public void testGetStringGLVersion() {
    // create a dummy window
    HWND hWnd = User32Util.createWindow("Message", null, 0, 0, 0, 0, 0, null, null, null, null);
    HDC hdc = User32.INSTANCE.GetDC(hWnd);
    // set a compatible pixel format
    PIXELFORMATDESCRIPTOR.ByReference pfd = new PIXELFORMATDESCRIPTOR.ByReference();
    pfd.nVersion = 1;
    pfd.dwFlags = WinGDI.PFD_DRAW_TO_WINDOW | WinGDI.PFD_SUPPORT_OPENGL | WinGDI.PFD_DOUBLEBUFFER;
    pfd.iPixelType = WinGDI.PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = WinGDI.PFD_MAIN_PLANE;
    GDI32.INSTANCE.SetPixelFormat(hdc, GDI32.INSTANCE.ChoosePixelFormat(hdc, pfd), pfd);
    // create the OpenGL context
    WinDef.HGLRC hGLRC = OpenGL32.INSTANCE.wglCreateContext(hdc);
    OpenGL32.INSTANCE.wglMakeCurrent(hdc, hGLRC);
    String glString = OpenGL32.INSTANCE.glGetString(GL.GL_VERSION);
    System.out.println("GL_VERSION=" + glString);
    OpenGL32.INSTANCE.wglDeleteContext(hGLRC);
    // destroy the window
    User32.INSTANCE.ReleaseDC(hWnd, hdc);
    User32Util.destroyWindow(hWnd);
    assertNotNull("Could not get GL_VERSION", glString);
}
Also used : HDC(com.sun.jna.platform.win32.WinDef.HDC) HWND(com.sun.jna.platform.win32.WinDef.HWND) PIXELFORMATDESCRIPTOR(com.sun.jna.platform.win32.WinGDI.PIXELFORMATDESCRIPTOR)

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