rows * cols components of
- * parent in a grid. Each component is as big as the maximum
- * preferred width and height of the components. The parent is made just big
- * enough to fit them all.
- *
- * @param parent
- * @param rows number of rows
- * @param cols number of columns
- * @param initialX x location to start the grid at
- * @param initialY y location to start the grid at
- * @param xPad x padding between cells
- * @param yPad y padding between cells
- */
- public static void makeGrid(Container parent,
- int rows, int cols,
- int initialX, int initialY,
- int xPad, int yPad) {
- SpringLayout layout;
- try {
- layout = (SpringLayout) parent.getLayout();
- } catch (ClassCastException exc) {
- System.err.println("The first argument to makeGrid must use SpringLayout.");
- return;
- }
-
- Spring xPadSpring = Spring.constant(xPad);
- Spring yPadSpring = Spring.constant(yPad);
- Spring initialXSpring = Spring.constant(initialX);
- Spring initialYSpring = Spring.constant(initialY);
- int max = rows * cols;
-
- //Calculate Springs that are the max of the width/height so that all
- //cells have the same size.
- Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
- getWidth();
- Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
- getHeight();
- for (int i = 1; i < max; i++) {
- SpringLayout.Constraints cons = layout.getConstraints(
- parent.getComponent(i));
-
- maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
- maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
- }
-
- //Apply the new width/height Spring. This forces all the
- //components to have the same size.
- for (int i = 0; i < max; i++) {
- SpringLayout.Constraints cons = layout.getConstraints(
- parent.getComponent(i));
-
- cons.setWidth(maxWidthSpring);
- cons.setHeight(maxHeightSpring);
- }
-
- //Then adjust the x/y constraints of all the cells so that they
- //are aligned in a grid.
- SpringLayout.Constraints lastCons = null;
- SpringLayout.Constraints lastRowCons = null;
- for (int i = 0; i < max; i++) {
- SpringLayout.Constraints cons = layout.getConstraints(
- parent.getComponent(i));
- if (i % cols == 0) { //start of new row
- lastRowCons = lastCons;
- cons.setX(initialXSpring);
- } else { //x position depends on previous component
- cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
- xPadSpring));
- }
-
- if (i / cols == 0) { //first row
- cons.setY(initialYSpring);
- } else { //y position depends on previous row
- cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
- yPadSpring));
- }
- lastCons = cons;
- }
-
- //Set the parent's size.
- SpringLayout.Constraints pCons = layout.getConstraints(parent);
- pCons.setConstraint(SpringLayout.SOUTH,
- Spring.sum(
- Spring.constant(yPad),
- lastCons.getConstraint(SpringLayout.SOUTH)));
- pCons.setConstraint(SpringLayout.EAST,
- Spring.sum(
- Spring.constant(xPad),
- lastCons.getConstraint(SpringLayout.EAST)));
- }
-
- /* Used by makeCompactGrid. */
- private static SpringLayout.Constraints getConstraintsForCell(
- int row, int col,
- Container parent,
- int cols) {
- SpringLayout layout = (SpringLayout) parent.getLayout();
- Component c = parent.getComponent(row * cols + col);
- return layout.getConstraints(c);
- }
-
- /**
- * Aligns the first rows * cols components of
- * parent in a grid. Each component in a column is as wide as
- * the maximum preferred width of the components in that column; height is
- * similarly determined for each row. The parent is made just big enough to
- * fit them all.
- *
- * @param parent
- * @param rows number of rows
- * @param cols number of columns
- * @param initialX x location to start the grid at
- * @param initialY y location to start the grid at
- * @param xPad x padding between cells
- * @param yPad y padding between cells
- */
- public static void makeCompactGrid(Container parent,
- int rows, int cols,
- int initialX, int initialY,
- int xPad, int yPad) {
- SpringLayout layout;
- try {
- layout = (SpringLayout) parent.getLayout();
- } catch (ClassCastException exc) {
- System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
- return;
- }
-
- //Align all cells in each column and make them the same width.
- Spring x = Spring.constant(initialX);
- for (int c = 0; c < cols; c++) {
- Spring width = Spring.constant(0);
- for (int r = 0; r < rows; r++) {
- width = Spring.max(width,
- getConstraintsForCell(r, c, parent, cols).
- getWidth());
- }
- for (int r = 0; r < rows; r++) {
- SpringLayout.Constraints constraints
- = getConstraintsForCell(r, c, parent, cols);
- constraints.setX(x);
- constraints.setWidth(width);
- }
- x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
- }
-
- //Align all cells in each row and make them the same height.
- Spring y = Spring.constant(initialY);
- for (int r = 0; r < rows; r++) {
- Spring height = Spring.constant(0);
- for (int c = 0; c < cols; c++) {
- height = Spring.max(height,
- getConstraintsForCell(r, c, parent, cols).
- getHeight());
- }
- for (int c = 0; c < cols; c++) {
- SpringLayout.Constraints constraints
- = getConstraintsForCell(r, c, parent, cols);
- constraints.setY(y);
- constraints.setHeight(height);
- }
- y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
- }
-
- //Set the parent's size.
- SpringLayout.Constraints pCons = layout.getConstraints(parent);
- pCons.setConstraint(SpringLayout.SOUTH, y);
- pCons.setConstraint(SpringLayout.EAST, x);
- }
-}
+/*
+ * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle or the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jpexs.decompiler.flash.gui.helpers;
+
+import java.awt.Component;
+import java.awt.Container;
+import javax.swing.Spring;
+import javax.swing.SpringLayout;
+
+/**
+ * A 1.4 file that provides utility methods for creating form- or grid-style
+ * layouts with SpringLayout. These utilities are used by several programs, such
+ * as SpringBox and SpringCompactGrid.
+ */
+public class SpringUtilities {
+
+ /**
+ * A debugging utility that prints to stdout the component's minimum,
+ * preferred, and maximum sizes.
+ *
+ * @param c
+ */
+ public static void printSizes(Component c) {
+ System.out.println("minimumSize = " + c.getMinimumSize());
+ System.out.println("preferredSize = " + c.getPreferredSize());
+ System.out.println("maximumSize = " + c.getMaximumSize());
+ }
+
+ /**
+ * Aligns the first rows * cols components of
+ * parent in a grid. Each component is as big as the maximum
+ * preferred width and height of the components. The parent is made just big
+ * enough to fit them all.
+ *
+ * @param parent
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeGrid(Container parent,
+ int rows, int cols,
+ int initialX, int initialY,
+ int xPad, int yPad) {
+ SpringLayout layout;
+ try {
+ layout = (SpringLayout) parent.getLayout();
+ } catch (ClassCastException exc) {
+ System.err.println("The first argument to makeGrid must use SpringLayout.");
+ return;
+ }
+
+ Spring xPadSpring = Spring.constant(xPad);
+ Spring yPadSpring = Spring.constant(yPad);
+ Spring initialXSpring = Spring.constant(initialX);
+ Spring initialYSpring = Spring.constant(initialY);
+ int max = rows * cols;
+
+ //Calculate Springs that are the max of the width/height so that all
+ //cells have the same size.
+ Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
+ getWidth();
+ Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
+ getHeight();
+ for (int i = 1; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+
+ maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
+ maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
+ }
+
+ //Apply the new width/height Spring. This forces all the
+ //components to have the same size.
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+
+ cons.setWidth(maxWidthSpring);
+ cons.setHeight(maxHeightSpring);
+ }
+
+ //Then adjust the x/y constraints of all the cells so that they
+ //are aligned in a grid.
+ SpringLayout.Constraints lastCons = null;
+ SpringLayout.Constraints lastRowCons = null;
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = layout.getConstraints(
+ parent.getComponent(i));
+ if (i % cols == 0) { //start of new row
+ lastRowCons = lastCons;
+ cons.setX(initialXSpring);
+ } else { //x position depends on previous component
+ cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
+ xPadSpring));
+ }
+
+ if (i / cols == 0) { //first row
+ cons.setY(initialYSpring);
+ } else { //y position depends on previous row
+ cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
+ yPadSpring));
+ }
+ lastCons = cons;
+ }
+
+ //Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH,
+ Spring.sum(
+ Spring.constant(yPad),
+ lastCons.getConstraint(SpringLayout.SOUTH)));
+ pCons.setConstraint(SpringLayout.EAST,
+ Spring.sum(
+ Spring.constant(xPad),
+ lastCons.getConstraint(SpringLayout.EAST)));
+ }
+
+ /* Used by makeCompactGrid. */
+ private static SpringLayout.Constraints getConstraintsForCell(
+ int row, int col,
+ Container parent,
+ int cols) {
+ SpringLayout layout = (SpringLayout) parent.getLayout();
+ Component c = parent.getComponent(row * cols + col);
+ return layout.getConstraints(c);
+ }
+
+ /**
+ * Aligns the first rows * cols components of
+ * parent in a grid. Each component in a column is as wide as
+ * the maximum preferred width of the components in that column; height is
+ * similarly determined for each row. The parent is made just big enough to
+ * fit them all.
+ *
+ * @param parent
+ * @param rows number of rows
+ * @param cols number of columns
+ * @param initialX x location to start the grid at
+ * @param initialY y location to start the grid at
+ * @param xPad x padding between cells
+ * @param yPad y padding between cells
+ */
+ public static void makeCompactGrid(Container parent,
+ int rows, int cols,
+ int initialX, int initialY,
+ int xPad, int yPad) {
+ SpringLayout layout;
+ try {
+ layout = (SpringLayout) parent.getLayout();
+ } catch (ClassCastException exc) {
+ System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
+ return;
+ }
+
+ //Align all cells in each column and make them the same width.
+ Spring x = Spring.constant(initialX);
+ for (int c = 0; c < cols; c++) {
+ Spring width = Spring.constant(0);
+ for (int r = 0; r < rows; r++) {
+ width = Spring.max(width,
+ getConstraintsForCell(r, c, parent, cols).
+ getWidth());
+ }
+ for (int r = 0; r < rows; r++) {
+ SpringLayout.Constraints constraints
+ = getConstraintsForCell(r, c, parent, cols);
+ constraints.setX(x);
+ constraints.setWidth(width);
+ }
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
+ }
+
+ //Align all cells in each row and make them the same height.
+ Spring y = Spring.constant(initialY);
+ for (int r = 0; r < rows; r++) {
+ Spring height = Spring.constant(0);
+ for (int c = 0; c < cols; c++) {
+ height = Spring.max(height,
+ getConstraintsForCell(r, c, parent, cols).
+ getHeight());
+ }
+ for (int c = 0; c < cols; c++) {
+ SpringLayout.Constraints constraints
+ = getConstraintsForCell(r, c, parent, cols);
+ constraints.setY(y);
+ constraints.setHeight(height);
+ }
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
+ }
+
+ //Set the parent's size.
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);
+ pCons.setConstraint(SpringLayout.SOUTH, y);
+ pCons.setConstraint(SpringLayout.EAST, x);
+ }
+}
diff --git a/src/com/sun/jna/platform/win32/BITMAP.java b/src/com/sun/jna/platform/win32/BITMAP.java
index 73a2ef17c..82f216e86 100644
--- a/src/com/sun/jna/platform/win32/BITMAP.java
+++ b/src/com/sun/jna/platform/win32/BITMAP.java
@@ -1,32 +1,44 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.sun.jna.platform.win32;
-
-import com.sun.jna.Structure;
-import com.sun.jna.platform.win32.WinDef.LONG;
-import com.sun.jna.platform.win32.WinDef.LPVOID;
-import com.sun.jna.platform.win32.WinDef.WORD;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- *
- * @author JPEXS
- */
-public class BITMAP extends Structure {
-
- public LONG bmType;
- public LONG bmWidth;
- public LONG bmHeight;
- public LONG bmWidthBytes;
- public WORD bmPlanes;
- public WORD bmBitsPixel;
- public LPVOID bmBits;
-
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("bmType", "bmWidth", "bmHeight", "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits");
- }
-}
+/*
+ * Copyright (C) 2010-2015 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see gdi32.dll.
- */
-public interface Gdi32 extends StdCallLibrary {
-
- Gdi32 INSTANCE = (Gdi32) Native.loadLibrary("gdi32", Gdi32.class,
- W32APIOptions.DEFAULT_OPTIONS);
-
- /**
- * The ExtCreateRegion function creates a region from the specified region
- * and transformation data.
- *
- * @param lpXform Pointer to an XFORM structure that defines the
- * transformation to be performed on the region. If this pointer is NULL,
- * the identity transformation is used.
- * @param nCount Specifies the number of bytes pointed to by lpRgnData.
- * @param lpRgnData Pointer to a RGNDATA structure that contains the region
- * data in logical units.
- * @return If the function succeeds, the return value is the value of the
- * region. If the function fails, the return value is NULL. To get extended
- * error information, call GetLastError.
- */
- public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
-
- /**
- * The CombineRgn function combines two regions and stores the result in a
- * third region. The two regions are combined according to the specified
- * mode.
- *
- * @param hrgnDest Handle to a new region with dimensions defined by
- * combining two other regions.
- * @param hrgnSrc1 Handle to the first of two regions to be combined.
- * @param hrgnSrc2 Handle to the second of two regions to be combined.
- * @param fnCombineMode Specifies a mode indicating how the two regions will
- * be combined.
- * @return The return value specifies the type of the resulting region.
- */
- int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
- int fnCombineMode);
-
- /**
- * The CreateRectRgn function creates a rectangular region.
- *
- * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
- * the region in logical units.
- * @param nTopRect Specifies the y-coordinate of the upper-left corner of
- * the region in logical units.
- * @param nRightRect Specifies the x-coordinate of the lower-right corner of
- * the region in logical units.
- * @param nBottomRect Specifies the y-coordinate of the lower-right corner
- * of the region in logical units.
- * @return If the function succeeds, the return value is the handle to the
- * region. If the function fails, the return value is NULL. To get extended
- * error information, call GetLastError.
- */
- HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
- int nBottomRect);
-
- /**
- * The CreateRoundRectRgn function creates a rectangular region with rounded
- * corners.
- *
- * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
- * the region in logical units.
- * @param nTopRect Specifies the y-coordinate of the upper-left corner of
- * the region in logical units.
- * @param nRightRect Specifies the x-coordinate of the lower-right corner of
- * the region in logical units.
- * @param nBottomRect Specifies the y-coordinate of the lower-right corner
- * of the region in logical units.
- * @param nWidthEllipse Specifies the width of the ellipse used to create
- * the rounded corners in logical units.
- * @param nHeightEllipse Specifies the height of the ellipse used to create
- * the rounded corners in logical units.
- * @return If the function succeeds, the return value is the handle to the
- * region. If the function fails, the return value is NULL. To get extended
- * error information, call GetLastError.
- */
- HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
- int nBottomRect, int nWidthEllipse, int nHeightEllipse);
-
- /**
- * The CreatePolyPolygonRgn function creates a region consisting of a series
- * of polygons. The polygons can overlap.
- *
- * @param lppt Pointer to an array of POINT structures that define the
- * vertices of the polygons in logical units. The polygons are specified
- * consecutively. Each polygon is presumed closed and each vertex is
- * specified only once.
- * @param lpPolyCounts Pointer to an array of integers, each of which
- * specifies the number of points in one of the polygons in the array
- * pointed to by lppt.
- * @param nCount Specifies the total number of integers in the array pointed
- * to by lpPolyCounts.
- * @param fnPolyFillMode Specifies the fill mode used to determine which
- * pixels are in the region.
- * @return If the function succeeds, the return value is the handle to the
- * region. If the function fails, the return value is zero. To get extended
- * error information, call GetLastError.
- */
- HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
- int nCount, int fnPolyFillMode);
-
- /**
- * The SetRectRgn function converts a region into a rectangular region with
- * the specified coordinates.
- *
- * @param hrgn Handle to the region.
- * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
- * the rectangular region in logical units.
- * @param nTopRect Specifies the y-coordinate of the upper-left corner of
- * the rectangular region in logical units.
- * @param nRightRect Specifies the x-coordinate of the lower-right corner of
- * the rectangular region in logical units.
- * @param nBottomRect Specifies the y-coordinate of the lower-right corner
- * of the rectangular region in logical units.
- * @return If the function succeeds, the return value is nonzero. If the
- * function fails, the return value is zero. To get extended error
- * information, call GetLastError.
- */
- boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
- int nBottomRect);
-
- /**
- * The SetPixel function sets the pixel at the specified coordinates to the
- * specified color.
- *
- * @param hDC Handle to the device context.
- * @param x Specifies the x-coordinate, in logical units, of the point to be
- * set.
- * @param y Specifies the y-coordinate, in logical units, of the point to be
- * set.
- * @param crColor Specifies the color to be used to paint the point. To
- * create a COLORREF color value, use the RGB macro.
- * @return If the function succeeds, the return value is the RGB value that
- * the function sets the pixel to. This value may differ from the color
- * specified by crColor; that occurs when an exact match for the specified
- * color cannot be found. If the function fails, the return value is 1. To
- * get extended error information, call GetLastError. This can be the
- * following value.
- */
- int SetPixel(HDC hDC, int x, int y, int crColor);
-
- /**
- * The CreateCompatibleDC function creates a memory device context (DC)
- * compatible with the specified device.
- *
- * @param hDC Handle to an existing DC. If this handle is NULL, the function
- * creates a memory DC compatible with the application's current screen.
- * @return If the function succeeds, the return value is the handle to a
- * memory DC. If the function fails, the return value is NULL. To get
- * extended error information, call GetLastError.
- */
- HDC CreateCompatibleDC(HDC hDC);
-
- /**
- * The DeleteDC function deletes the specified device context (DC).
- *
- * @param hDC Handle to the device context.
- * @return If the function succeeds, the return value is nonzero. If the
- * function fails, the return value is zero. To get extended error
- * information, call GetLastError.
- */
- boolean DeleteDC(HDC hDC);
-
- /**
- * The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB
- * and, optionally, sets the bitmap bits.
- *
- * @param hDC Handle to a device context.
- * @param lpbmih Pointer to a bitmap information header structure, which may
- * be one of those shown in the following table.
- * @param fdwInit Specifies how the system initializes the bitmap bits.
- * @param lpbInit Pointer to an array of bytes containing the initial bitmap
- * data.
- * @param lpbmi Pointer to a BITMAPINFO structure that describes the
- * dimensions and color format of the array pointed to by the lpbInit
- * parameter.
- * @param fuUsage Specifies whether the bmiColors member of the BITMAPINFO
- * structure was initialized and, if so, whether bmiColors contains explicit
- * red, green, blue (RGB) values or palette indexes. The fuUsage parameter
- * must be one of the following values.
- * @return If the function succeeds, the return value is a handle to the
- * compatible bitmap. If the function fails, the return value is NULL. To
- * get extended error information, call GetLastError.
- */
- HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
- Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
-
- /**
- * The CreateDIBSection function creates a DIB that applications can write
- * to directly. The function gives you a pointer to the location of the
- * bitmap bit values. You can supply a handle to a file-mapping object that
- * the function will use to create the bitmap, or you can let the system
- * allocate the memory for the bitmap.
- *
- * @param hDC Handle to a device context. If the value of iUsage is
- * DIB_PAL_COLORS, the function uses this device context's logical palette
- * to initialize the DIB colors.
- * @param pbmi Pointer to a BITMAPINFO structure that specifies various
- * attributes of the DIB, including the bitmap dimensions and colors.
- * @param iUsage Specifies the type of data contained in the bmiColors array
- * member of the BITMAPINFO structure pointed to by pbmi (either logical
- * palette indexes or literal RGB values).
- * @param ppvBits Pointer to a variable that receives a pointer to the
- * location of the DIB bit values.
- * @param hSection Handle to a file-mapping object that the function will
- * use to create the DIB. This parameter can be NULL.
- * @param dwOffset Specifies the offset from the beginning of the
- * file-mapping object referenced by hSection where storage for the bitmap
- * bit values is to begin.
- * @return Specifies the offset from the beginning of the file-mapping
- * object referenced by hSection where storage for the bitmap bit values is
- * to begin.
- */
- HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
- PointerByReference ppvBits, Pointer hSection, int dwOffset);
-
- /**
- * The CreateCompatibleBitmap function creates a bitmap compatible with the
- * device that is associated with the specified device context.
- *
- * @param hDC Handle to a device context.
- * @param width Specifies the bitmap width, in pixels.
- * @param height Specifies the bitmap height, in pixels.
- * @return If the function succeeds, the return value is a handle to the
- * compatible bitmap (DDB). If the function fails, the return value is NULL.
- * To get extended error information, call GetLastError.
- */
- HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
-
- /**
- * The SelectObject function selects an object into the specified device
- * context (DC). The new object replaces the previous object of the same
- * type.
- *
- * @param hDC Handle to the DC.
- * @param hGDIObj Handle to the object to be selected.
- * @return If the selected object is not a region and the function succeeds,
- * the return value is a handle to the object being replaced. If the
- * selected object is a region and the function succeeds, the return value
- * is one of the REGION values.
- */
- HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
-
- /**
- * The DeleteObject function deletes a logical pen, brush, font, bitmap,
- * region, or palette, freeing all system resources associated with the
- * object. After the object is deleted, the specified handle is no longer
- * valid.
- *
- * @param hObject Handle to a logical pen, brush, font, bitmap, region, or
- * palette.
- * @return If the function succeeds, the return value is nonzero. If the
- * specified handle is not valid or is currently selected into a DC, the
- * return value is zero. To get extended error information, call
- * GetLastError.
- */
- boolean DeleteObject(HANDLE hObject);
-
- /**
- * The GetDeviceCaps function retrieves device-specific information for the
- * specified device.
- *
- * @param hdc A handle to the DC.
- * @param nIndex The item to be returned.
- * @return The return value specifies the value of the desired item. When
- * nIndex is BITSPIXEL and the device has 15bpp or
- * 16bpp, the return value is 16.
- */
- int GetDeviceCaps(HDC hdc, int nIndex);
-
- /**
- * The GetDIBits function retrieves the bits fo the specified compatible
- * bitmap and copies them into a buffer as a DIB using the specified format.
- *
- * @param hdc A handle to the device context.
- * @param hbmp A handle to the bitmap. This must be a compatible bitmap
- * (DDB).
- * @param uStartScan The first scan line to retrieve
- * @param cScanLines The number of scan lines to retrieve.
- * @param lpvBits A pointer to a buffer to receive the bitmap data. If this
- * parameter is null, the function passes the dimensions and
- * format of the bitmap to the {@link BITMAPINFO} structure pointed to by
- * the lpbi parameter.
- * @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
- * the desired format for the DIB data.
- * @param uUsage The format of the bmiColors member of the {@link
- * BITMAPINFO} structure.
- * @return
- */
- int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
-
- int GetObject(HANDLE hgdiobj, int cbBuffer, Structure lpvObject);
-
- DWORD GetPixel(HDC hdc, int nXPos, int nYPos);
-
- HANDLE CreateSolidBrush(DWORD crColor);
-}
+/*
+ * Copyright (C) 2010-2015 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see gdi32.dll.
+ */
+public interface Gdi32 extends StdCallLibrary {
+
+ Gdi32 INSTANCE = (Gdi32) Native.loadLibrary("gdi32", Gdi32.class,
+ W32APIOptions.DEFAULT_OPTIONS);
+
+ /**
+ * The ExtCreateRegion function creates a region from the specified region
+ * and transformation data.
+ *
+ * @param lpXform Pointer to an XFORM structure that defines the
+ * transformation to be performed on the region. If this pointer is NULL,
+ * the identity transformation is used.
+ * @param nCount Specifies the number of bytes pointed to by lpRgnData.
+ * @param lpRgnData Pointer to a RGNDATA structure that contains the region
+ * data in logical units.
+ * @return If the function succeeds, the return value is the value of the
+ * region. If the function fails, the return value is NULL. To get extended
+ * error information, call GetLastError.
+ */
+ public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
+
+ /**
+ * The CombineRgn function combines two regions and stores the result in a
+ * third region. The two regions are combined according to the specified
+ * mode.
+ *
+ * @param hrgnDest Handle to a new region with dimensions defined by
+ * combining two other regions.
+ * @param hrgnSrc1 Handle to the first of two regions to be combined.
+ * @param hrgnSrc2 Handle to the second of two regions to be combined.
+ * @param fnCombineMode Specifies a mode indicating how the two regions will
+ * be combined.
+ * @return The return value specifies the type of the resulting region.
+ */
+ int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
+ int fnCombineMode);
+
+ /**
+ * The CreateRectRgn function creates a rectangular region.
+ *
+ * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
+ * the region in logical units.
+ * @param nTopRect Specifies the y-coordinate of the upper-left corner of
+ * the region in logical units.
+ * @param nRightRect Specifies the x-coordinate of the lower-right corner of
+ * the region in logical units.
+ * @param nBottomRect Specifies the y-coordinate of the lower-right corner
+ * of the region in logical units.
+ * @return If the function succeeds, the return value is the handle to the
+ * region. If the function fails, the return value is NULL. To get extended
+ * error information, call GetLastError.
+ */
+ HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
+ int nBottomRect);
+
+ /**
+ * The CreateRoundRectRgn function creates a rectangular region with rounded
+ * corners.
+ *
+ * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
+ * the region in logical units.
+ * @param nTopRect Specifies the y-coordinate of the upper-left corner of
+ * the region in logical units.
+ * @param nRightRect Specifies the x-coordinate of the lower-right corner of
+ * the region in logical units.
+ * @param nBottomRect Specifies the y-coordinate of the lower-right corner
+ * of the region in logical units.
+ * @param nWidthEllipse Specifies the width of the ellipse used to create
+ * the rounded corners in logical units.
+ * @param nHeightEllipse Specifies the height of the ellipse used to create
+ * the rounded corners in logical units.
+ * @return If the function succeeds, the return value is the handle to the
+ * region. If the function fails, the return value is NULL. To get extended
+ * error information, call GetLastError.
+ */
+ HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
+ int nBottomRect, int nWidthEllipse, int nHeightEllipse);
+
+ /**
+ * The CreatePolyPolygonRgn function creates a region consisting of a series
+ * of polygons. The polygons can overlap.
+ *
+ * @param lppt Pointer to an array of POINT structures that define the
+ * vertices of the polygons in logical units. The polygons are specified
+ * consecutively. Each polygon is presumed closed and each vertex is
+ * specified only once.
+ * @param lpPolyCounts Pointer to an array of integers, each of which
+ * specifies the number of points in one of the polygons in the array
+ * pointed to by lppt.
+ * @param nCount Specifies the total number of integers in the array pointed
+ * to by lpPolyCounts.
+ * @param fnPolyFillMode Specifies the fill mode used to determine which
+ * pixels are in the region.
+ * @return If the function succeeds, the return value is the handle to the
+ * region. If the function fails, the return value is zero. To get extended
+ * error information, call GetLastError.
+ */
+ HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
+ int nCount, int fnPolyFillMode);
+
+ /**
+ * The SetRectRgn function converts a region into a rectangular region with
+ * the specified coordinates.
+ *
+ * @param hrgn Handle to the region.
+ * @param nLeftRect Specifies the x-coordinate of the upper-left corner of
+ * the rectangular region in logical units.
+ * @param nTopRect Specifies the y-coordinate of the upper-left corner of
+ * the rectangular region in logical units.
+ * @param nRightRect Specifies the x-coordinate of the lower-right corner of
+ * the rectangular region in logical units.
+ * @param nBottomRect Specifies the y-coordinate of the lower-right corner
+ * of the rectangular region in logical units.
+ * @return If the function succeeds, the return value is nonzero. If the
+ * function fails, the return value is zero. To get extended error
+ * information, call GetLastError.
+ */
+ boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
+ int nBottomRect);
+
+ /**
+ * The SetPixel function sets the pixel at the specified coordinates to the
+ * specified color.
+ *
+ * @param hDC Handle to the device context.
+ * @param x Specifies the x-coordinate, in logical units, of the point to be
+ * set.
+ * @param y Specifies the y-coordinate, in logical units, of the point to be
+ * set.
+ * @param crColor Specifies the color to be used to paint the point. To
+ * create a COLORREF color value, use the RGB macro.
+ * @return If the function succeeds, the return value is the RGB value that
+ * the function sets the pixel to. This value may differ from the color
+ * specified by crColor; that occurs when an exact match for the specified
+ * color cannot be found. If the function fails, the return value is 1. To
+ * get extended error information, call GetLastError. This can be the
+ * following value.
+ */
+ int SetPixel(HDC hDC, int x, int y, int crColor);
+
+ /**
+ * The CreateCompatibleDC function creates a memory device context (DC)
+ * compatible with the specified device.
+ *
+ * @param hDC Handle to an existing DC. If this handle is NULL, the function
+ * creates a memory DC compatible with the application's current screen.
+ * @return If the function succeeds, the return value is the handle to a
+ * memory DC. If the function fails, the return value is NULL. To get
+ * extended error information, call GetLastError.
+ */
+ HDC CreateCompatibleDC(HDC hDC);
+
+ /**
+ * The DeleteDC function deletes the specified device context (DC).
+ *
+ * @param hDC Handle to the device context.
+ * @return If the function succeeds, the return value is nonzero. If the
+ * function fails, the return value is zero. To get extended error
+ * information, call GetLastError.
+ */
+ boolean DeleteDC(HDC hDC);
+
+ /**
+ * The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB
+ * and, optionally, sets the bitmap bits.
+ *
+ * @param hDC Handle to a device context.
+ * @param lpbmih Pointer to a bitmap information header structure, which may
+ * be one of those shown in the following table.
+ * @param fdwInit Specifies how the system initializes the bitmap bits.
+ * @param lpbInit Pointer to an array of bytes containing the initial bitmap
+ * data.
+ * @param lpbmi Pointer to a BITMAPINFO structure that describes the
+ * dimensions and color format of the array pointed to by the lpbInit
+ * parameter.
+ * @param fuUsage Specifies whether the bmiColors member of the BITMAPINFO
+ * structure was initialized and, if so, whether bmiColors contains explicit
+ * red, green, blue (RGB) values or palette indexes. The fuUsage parameter
+ * must be one of the following values.
+ * @return If the function succeeds, the return value is a handle to the
+ * compatible bitmap. If the function fails, the return value is NULL. To
+ * get extended error information, call GetLastError.
+ */
+ HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
+ Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
+
+ /**
+ * The CreateDIBSection function creates a DIB that applications can write
+ * to directly. The function gives you a pointer to the location of the
+ * bitmap bit values. You can supply a handle to a file-mapping object that
+ * the function will use to create the bitmap, or you can let the system
+ * allocate the memory for the bitmap.
+ *
+ * @param hDC Handle to a device context. If the value of iUsage is
+ * DIB_PAL_COLORS, the function uses this device context's logical palette
+ * to initialize the DIB colors.
+ * @param pbmi Pointer to a BITMAPINFO structure that specifies various
+ * attributes of the DIB, including the bitmap dimensions and colors.
+ * @param iUsage Specifies the type of data contained in the bmiColors array
+ * member of the BITMAPINFO structure pointed to by pbmi (either logical
+ * palette indexes or literal RGB values).
+ * @param ppvBits Pointer to a variable that receives a pointer to the
+ * location of the DIB bit values.
+ * @param hSection Handle to a file-mapping object that the function will
+ * use to create the DIB. This parameter can be NULL.
+ * @param dwOffset Specifies the offset from the beginning of the
+ * file-mapping object referenced by hSection where storage for the bitmap
+ * bit values is to begin.
+ * @return Specifies the offset from the beginning of the file-mapping
+ * object referenced by hSection where storage for the bitmap bit values is
+ * to begin.
+ */
+ HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
+ PointerByReference ppvBits, Pointer hSection, int dwOffset);
+
+ /**
+ * The CreateCompatibleBitmap function creates a bitmap compatible with the
+ * device that is associated with the specified device context.
+ *
+ * @param hDC Handle to a device context.
+ * @param width Specifies the bitmap width, in pixels.
+ * @param height Specifies the bitmap height, in pixels.
+ * @return If the function succeeds, the return value is a handle to the
+ * compatible bitmap (DDB). If the function fails, the return value is NULL.
+ * To get extended error information, call GetLastError.
+ */
+ HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
+
+ /**
+ * The SelectObject function selects an object into the specified device
+ * context (DC). The new object replaces the previous object of the same
+ * type.
+ *
+ * @param hDC Handle to the DC.
+ * @param hGDIObj Handle to the object to be selected.
+ * @return If the selected object is not a region and the function succeeds,
+ * the return value is a handle to the object being replaced. If the
+ * selected object is a region and the function succeeds, the return value
+ * is one of the REGION values.
+ */
+ HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
+
+ /**
+ * The DeleteObject function deletes a logical pen, brush, font, bitmap,
+ * region, or palette, freeing all system resources associated with the
+ * object. After the object is deleted, the specified handle is no longer
+ * valid.
+ *
+ * @param hObject Handle to a logical pen, brush, font, bitmap, region, or
+ * palette.
+ * @return If the function succeeds, the return value is nonzero. If the
+ * specified handle is not valid or is currently selected into a DC, the
+ * return value is zero. To get extended error information, call
+ * GetLastError.
+ */
+ boolean DeleteObject(HANDLE hObject);
+
+ /**
+ * The GetDeviceCaps function retrieves device-specific information for the
+ * specified device.
+ *
+ * @param hdc A handle to the DC.
+ * @param nIndex The item to be returned.
+ * @return The return value specifies the value of the desired item. When
+ * nIndex is BITSPIXEL and the device has 15bpp or
+ * 16bpp, the return value is 16.
+ */
+ int GetDeviceCaps(HDC hdc, int nIndex);
+
+ /**
+ * The GetDIBits function retrieves the bits fo the specified compatible
+ * bitmap and copies them into a buffer as a DIB using the specified format.
+ *
+ * @param hdc A handle to the device context.
+ * @param hbmp A handle to the bitmap. This must be a compatible bitmap
+ * (DDB).
+ * @param uStartScan The first scan line to retrieve
+ * @param cScanLines The number of scan lines to retrieve.
+ * @param lpvBits A pointer to a buffer to receive the bitmap data. If this
+ * parameter is null, the function passes the dimensions and
+ * format of the bitmap to the {@link BITMAPINFO} structure pointed to by
+ * the lpbi parameter.
+ * @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
+ * the desired format for the DIB data.
+ * @param uUsage The format of the bmiColors member of the {@link
+ * BITMAPINFO} structure.
+ * @return
+ */
+ int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
+
+ int GetObject(HANDLE hgdiobj, int cbBuffer, Structure lpvObject);
+
+ DWORD GetPixel(HDC hdc, int nXPos, int nYPos);
+
+ HANDLE CreateSolidBrush(DWORD crColor);
+}
diff --git a/src/com/sun/jna/platform/win32/ICONINFO.java b/src/com/sun/jna/platform/win32/ICONINFO.java
index 2148a019e..02a51dd96 100644
--- a/src/com/sun/jna/platform/win32/ICONINFO.java
+++ b/src/com/sun/jna/platform/win32/ICONINFO.java
@@ -1,29 +1,41 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.sun.jna.platform.win32;
-
-import com.sun.jna.Structure;
-import com.sun.jna.platform.win32.WinDef.DWORD;
-import com.sun.jna.platform.win32.WinDef.HBITMAP;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- *
- * @author JPEXS
- */
-public class ICONINFO extends Structure {
-
- public boolean fIcon;
- public DWORD xHotspot;
- public DWORD yHotspot;
- public HBITMAP hbmMask;
- public HBITMAP hbmColor;
-
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("fIcon", "xHotspot", "yHotspot", "hbmMask", "hbmColor");
- }
-}
+/*
+ * Copyright (C) 2010-2015 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see | Return code/value | - *Description | - *
|---|---|
| 0 | - *The wait was satisfied successfully. | - *
| WAIT_TIMEOUT | - *The wait was terminated because the time-out interval elapsed. | - *
| WAIT_FAILED | - *An error occurred. | - *
- * If the function fails, the return value is zero. To get extended error - * information, call GetLastError. - *
- */ - int RegisterWindowMessage(String string); - - boolean GetIconInfo(HICON hIcon, ICONINFO iconinfo); - - boolean DrawIcon(HDC hDC, int X, int Y, HICON hIcon); - - boolean DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, int diFlags); - - HWND GetDesktopWindow(); - public static final int DI_MASK = 1; - public static final int DI_IMAGE = 2; - public static final int DI_NORMAL = 3; - public static final int DI_COMPAT = 4; - public static final int DI_DEFAULTSIZE = 8; - - int FillRect(HDC hDC, RECT lprc, HANDLE hbr); -} +/* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, All Rights Reserved + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.WString; +import com.sun.jna.platform.win32.BaseTSD.LONG_PTR; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.W32APIOptions; + +/** + * Provides access to the w32 user32 library. Incomplete implementation to + * support demos. + * + * @author Todd Fast, todd.fast@sun.com + * @author twalljava@dev.java.net + * @author Tobias Wolf, wolf.tobias@gmx.net + * @author Markus KARG (markus[at]headcrashing[dot]eu) + */ +public interface User32 extends StdCallLibrary, WinUser { + + /** + * The instance. + */ + User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, + W32APIOptions.DEFAULT_OPTIONS); + /** + * Handle for message-only window. + */ + public static final HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3)); + /** + * The cs globalclass. + */ + int CS_GLOBALCLASS = 0x4000; + /** + * The ws ex topmost. + */ + int WS_EX_TOPMOST = 0x00000008; + /** + * The ws overlapped. + */ + int WS_OVERLAPPED = 0x00000000; + /** + * The hRecipient parameter is a window handle. + */ + int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000; + /** + * The hRecipient parameter is a service status handle. + */ + int DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001; + /** + * The device notify all interface classes. + */ + int DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x00000004; + + /** + * This function retrieves a handle to a display device context (DC) for the + * client area of the specified window. The display device context can be + * used in subsequent graphics display interface (GDI) functions to draw in + * the client area of the window. + * + * @param hWnd Handle to the window whose device context is to be retrieved. + * If this value is NULL, GetDC retrieves the device context for the entire + * screen. + * @return The handle the device context for the specified window's client + * area indicates success. NULL indicates failure. To get extended error + * information, call GetLastError. + */ + HDC GetDC(HWND hWnd); + + /** + * This function releases a device context (DC), freeing it for use by other + * applications. The effect of ReleaseDC depends on the type of device + * context. + * + * @param hWnd Handle to the window whose device context is to be released. + * @param hDC Handle to the device context to be released. + * @return The return value specifies whether the device context is + * released. 1 indicates that the device context is released. Zero indicates + * that the device context is not released. + */ + int ReleaseDC(HWND hWnd, HDC hDC); + + /** + * This function retrieves the handle to the top-level window whose class + * name and window name match the specified strings. This function does not + * search child windows. + * + * @param lpClassName Long pointer to a null-terminated string that + * specifies the class name or is an atom that identifies the class-name + * string. If this parameter is an atom, it must be a global atom created by + * a previous call to the GlobalAddAtom function. The atom, a 16-bit value, + * must be placed in the low-order word of lpClassName; the high-order word + * must be zero. + * @param lpWindowName Long pointer to a null-terminated string that + * specifies the window name (the window's title). If this parameter is + * NULL, all window names match. + * @return A handle to the window that has the specified class name and + * window name indicates success. NULL indicates failure. To get extended + * error information, call GetLastError. + */ + HWND FindWindow(String lpClassName, String lpWindowName); + + /** + * This function retrieves the name of the class to which the specified + * window belongs. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param lpClassName Long pointer to the buffer that is to receive the + * class name string. + * @param nMaxCount Specifies the length, in characters, of the buffer + * pointed to by the lpClassName parameter. The class name string is + * truncated if it is longer than the buffer. + * @return The number of characters copied to the specified buffer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount); + + /** + * Retrieves information about the active window or a specified graphical + * user interface (GUI) thread. + * + * @param idThread Identifies the thread for which information is to be + * retrieved. To retrieve this value, use the GetWindowThreadProcessId + * function. If this parameter is NULL, the function returns information for + * the foreground thread. + * @param lpgui Pointer to a GUITHREADINFO structure that receives + * information describing the thread. Note that you must set + * GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling this + * function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui); + + /** + * The GetWindowInfo function retrieves information about the specified + * window. + * + * @param hWnd Handle to the window whose information is to be retrieved. + * @param pwi Pointer to a WINDOWINFO structure to receive the information. + * Note that you must set WINDOWINFO.cbSize to sizeof(WINDOWINFO) before + * calling this function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. + */ + boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi); + + /** + * This function retrieves the dimensions of the bounding rectangle of the + * specified window. The dimensions are given in screen coordinates that are + * relative to the upper-left corner of the screen. + * + * @param hWnd Handle to the window. + * @param rect Long pointer to a RECT structure that receives the screen + * coordinates of the upper-left and lower-right corners of the window. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean GetWindowRect(HWND hWnd, RECT rect); + + /** + * This function copies the text of the specified window's title bar - if it + * has one - into a buffer. If the specified window is a control, the text + * of the control is copied. + * + * @param hWnd Handle to the window or control containing the text. + * @param lpString Long pointer to the buffer that will receive the text. + * @param nMaxCount Specifies the maximum number of characters to copy to + * the buffer, including the NULL character. If the text exceeds this limit, + * it is truncated. + * @return The length, in characters, of the copied string, not including + * the terminating null character, indicates success. Zero indicates that + * the window has no title bar or text, if the title bar is empty, or if the + * window or control handle is invalid. To get extended error information, + * call GetLastError. This function cannot retrieve the text of an edit + * control in another application. + */ + int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount); + + /** + * This function retrieves the length, in characters, of the specified + * window's title bar text - if the window has a title bar. If the specified + * window is a control, the function retrieves the length of the text within + * the control. + * + * @param hWnd Handle to the window or control. + * @return The length, in characters, of the text indicates success. Under + * certain conditions, this value may actually be greater than the length of + * the text. Zero indicates that the window has no text. To get extended + * error information, call GetLastError. + */ + int GetWindowTextLength(HWND hWnd); + + /** + * The GetWindowModuleFileName function retrieves the full path and file + * name of the module associated with the specified window handle. + * + * @param hWnd Handle to the window whose module file name will be + * retrieved. + * @param lpszFileName Pointer to a buffer that receives the path and file + * name. + * @param cchFileNameMax Specifies the maximum number of TCHARs that can be + * copied into the lpszFileName buffer. + * @return The return value is the total number of TCHARs copied into the + * buffer. + */ + int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, + int cchFileNameMax); + + /** + * This function retrieves the identifier of the thread that created the + * specified window and, optionally, the identifier of the process that + * created the window. + * + * @param hWnd Handle to the window. + * @param lpdwProcessId Pointer to a 32-bit value that receives the process + * identifier. If this parameter is not NULL, GetWindowThreadProcessId + * copies the identifier of the process to the 32-bit value; otherwise, it + * does not. + * @return The return value is the identifier of the thread that created the + * window. + */ + int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId); + + /** + * This function enumerates all top-level windows on the screen by passing + * the handle to each window, in turn, to an application-defined callback + * function. EnumWindows continues until the last top-level window is + * enumerated or the callback function returns FALSE. + * + * @param lpEnumFunc Long pointer to an application-defined callback + * function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data); + + /** + * The EnumChildWindows function enumerates the child windows that belong to + * the specified parent window by passing the handle to each child window, + * in turn, to an application-defined callback function. EnumChildWindows + * continues until the last child window is enumerated or the callback + * function returns FALSE. + * + * @param hWnd Handle to the parent window whose child windows are to be + * enumerated. If this parameter is NULL, this function is equivalent to + * EnumWindows. + * @param lpEnumFunc Pointer to an application-defined callback function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. If EnumChildProc returns zero, the return + * value is also zero. In this case, the callback function should call + * SetLastError to obtain a meaningful error code to be returned to the + * caller of EnumChildWindows. + */ + boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data); + + /** + * The EnumThreadWindows function enumerates all nonchild windows associated + * with a thread by passing the handle to each window, in turn, to an + * application-defined callback function. EnumThreadWindows continues until + * the last window is enumerated or the callback function returns FALSE. To + * enumerate child windows of a particular window, use the EnumChildWindows + * function. + * + * @param dwThreadId Identifies the thread whose windows are to be + * enumerated. + * @param lpEnumFunc Pointer to an application-defined callback function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return If the callback function returns TRUE for all windows in the + * thread specified by dwThreadId, the return value is TRUE. If the callback + * function returns FALSE on any enumerated window, or if there are no + * windows found in the thread specified by dwThreadId, the return value is + * FALSE. + */ + boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, + Pointer data); + + /** + * The FlashWindowEx function flashes the specified window. It does not + * change the active state of the window. + * + * @param pfwi Pointer to the FLASHWINFO structure. + * @return The return value specifies the window's state before the call to + * the FlashWindowEx function. If the window caption was drawn as active + * before the call, the return value is nonzero. Otherwise, the return value + * is zero. + */ + boolean FlashWindowEx(FLASHWINFO pfwi); + + /** + * This function loads the specified icon resource from the executable + * (.exe) file associated with an application instance. + * + * @param hInstance Handle to an instance of the module whose executable + * file contains the icon to be loaded. This parameter must be NULL when a + * standard icon is being loaded. + * @param iconName Long pointer to a null-terminated string that contains + * the name of the icon resource to be loaded. Alternatively, this parameter + * can contain the resource identifier in the low-order word and zero in the + * high-order word. Use the MAKEINTRESOURCE macro to create this value. + * @return A handle to the newly loaded icon indicates success. NULL + * indicates failure. To get extended error information, call GetLastError. + */ + HICON LoadIcon(HINSTANCE hInstance, String iconName); + + /** + * This function loads an icon, cursor, or bitmap. + * + * @param hinst Handle to an instance of the module that contains the image + * to be loaded. + * @param name Pointer to a null-terminated string that contains the name of + * the image resource in the hinst module that identifies the image to load. + * @param type Specifies the type of image to be loaded. + * @param xDesired Specifies the width, in pixels, of the icon or cursor. If + * this parameter is zero, the function uses the SM_CXICON or SM_CXCURSOR + * system metric value to set the width. If uType is IMAGE_BITMAP, this + * parameter must be zero. + * @param yDesired Specifies the height, in pixels, of the icon or cursor. + * If this parameter is zero, the function uses the SM_CYICON or SM_CYCURSOR + * system metric value to set the height. If uType is IMAGE_BITMAP, this + * parameter must be zero. + * @param load Set to zero. + * @return The handle of the newly loaded image indicates success. NULL + * indicates failure. To get extended error information, call GetLastError. + */ + HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired, + int yDesired, int load); + + /** + * This function destroys an icon and frees any memory the icon occupied. + * + * @param hicon Handle to the icon to be destroyed. The icon must not be in + * use. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean DestroyIcon(HICON hicon); + + /** + * This function retrieves information about the specified window. + * GetWindowLong also retrieves the 32-bit (long) value at the specified + * offset into the extra window memory of a window. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be + * retrieved. + * @return The requested 32-bit value indicates success. Zero indicates + * failure. To get extended error information, call GetLastError. + */ + int GetWindowLong(HWND hWnd, int nIndex); + + /** + * This function changes an attribute of the specified window. SetWindowLong + * also sets a 32-bit (LONG) value at the specified offset into the extra + * window memory of a window. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLong Specifies the replacement value. + * @return The previous value of the specified 32-bit integer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong); + + /** + * This function changes an attribute of the specified window. SetWindowLong + * also sets a 32-bit (LONG) value at the specified offset into the extra + * window memory of a window. Do not use this version on Windows-64. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLong Specifies the replacement value. + * @return The previous value of the specified 32-bit integer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + Pointer SetWindowLong(HWND hWnd, int nIndex, Pointer dwNewLong); + + /** + * The GetWindowLongPtr function retrieves information about the specified + * window. The function also retrieves the value at a specified offset into + * the extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be + * retrieved. + * @return If the function succeeds, the return value is the requested + * value. If the function fails, the return value is zero. To get extended + * error information, call GetLastError. If SetWindowLong or + * SetWindowLongPtr has not been called previously, GetWindowLongPtr returns + * zero for values in the extra window or class memory. + */ + LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex); + + /** + * The SetWindowLongPtr function changes an attribute of the specified + * window. The function also sets a value at the specified offset in the + * extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLongPtr Specifies the replacement value. + * @return If the function succeeds, the return value is the previous value + * of the specified offset. If the function fails, the return value is zero. + * To get extended error information, call GetLastError. If the previous + * value is zero and the function succeeds, the return value is zero, but + * the function does not clear the last error information. To determine + * success or failure, clear the last error information by calling + * SetLastError(0), then call SetWindowLongPtr. Function failure will be + * indicated by a return value of zero and a GetLastError result that is + * nonzero. + */ + LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLongPtr); + + /** + * The SetWindowLongPtr function changes an attribute of the specified + * window. The function also sets a value at the specified offset in the + * extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLongPtr Specifies the replacement value. + * @return If the function succeeds, the return value is the previous value + * of the specified offset. If the function fails, the return value is zero. + * To get extended error information, call GetLastError. If the previous + * value is zero and the function succeeds, the return value is zero, but + * the function does not clear the last error information. To determine + * success or failure, clear the last error information by calling + * SetLastError(0), then call SetWindowLongPtr. Function failure will be + * indicated by a return value of zero and a GetLastError result that is + * nonzero. + */ + Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr); + + /** + * The SetLayeredWindowAttributes function sets the opacity and transparency + * color key of a layered window. + * + * @param hwnd Handle to the layered window. + * @param crKey COLORREF structure that specifies the transparency color key + * to be used when composing the layered window. + * @param bAlpha Alpha value used to describe the opacity of the layered + * window. + * @param dwFlags Specifies an action to take. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha, + int dwFlags); + + /** + * The GetLayeredWindowAttributes function retrieves the opacity and + * transparency color key of a layered window. + * + * @param hwnd Handle to the layered window. A layered window is created by + * specifying WS_EX_LAYERED when creating the window with the CreateWindowEx + * function or by setting WS_EX_LAYERED via SetWindowLong after the window + * has been created. + * @param pcrKey Pointer to a COLORREF value that receives the transparency + * color key to be used when composing the layered window. All pixels + * painted by the window in this color will be transparent. This can be NULL + * if the argument is not needed. + * @param pbAlpha Pointer to a BYTE that receives the Alpha value used to + * describe the opacity of the layered window. Similar to the + * SourceConstantAlpha member of the BLENDFUNCTION structure. When the + * variable referred to by pbAlpha is 0, the window is completely + * transparent. When the variable referred to by pbAlpha is 255, the window + * is opaque. This can be NULL if the argument is not needed. + * @param pdwFlags Pointer to a DWORD that receives a layering flag. This + * can be NULL if the argument is not needed. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey, + ByteByReference pbAlpha, IntByReference pdwFlags); + + /** + * The UpdateLayeredWindow function updates the position, size, shape, + * content, and translucency of a layered window. + * + * @param hwnd Handle to a layered window. A layered window is created by + * specifying WS_EX_LAYERED when creating the window with the CreateWindowEx + * function. + * @param hdcDst Handle to a device context (DC) for the screen. This handle + * is obtained by specifying NULL when calling the function. It is used for + * palette color matching when the window contents are updated. If hdcDst + * isNULL, the default palette will be used. If hdcSrc is NULL, hdcDst must + * be NULL. + * @param pptDst Pointer to a POINT structure that specifies the new screen + * position of the layered window. If the current position is not changing, + * pptDst can be NULL. + * @param psize Pointer to a SIZE structure that specifies the new size of + * the layered window. If the size of the window is not changing, psize can + * be NULL. If hdcSrc is NULL, psize must be NULL. + * @param hdcSrc Handle to a DC for the surface that defines the layered + * window. This handle can be obtained by calling the CreateCompatibleDC + * function. If the shape and visual context of the window are not changing, + * hdcSrc can be NULL. + * @param pptSrc Pointer to a POINT structure that specifies the location of + * the layer in the device context. If hdcSrc is NULL, pptSrc should be + * NULL. + * @param crKey Pointer to a COLORREF value that specifies the color key to + * be used when composing the layered window. To generate a COLORREF, use + * the RGB macro. + * @param pblend Pointer to a BLENDFUNCTION structure that specifies the + * transparency value to be used when composing the layered window. + * @param dwFlags ULW_* flags. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst, + SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey, + BLENDFUNCTION pblend, int dwFlags); + + /** + * This function sets the window region of a window. The window region + * determines the area within the window where the system permits drawing. + * The system does not display any portion of a window that lies outside of + * the window region. + * + * @param hWnd Handle to the window whose window region is to be set. + * @param hRgn Handle to a region. The function sets the window region of + * the window to this region. If hRgn is NULL, the function sets the window + * region to NULL. + * @param bRedraw Specifies whether the system redraws the window after + * setting the window region. If bRedraw is TRUE, the system does so; + * otherwise, it does not. Typically, you set bRedraw to TRUE if the window + * is visible. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw); + + /** + * The GetKeyboardState function copies the status of the 256 virtual keys + * to the specified buffer. + * + * @param lpKeyState Pointer to the 256-byte array that receives the status + * data for each virtual key. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetKeyboardState(byte[] lpKeyState); + + /** + * This function determines whether a key is up or down at the time the + * function is called, and whether the key was pressed after a previous call + * to GetAsyncKeyState. + * + * @param vKey Specifies one of 256 possible virtual-key codes. + * @return If the function succeeds, the return value specifies whether the + * key was pressed since the last call to GetAsyncKeyState, and whether the + * key is currently up or down. If the most significant bit is set, the key + * is down. + */ + short GetAsyncKeyState(int vKey); + + /** + * The SetWindowsHookEx function installs an application-defined hook + * procedure into a hook chain. You would install a hook procedure to + * monitor the system for certain types of events. These events are + * associated either with a specific thread or with all threads in the same + * desktop as the calling thread. + * + * @param idHook Specifies the type of hook procedure to be installed. + * @param lpfn Pointer to the hook procedure. + * @param hMod Handle to the DLL containing the hook procedure pointed to by + * the lpfn parameter. + * @param dwThreadId Specifies the identifier of the thread with which the + * hook procedure is to be associated. + * @return If the function succeeds, the return value is the handle to the + * hook procedure. If the function fails, the return value is NULL. To get + * extended error information, call GetLastError. + */ + HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, + int dwThreadId); + + /** + * The CallNextHookEx function passes the hook information to the next hook + * procedure in the current hook chain. A hook procedure can call this + * function either before or after processing the hook information. + * + * @param hhk Ignored. + * @param nCode Specifies the hook code passed to the current hook + * procedure. The next hook procedure uses this code to determine how to + * process the hook information. + * @param wParam Specifies the wParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @param lParam Specifies the lParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @return This value is returned by the next hook procedure in the chain. + * The current hook procedure must also return this value. The meaning of + * the return value depends on the hook type. + */ + LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam); + + /** + * The CallNextHookEx function passes the hook information to the next hook + * procedure in the current hook chain. A hook procedure can call this + * function either before or after processing the hook information. + * + * @param hhk Ignored. + * @param nCode Specifies the hook code passed to the current hook + * procedure. The next hook procedure uses this code to determine how to + * process the hook information. + * @param wParam Specifies the wParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @param lParam Specifies the lParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @return This value is returned by the next hook procedure in the chain. + * The current hook procedure must also return this value. The meaning of + * the return value depends on the hook type. + */ + LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam); + + /** + * The UnhookWindowsHookEx function removes a hook procedure installed in a + * hook chain by the SetWindowsHookEx function. + * + * @param hhk Handle to the hook to be removed. This parameter is a hook + * handle obtained by a previous call to SetWindowsHookEx. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean UnhookWindowsHookEx(HHOOK hhk); + + /** + * This function retrieves a message from the calling thread's message queue + * and places it in the specified structure. + * + * @param lpMsg Pointer to an MSG structure that receives message + * information from the thread's message queue. + * @param hWnd Handle to the window whose messages are to be retrieved. One + * value has a special meaning. + * @param wMsgFilterMin Specifies the integer value of the lowest message + * value to be retrieved. + * @param wMsgFilterMax Specifies the integer value of the highest message + * value to be retrieved. + * @return Nonzero indicates that the function retrieves a message other + * than WM_QUIT. Zero indicates that the function retrieves the WM_QUIT + * message, or that lpMsg is an invalid pointer. To get extended error + * information, call GetLastError. + */ + int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax); + + /** + * This function checks a thread message queue for a message and places the + * message (if any) in the specified structure. + * + * @param lpMsg Pointer to an MSG structure that receives message + * information. + * @param hWnd Handle to the window whose messages are to be examined. + * @param wMsgFilterMin Specifies the value of the first message in the + * range of messages to be examined. + * @param wMsgFilterMax Specifies the value of the last message in the range + * of messages to be examined. + * @param wRemoveMsg Specifies how messages are handled. This parameter can + * be one of the following values. + * @return Nonzero indicates success. Zero indicates failure. + */ + boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, + int wMsgFilterMax, int wRemoveMsg); + + /** + * This function translates virtual-key messages into character messages. + * The character messages are posted to the calling thread's message queue, + * to be read the next time the thread calls the GetMessage or PeekMessage + * function. + * + * @param lpMsg Pointer to an MSG structure that contains message + * information retrieved from the calling thread's message queue by using + * the GetMessage or PeekMessage function. + * @return Nonzero indicates that the message is translated, that is, a + * character message is posted to the thread's message queue. If the message + * is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is nonzero, regardless + * of the translation. Zero indicates that the message is not translated, + * that is, a character message is not posted to the thread's message queue. + */ + boolean TranslateMessage(MSG lpMsg); + + /** + * This function dispatches a message to a window procedure. It is typically + * used to dispatch a message retrieved by the GetMessage function. + * + * @param lpMsg Pointer to an MSG structure that contains the message. + * @return The return value specifies the value returned by the window + * procedure. Although its meaning depends on the message being dispatched, + * the return value generally is ignored. + */ + LRESULT DispatchMessage(MSG lpMsg); + + /** + * This function places a message in the message queue associated with the + * thread that created the specified window and then returns without waiting + * for the thread to process the message. Messages in a message queue are + * retrieved by calls to the GetMessage or PeekMessage function. + * + * @param hWnd Handle to the window whose window procedure is to receive the + * message. + * @param msg Specifies the message to be posted. + * @param wParam Specifies additional message-specific information. + * @param lParam Specifies additional message-specific information. + */ + void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam); + + /** + * This function indicates to Windows that a thread has made a request to + * terminate (quit). It is typically used in response to a WM_DESTROY + * message. + * + * @param nExitCode Specifies an application exit code. This value is used + * as the wParam parameter of the WM_QUIT message. + */ + void PostQuitMessage(int nExitCode); + + /** + * The GetSystemMetrics function retrieves various system metrics (widths + * and heights of display elements) and system configuration settings. All + * dimensions retrieved by GetSystemMetrics are in pixels. + * + * @param nIndex System metric or configuration setting to retrieve. This + * parameter can be one of the following values. Note that all SM_CX* values + * are widths and all SM_CY* values are heights. Also note that all settings + * designed to return Boolean data represent TRUE as any nonzero value, and + * FALSE as a zero value. + * @return If the function succeeds, the return value is the requested + * system metric or configuration setting. If the function fails, the return + * value is zero. GetLastError does not provide extended error information. + */ + public int GetSystemMetrics(int nIndex); + + /** + * Changes the parent window of the specified child window. + * + * @param hWndChild A handle to the child window. + * + * @param hWndNewParent A handle to the new parent window. If this parameter + * is NULL, the desktop window becomes the new parent window. If this + * parameter is HWND_MESSAGE, the child window becomes a message-only + * window. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + HWND SetParent(HWND hWndChild, HWND hWndNewParent); + + /** + * Determines the visibility state of the specified window. + * + * @param hWnd A handle to the window to be tested. + * + * @return If the specified window, its parent window, its parent's parent + * window, and so forth, have the WS_VISIBLE style, the return value is + * nonzero. Otherwise, the return value is zero. + * + * Because the return value specifies whether the window has the WS_VISIBLE + * style, it may be nonzero even if the window is totally obscured by other + * windows. + */ + boolean IsWindowVisible(HWND hWnd); + + /** + * Changes the position and dimensions of the specified window. For a + * top-level window, the position and dimensions are relative to the + * upper-left corner of the screen. For a child window, they are relative to + * the upper-left corner of the parent window's client area. + * + * @param hWnd A handle to the window. + * + * @param X The new position of the left side of the window. + * + * @param Y The new position of the top of the window. + * + * @param nWidth The new width of the window. + * + * @param nHeight The new height of the window. + * + * @param bRepaint Indicates whether the window is to be repainted. If this + * parameter is TRUE, the window receives a message. If the parameter is + * FALSE, no repainting of any kind occurs. This applies to the client area, + * the nonclient area (including the title bar and scroll bars), and any + * part of the parent window uncovered as a result of moving a child window. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, + boolean bRepaint); + + /** + * Changes the size, position, and Z order of a child, pop-up, or top-level + * window. These windows are ordered according to their appearance on the + * screen. The topmost window receives the highest rank and is the first + * window in the Z order. + * + * @param hWnd A handle to the window. + * + * @param hWndInsertAfter A handle to the window to precede the positioned + * window in the Z order. + * + * @param X The new position of the left side of the window, in client + * coordinates. + * + * @param Y The new position of the top of the window, in client + * coordinates. + * + * @param cx The new width of the window, in pixels. + * + * @param cy The new height of the window, in pixels. + * + * @param uFlags The window sizing and positioning flags. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, + int cy, int uFlags); + + /** + * Attaches or detaches the input processing mechanism of one thread to that + * of another thread. + * + * @param idAttach The identifier of the thread to be attached to another + * thread. The thread to be attached cannot be a system thread. + * + * @param idAttachTo The identifier of the thread to which idAttach will be + * attached. This thread cannot be a system thread. A thread cannot attach + * to itself. Therefore, idAttachTo cannot equal idAttach. + * + * @param fAttach If this parameter is TRUE, the two threads are attached. + * If the parameter is FALSE, the threads are detached. + * + * @return If the function succeeds, the return value is nonzero. + */ + boolean AttachThreadInput(DWORD idAttach, DWORD idAttachTo, boolean fAttach); + + /** + * Brings the thread that created the specified window into the foreground + * and activates the window. Keyboard input is directed to the window, and + * various visual cues are changed for the user. The system assigns a + * slightly higher priority to the thread that created the foreground window + * than it does to other threads. + * + * @param hWnd A handle to the window that should be activated and brought + * to the foreground. + * + * @return If the window was brought to the foreground, the return value is + * nonzero. + */ + boolean SetForegroundWindow(HWND hWnd); + + /** + * Retrieves a handle to the foreground window (the window with which the + * user is currently working). The system assigns a slightly higher priority + * to the thread that creates the foreground window than it does to other + * threads. + * + * @return The return value is a handle to the foreground window. The + * foreground window can be NULL in certain circumstances, such as when a + * window is losing activation. + */ + HWND GetForegroundWindow(); + + /** + * Sets the keyboard focus to the specified window. The window must be + * attached to the calling thread's message queue. + * + * @param hWnd A handle to the window that will receive the keyboard input. + * If this parameter is NULL, keystrokes are ignored. + * + * @return If the function succeeds, the return value is the handle to the + * window that previously had the keyboard focus. If the hWnd parameter is + * invalid or the window is not attached to the calling thread's message + * queue, the return value is NULL. To get extended error information, call + * GetLastError. + */ + HWND SetFocus(HWND hWnd); + + /** + * Synthesizes keystrokes, mouse motions, and button clicks. + * + * @param nInputs The number of structures in the pInputs array. + * + * @param pInputs An array of INPUT structures. Each structure represents an + * event to be inserted into the keyboard or mouse input stream. + * + * @param cbSize The size, in bytes, of an INPUT structure. If cbSize is not + * the size of an INPUT structure, the function fails. + * + * @return The function returns the number of events that it successfully + * inserted into the keyboard or mouse input stream. If the function returns + * zero, the input was already blocked by another thread. To get extended + * error information, call GetLastError. + * + * This function fails when it is blocked by UIPI. Note that neither + * GetLastError nor the return value will indicate the failure was caused by + * UIPI blocking. + */ + DWORD SendInput(DWORD nInputs, WinUser.INPUT[] pInputs, int cbSize); + + /** + * Waits until the specified process has finished processing its initial + * input and is waiting for user input with no input pending, or until the + * time-out interval has elapsed. + * + * @param hProcess A handle to the process. If this process is a console + * application or does not have a message queue, WaitForInputIdle returns + * immediately. + * + * @param dwMilliseconds The time-out interval, in milliseconds. If + * dwMilliseconds is INFINITE, the function does not return until the + * process is idle. + * + * @return The following table shows the possible return values for this + * function. + *| Return code/value | + *Description | + *
|---|---|
| 0 | + *The wait was satisfied successfully. | + *
| WAIT_TIMEOUT | + *The wait was terminated because the time-out interval elapsed. | + *
| WAIT_FAILED | + *An error occurred. | + *
+ * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + *
+ */ + int RegisterWindowMessage(String string); + + boolean GetIconInfo(HICON hIcon, ICONINFO iconinfo); + + boolean DrawIcon(HDC hDC, int X, int Y, HICON hIcon); + + boolean DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, int diFlags); + + HWND GetDesktopWindow(); + public static final int DI_MASK = 1; + public static final int DI_IMAGE = 2; + public static final int DI_NORMAL = 3; + public static final int DI_COMPAT = 4; + public static final int DI_DEFAULTSIZE = 8; + + int FillRect(HDC hDC, RECT lprc, HANDLE hbr); +} diff --git a/src/com/sun/jna/platform/win32/WinDef.java b/src/com/sun/jna/platform/win32/WinDef.java index f20cab86e..e3895e2df 100644 --- a/src/com/sun/jna/platform/win32/WinDef.java +++ b/src/com/sun/jna/platform/win32/WinDef.java @@ -1,1132 +1,1132 @@ -/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package com.sun.jna.platform.win32; - -import com.sun.jna.IntegerType; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.platform.win32.BaseTSD.LONG_PTR; -import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.ptr.ByReference; -import com.sun.jna.win32.StdCallLibrary; -import java.awt.Rectangle; -import java.util.Arrays; -import java.util.List; - -// TODO: Auto-generated Javadoc -/** - * Ported from Windef.h (various macros and types). Microsoft Windows SDK 6.0A. - * - * @author dblock[at]dblock.org - */ -@SuppressWarnings("serial") -public interface WinDef extends StdCallLibrary { - - /** - * The max path. - */ - int MAX_PATH = 260; - - /** - * 16-bit unsigned integer. - */ - public static class WORD extends IntegerType { - - public static final int SIZE = 2; - - /** - * Instantiates a new word. - */ - public WORD() { - this(0); - } - - /** - * Instantiates a new word. - * - * @param value the value - */ - public WORD(long value) { - super(SIZE, value, true); - } - } - - public static final class WORDbyReference extends ByReference { - - public WORDbyReference() { - this(new WORD(0)); - } - - public WORDbyReference(WORD value) { - super(WORD.SIZE); - setValue(value); - } - - public void setValue(WORD value) { - getPointer().setInt(0, value.intValue()); - } - - public WORD getValue() { - return new WORD(getPointer().getInt(0)); - } - } - - /** - * 32-bit unsigned integer. - */ - public static class DWORD extends IntegerType { - - public static final int SIZE = 4; - - /** - * Instantiates a new dword. - */ - public DWORD() { - this(0); - } - - /** - * Instantiates a new dword. - * - * @param value the value - */ - public DWORD(long value) { - super(SIZE, value, true); - } - - /** - * Low WORD. - * - * @return Low WORD. - */ - public WORD getLow() { - return new WORD(longValue() & 0xFF); - } - - /** - * High WORD. - * - * @return High WORD. - */ - public WORD getHigh() { - return new WORD((longValue() >> 16) & 0xFF); - } - } - - public static final class DWORDbyReference extends ByReference { - - public DWORDbyReference() { - this(new DWORD(0)); - } - - public DWORDbyReference(DWORD value) { - super(DWORD.SIZE); - setValue(value); - } - - public void setValue(DWORD value) { - getPointer().setInt(0, value.intValue()); - } - - public DWORD getValue() { - return new DWORD(getPointer().getInt(0)); - } - } - - public static class LONG extends IntegerType { - - public static final int SIZE = 4; - - public LONG() { - this(0); - } - - public LONG(int value) { - super(SIZE, value); - } - } - - public static final class LONGbyReference extends ByReference { - - public LONGbyReference() { - this(new LONG(0)); - } - - public LONGbyReference(LONG value) { - super(LONG.SIZE); - setValue(value); - } - - public void setValue(LONG value) { - getPointer().setInt(0, value.intValue()); - } - - public LONG getValue() { - return new LONG(getPointer().getInt(0)); - } - } - - public static class LONGLONG extends IntegerType { - - public static final int SIZE = 8; - - public LONGLONG() { - this(0); - } - - public LONGLONG(long value) { - super(8, value, false); - } - } - - public static final class LONGLONGbyReference extends ByReference { - - public LONGLONGbyReference() { - this(new LONGLONG(0)); - } - - public LONGLONGbyReference(LONGLONG value) { - super(LONGLONG.SIZE); - setValue(value); - } - - public void setValue(LONGLONG value) { - getPointer().setLong(0, value.longValue()); - } - - public LONGLONG getValue() { - return new LONGLONG(getPointer().getLong(0)); - } - } - - /** - * Handle to a device context (DC). - */ - public static class HDC extends HANDLE { - - /** - * Instantiates a new hdc. - */ - public HDC() { - } - - /** - * Instantiates a new hdc. - * - * @param p the p - */ - public HDC(Pointer p) { - super(p); - } - } - - /** - * Handle to an icon. - */ - public static class HICON extends HANDLE { - - /** - * Instantiates a new hicon. - */ - public HICON() { - } - - /** - * Instantiates a new hicon. - * - * @param p the p - */ - public HICON(Pointer p) { - super(p); - } - } - - /** - * Handle to a cursor. - */ - public static class HCURSOR extends HICON { - - /** - * Instantiates a new hcursor. - */ - public HCURSOR() { - } - - /** - * Instantiates a new hcursor. - * - * @param p the p - */ - public HCURSOR(Pointer p) { - super(p); - } - } - - /** - * Handle to a cursor. - */ - public static class HMENU extends HANDLE { - - /** - * Instantiates a new hmenu. - */ - public HMENU() { - } - - /** - * Instantiates a new hmenu. - * - * @param p the p - */ - public HMENU(Pointer p) { - super(p); - } - } - - /** - * Handle to a pen. - */ - public static class HPEN extends HANDLE { - - /** - * Instantiates a new hpen. - */ - public HPEN() { - } - - /** - * Instantiates a new hpen. - * - * @param p the p - */ - public HPEN(Pointer p) { - super(p); - } - } - - /** - * Handle to a resource. - */ - public static class HRSRC extends HANDLE { - - /** - * Instantiates a new hrsrc. - */ - public HRSRC() { - } - - /** - * Instantiates a new hrsrc. - * - * @param p the p - */ - public HRSRC(Pointer p) { - super(p); - } - } - - /** - * Handle to a palette. - */ - public static class HPALETTE extends HANDLE { - - /** - * Instantiates a new hpalette. - */ - public HPALETTE() { - } - - /** - * Instantiates a new hpalette. - * - * @param p the p - */ - public HPALETTE(Pointer p) { - super(p); - } - } - - /** - * Handle to a bitmap. - */ - public static class HBITMAP extends HANDLE { - - /** - * Instantiates a new hbitmap. - */ - public HBITMAP() { - } - - /** - * Instantiates a new hbitmap. - * - * @param p the p - */ - public HBITMAP(Pointer p) { - super(p); - } - } - - /** - * Handle to a region. - */ - public static class HRGN extends HANDLE { - - /** - * Instantiates a new hrgn. - */ - public HRGN() { - } - - /** - * Instantiates a new hrgn. - * - * @param p the p - */ - public HRGN(Pointer p) { - super(p); - } - } - - /** - * Handle to a window. - */ - public static class HWND extends HANDLE { - - /** - * Instantiates a new hwnd. - */ - public HWND() { - super(); - } - - /** - * Instantiates a new hwnd. - * - * @param p the p - */ - public HWND(Pointer p) { - super(p); - } - } - - /** - * Handle to an instance. - */ - public static class HINSTANCE extends HANDLE { - } - - /** - * Handle to a module. The value is the base address of the module. - */ - public static class HMODULE extends HINSTANCE { - } - - /** - * Handle to a font. - */ - public static class HFONT extends HANDLE { - - /** - * Instantiates a new hfont. - */ - public HFONT() { - } - - /** - * Instantiates a new hfont. - * - * @param p the p - */ - public HFONT(Pointer p) { - super(p); - } - } - - /** - * Message parameter. - */ - public static class LPARAM extends LONG_PTR { - - /** - * Instantiates a new lparam. - */ - public LPARAM() { - this(0); - } - - /** - * Instantiates a new lparam. - * - * @param value the value - */ - public LPARAM(long value) { - super(value); - } - } - - /** - * Signed result of message processing. - */ - public static class LRESULT extends LONG_PTR { - - /** - * Instantiates a new lresult. - */ - public LRESULT() { - this(0); - } - - /** - * Instantiates a new lresult. - * - * @param value the value - */ - public LRESULT(long value) { - super(value); - } - } - - /** - * Integer type big enough for a pointer. - */ - public static class INT_PTR extends IntegerType { - - /** - * Instantiates a new int ptr. - */ - public INT_PTR() { - super(Pointer.SIZE); - } - - /** - * Instantiates a new int ptr. - * - * @param value the value - */ - public INT_PTR(long value) { - super(Pointer.SIZE, value); - } - - /** - * To pointer. - * - * @return the pointer - */ - public Pointer toPointer() { - return Pointer.createConstant(longValue()); - } - } - - /** - * Unsigned INT_PTR. - */ - public static class UINT_PTR extends IntegerType { - - /** - * Instantiates a new uint ptr. - */ - public UINT_PTR() { - super(Pointer.SIZE); - } - - /** - * Instantiates a new uint ptr. - * - * @param value the value - */ - public UINT_PTR(long value) { - super(Pointer.SIZE, value, true); - } - - /** - * To pointer. - * - * @return the pointer - */ - public Pointer toPointer() { - return Pointer.createConstant(longValue()); - } - } - - /** - * Message parameter. - */ - public static class WPARAM extends UINT_PTR { - - /** - * Instantiates a new wparam. - */ - public WPARAM() { - this(0); - } - - /** - * Instantiates a new wparam. - * - * @param value the value - */ - public WPARAM(long value) { - super(value); - } - } - - /** - * The Class RECT. - */ - public class RECT extends Structure { - - /** - * The left. - */ - public int left; - /** - * The top. - */ - public int top; - /** - * The right. - */ - public int right; - /** - * The bottom. - */ - public int bottom; - - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - @Override - protected List