本文整理汇总了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));
}
示例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;
}
示例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));
}
示例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);
}
示例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;
}
示例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();
}
示例7: GetWindowRect
boolean GetWindowRect(Pointer hWnd, WinDef.RECT rect);
示例8: TrackPopupMenu
public WinDef.BOOL TrackPopupMenu(WinDef.HMENU hMenu, WinDef.UINT uFlags, int x, int y, int nReserved, WinDef.HWND hWnd, WinDef.RECT prcRect);