当前位置: 首页>>代码示例>>Java>>正文


Java WinDef.RECT属性代码示例

本文整理汇总了Java中com.sun.jna.platform.win32.WinDef.RECT属性的典型用法代码示例。如果您正苦于以下问题:Java WinDef.RECT属性的具体用法?Java WinDef.RECT怎么用?Java WinDef.RECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.jna.platform.win32.WinDef的用法示例。


在下文中一共展示了WinDef.RECT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: capture

/**
 * Captures the window.
 *
 * @param hwnd The window to capture.
 * @param filename Name to save the output into.
 * @throws AWTException Robot exception.
 * @throws IOException IO Exception.
 */
public static void capture(final WinDef.HWND hwnd,
                           final String filename)
        throws AWTException, IOException, Win32Exception {
    ensureWinApiInstances();
    
    WinDef.RECT rect = new WinDef.RECT();

    if (!user32.GetWindowRect(hwnd, rect)) {
        throw new Win32Exception(kernel32.GetLastError());
    }

    Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right -rect.left, rect.bottom -rect.top);

    BufferedImage image = new Robot().createScreenCapture(rectangle);

    ImageIO.write(image, "png", new File(filename));
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:25,代码来源:Utils.java

示例2: getBoundingRectangle

/**
 * Gets the bounding rectangle of the control.
 *
 * @return The bounding rectangle.
 * @throws AutomationException Call to Automation API failed.
 */
public WinDef.RECT getBoundingRectangle() throws AutomationException {
    WinDef.RECT rect = new WinDef.RECT();

    final int res = this.element.getCurrentBoundingRectangle(rect);
    if (res != 0) {
        throw new AutomationException(res);
    }

    return rect;
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:16,代码来源:AutomationElement.java

示例3: testGetCurrentBoundingRectangleForDesktop

@Test
public void testGetCurrentBoundingRectangleForDesktop() throws AutomationException {
	AutomationElement root = instance.getRootElement();

	WinDef.RECT empty = new WinDef.RECT();

	assertTrue("root:" + root.getBoundingRectangle(), !root.getBoundingRectangle().dataEquals(empty));
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:8,代码来源:AutomationElementTest.java

示例4: getWindowArea

public static Rectangle getWindowArea(Pointer hWnd)
{
    if(!isKernelAvailable() || hWnd == null)return null;
    WinDef.RECT rect = new WinDef.RECT();
    user32.GetWindowRect(hWnd, rect);
    return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
 
开发者ID:thatdude624,项目名称:Spark-Reader,代码行数:7,代码来源:KernelController.java

示例5: drawIcon

public static boolean drawIcon(BufferedImage ret, WinDef.HICON hIcon, int diFlags) {

        WinDef.HDC hdcScreen = User32.INSTANCE.GetDC(null);
        WinDef.HDC hdcMem = Gdi32.INSTANCE.CreateCompatibleDC(hdcScreen);

        WinDef.HBITMAP bitmap = Gdi32.INSTANCE.CreateCompatibleBitmap(hdcScreen, ret.getWidth(), ret.getHeight());

        WinNT.HANDLE hbmOld = Gdi32.INSTANCE.SelectObject(hdcMem, bitmap);

        WinNT.HANDLE hBrush = Gdi32.INSTANCE.CreateSolidBrush(new WinDef.DWORD(0xffffff));
        WinDef.RECT rect = new WinDef.RECT();
        rect.left = 0;
        rect.top = 0;
        rect.right = ret.getWidth();
        rect.bottom = ret.getHeight();
        User32.INSTANCE.FillRect(hdcMem, rect, hBrush);
        Gdi32.INSTANCE.DeleteObject(hBrush);

        boolean ok = User32.INSTANCE.DrawIconEx(hdcMem, 0, 0, hIcon, ret.getWidth(), ret.getHeight(), new WinDef.UINT(0), new WinDef.HBRUSH(Pointer.NULL), diFlags);

        if (!ok) {
            return false;
        }

        for (int x = 0; x < ret.getWidth(); x++) {
            for (int y = 0; y < ret.getHeight(); y++) {
                int rgb = Gdi32.INSTANCE.GetPixel(hdcMem, x, y).intValue();
                int r = (rgb >> 16) & 0xff;
                int g = (rgb >> 8) & 0xff;
                int b = (rgb) & 0xff;
                rgb = (b << 16) + (g << 8) + r;
                ret.setRGB(x, y, rgb);
            }
        }

        Gdi32.INSTANCE.SelectObject(hdcMem, hbmOld);
        Gdi32.INSTANCE.DeleteObject(bitmap);
        Gdi32.INSTANCE.DeleteDC(hdcMem);
        User32.INSTANCE.ReleaseDC(null, hdcScreen);
        return true;
    }
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:41,代码来源:Win32ProcessTools.java

示例6: getBoundingRectangle

/**
 * Gets the bounding rectangle of the control.
 *
 * @return The bounding rectangle
 * @throws AutomationException Something is wrong in automation
 */
public WinDef.RECT getBoundingRectangle() throws AutomationException {
    return this.element.getBoundingRectangle();
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:9,代码来源:AutomationBase.java

示例7: GetWindowRect

boolean GetWindowRect(Pointer hWnd, WinDef.RECT rect); 
开发者ID:thatdude624,项目名称:Spark-Reader,代码行数:1,代码来源:User32.java

示例8: TrackPopupMenu

public WinDef.BOOL TrackPopupMenu(WinDef.HMENU hMenu, WinDef.UINT uFlags, int x, int y, int nReserved, WinDef.HWND hWnd, WinDef.RECT prcRect); 
开发者ID:vanjadardic,项目名称:KiTTY2,代码行数:1,代码来源:User32.java


注:本文中的com.sun.jna.platform.win32.WinDef.RECT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。