1 /* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, All Rights Reserved 2 * 3 * The contents of this file is dual-licensed under 2 4 * alternative Open Source/Free licenses: LGPL 2.1 or later and 5 * Apache License 2.0. (starting with JNA version 4.0.0). 6 * 7 * You can freely decide which license you want to apply to 8 * the project. 9 * 10 * You may obtain a copy of the LGPL License at: 11 * 12 * http://www.gnu.org/licenses/licenses.html 13 * 14 * A copy is also included in the downloadable source code package 15 * containing JNA, in file "LGPL2.1". 16 * 17 * You may obtain a copy of the Apache License at: 18 * 19 * http://www.apache.org/licenses/ 20 * 21 * A copy is also included in the downloadable source code package 22 * containing JNA, in file "AL2.0". 23 */ 24 package com.sun.jna.platform.win32; 25 26 import com.sun.jna.Native; 27 import com.sun.jna.Pointer; 28 import com.sun.jna.Structure; 29 import com.sun.jna.platform.win32.WinGDI.ICONINFO; 30 import com.sun.jna.ptr.ByteByReference; 31 import com.sun.jna.ptr.IntByReference; 32 import com.sun.jna.win32.StdCallLibrary; 33 import com.sun.jna.win32.W32APIOptions; 34 35 36 /** 37 * Provides access to the w32 user32 library. Incomplete implementation to 38 * support demos. 39 * 40 * @author Todd Fast, todd.fast@sun.com 41 * @author twalljava@dev.java.net 42 * @author Tobias Wolf, wolf.tobias@gmx.net 43 * @author Markus KARG (markus[at]headcrashing[dot]eu) 44 * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de 45 */ 46 public interface User32 extends StdCallLibrary, WinUser, WinNT { 47 48 /** The instance. */ 49 User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); 50 51 /** 52 * Handle for message-only window. 53 */ 54 HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3)); 55 56 /** The cs globalclass. */ 57 int CS_GLOBALCLASS = 0x4000; 58 59 /** The ws ex topmost. */ 60 int WS_EX_TOPMOST = 0x00000008; 61 62 /** The hRecipient parameter is a window handle. */ 63 int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000; 64 65 /** The hRecipient parameter is a service status handle. */ 66 int DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001; 67 68 /** The device notify all interface classes. */ 69 int DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x00000004; 70 71 /** 72 * <p> 73 * Sets the show state based on the SW_ value specified in the <a href= 74 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms686331(v=vs.85).aspx"> 75 * <strong xmlns="http://www.w3.org/1999/xhtml">STARTUPINFO</strong></a> 76 * structure passed to the <a href= 77 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx"> 78 * <strong xmlns="http://www.w3.org/1999/xhtml">CreateProcess</strong></a> 79 * function by the program that started the application. 80 * </p> 81 */ 82 int SW_SHOWDEFAULT = 10; 83 84 /** 85 * This function retrieves a handle to a display device context (DC) for the 86 * client area of the specified window. The display device context can be 87 * used in subsequent graphics display interface (GDI) functions to draw in 88 * the client area of the window. 89 * 90 * @param hWnd 91 * Handle to the window whose device context is to be retrieved. 92 * If this value is NULL, GetDC retrieves the device context for 93 * the entire screen. 94 * @return The handle the device context for the specified window's client 95 * area indicates success. NULL indicates failure. To get extended 96 * error information, call GetLastError. 97 */ GetDC(HWND hWnd)98 HDC GetDC(HWND hWnd); 99 100 /** 101 * This function releases a device context (DC), freeing it for use by other 102 * applications. The effect of ReleaseDC depends on the type of device 103 * context. 104 * 105 * @param hWnd 106 * Handle to the window whose device context is to be released. 107 * @param hDC 108 * Handle to the device context to be released. 109 * @return The return value specifies whether the device context is 110 * released. 1 indicates that the device context is released. Zero 111 * indicates that the device context is not released. 112 */ ReleaseDC(HWND hWnd, HDC hDC)113 int ReleaseDC(HWND hWnd, HDC hDC); 114 115 /** 116 * This function retrieves the handle to the top-level window whose class 117 * name and window name match the specified strings. This function does not 118 * search child windows. 119 * 120 * @param lpClassName 121 * Long pointer to a null-terminated string that specifies the 122 * class name or is an atom that identifies the class-name 123 * string. If this parameter is an atom, it must be a global atom 124 * created by a previous call to the GlobalAddAtom function. The 125 * atom, a 16-bit value, must be placed in the low-order word of 126 * lpClassName; the high-order word must be zero. 127 * @param lpWindowName 128 * Long pointer to a null-terminated string that specifies the 129 * window name (the window's title). If this parameter is NULL, 130 * all window names match. 131 * @return A handle to the window that has the specified class name and 132 * window name indicates success. NULL indicates failure. To get 133 * extended error information, call GetLastError. 134 */ FindWindow(String lpClassName, String lpWindowName)135 HWND FindWindow(String lpClassName, String lpWindowName); 136 137 /** 138 * This function retrieves the name of the class to which the specified 139 * window belongs. 140 * 141 * @param hWnd 142 * Handle to the window and, indirectly, the class to which the 143 * window belongs. 144 * @param lpClassName 145 * Long pointer to the buffer that is to receive the class name 146 * string. 147 * @param nMaxCount 148 * Specifies the length, in characters, of the buffer pointed to 149 * by the lpClassName parameter. The class name string is 150 * truncated if it is longer than the buffer. 151 * @return The number of characters copied to the specified buffer indicates 152 * success. Zero indicates failure. To get extended error 153 * information, call GetLastError. 154 */ GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount)155 int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount); 156 157 /** 158 * Retrieves information about the active window or a specified graphical 159 * user interface (GUI) thread. 160 * 161 * @param idThread 162 * Identifies the thread for which information is to be 163 * retrieved. To retrieve this value, use the 164 * GetWindowThreadProcessId function. If this parameter is NULL, 165 * the function returns information for the foreground thread. 166 * @param lpgui 167 * Pointer to a GUITHREADINFO structure that receives information 168 * describing the thread. Note that you must set 169 * GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling 170 * this function. 171 * @return If the function succeeds, the return value is nonzero. If the 172 * function fails, the return value is zero. To get extended error 173 * information, call GetLastError. 174 */ GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui)175 boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui); 176 177 /** 178 * The GetWindowInfo function retrieves information about the specified 179 * window. 180 * 181 * @param hWnd 182 * Handle to the window whose information is to be retrieved. 183 * @param pwi 184 * Pointer to a WINDOWINFO structure to receive the information. 185 * Note that you must set WINDOWINFO.cbSize to sizeof(WINDOWINFO) 186 * before calling this function. 187 * @return If the function succeeds, the return value is nonzero. If the 188 * function fails, the return value is zero. 189 */ GetWindowInfo(HWND hWnd, WINDOWINFO pwi)190 boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi); 191 192 /** 193 * This function retrieves the dimensions of the bounding rectangle of the 194 * specified window. The dimensions are given in screen coordinates that are 195 * relative to the upper-left corner of the screen. 196 * 197 * @param hWnd 198 * Handle to the window. 199 * @param rect 200 * Long pointer to a RECT structure that receives the screen 201 * coordinates of the upper-left and lower-right corners of the 202 * window. 203 * @return If the function succeeds, the return value is nonzero. If the 204 * function fails, the return value is zero. 205 */ GetWindowRect(HWND hWnd, RECT rect)206 boolean GetWindowRect(HWND hWnd, RECT rect); 207 208 /** 209 * This function retrieves the coordinates of a window's client area. 210 * The client coordinates specify the upper-left and lower-right corners of the 211 * client area. Because client coordinates are relative to the upper-left 212 * corner of a window's client area, the coordinates of the upper-left corner 213 * are (0,0). 214 * 215 * @param hWnd 216 * Handle to the window. 217 * @param rect 218 * Long pointer to a RECT structure that structure that receives 219 * the client coordinates. The left and top members are zero. The 220 * right and bottom members contain the width and height of the 221 * window. 222 * @return If the function succeeds, the return value is nonzero. If the 223 * function fails, the return value is zero. 224 */ GetClientRect(HWND hWnd, RECT rect)225 boolean GetClientRect(HWND hWnd, RECT rect); 226 227 /** 228 * This function copies the text of the specified window's title bar - if it 229 * has one - into a buffer. If the specified window is a control, the text 230 * of the control is copied. 231 * 232 * @param hWnd 233 * Handle to the window or control containing the text. 234 * @param lpString 235 * Long pointer to the buffer that will receive the text. 236 * @param nMaxCount 237 * Specifies the maximum number of characters to copy to the 238 * buffer, including the NULL character. If the text exceeds this 239 * limit, it is truncated. 240 * @return The length, in characters, of the copied string, not including 241 * the terminating null character, indicates success. Zero indicates 242 * that the window has no title bar or text, if the title bar is 243 * empty, or if the window or control handle is invalid. To get 244 * extended error information, call GetLastError. This function 245 * cannot retrieve the text of an edit control in another 246 * application. 247 */ GetWindowText(HWND hWnd, char[] lpString, int nMaxCount)248 int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount); 249 250 /** 251 * This function retrieves the length, in characters, of the specified 252 * window's title bar text - if the window has a title bar. If the specified 253 * window is a control, the function retrieves the length of the text within 254 * the control. 255 * 256 * @param hWnd 257 * Handle to the window or control. 258 * @return The length, in characters, of the text indicates success. Under 259 * certain conditions, this value may actually be greater than the 260 * length of the text. Zero indicates that the window has no text. 261 * To get extended error information, call GetLastError. 262 */ GetWindowTextLength(HWND hWnd)263 int GetWindowTextLength(HWND hWnd); 264 265 /** 266 * The GetWindowModuleFileName function retrieves the full path and file 267 * name of the module associated with the specified window handle. 268 * 269 * @param hWnd 270 * Handle to the window whose module file name will be retrieved. 271 * @param lpszFileName 272 * Pointer to a buffer that receives the path and file name. 273 * @param cchFileNameMax 274 * Specifies the maximum number of TCHARs that can be copied into 275 * the lpszFileName buffer. 276 * @return The return value is the total number of TCHARs copied into the 277 * buffer. 278 */ GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, int cchFileNameMax)279 int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, int cchFileNameMax); 280 281 /** 282 * This function retrieves the identifier of the thread that created the 283 * specified window and, optionally, the identifier of the process that 284 * created the window. 285 * 286 * @param hWnd 287 * Handle to the window. 288 * @param lpdwProcessId 289 * Pointer to a 32-bit value that receives the process 290 * identifier. If this parameter is not NULL, 291 * GetWindowThreadProcessId copies the identifier of the process 292 * to the 32-bit value; otherwise, it does not. 293 * @return The return value is the identifier of the thread that created the 294 * window. 295 */ GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId)296 int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId); 297 298 /** 299 * This function enumerates all top-level windows on the screen by passing 300 * the handle to each window, in turn, to an application-defined callback 301 * function. EnumWindows continues until the last top-level window is 302 * enumerated or the callback function returns FALSE. 303 * 304 * @param lpEnumFunc 305 * Long pointer to an application-defined callback function. 306 * @param data 307 * Specifies an application-defined value to be passed to the 308 * callback function. 309 * @return Nonzero indicates success. Zero indicates failure. To get 310 * extended error information, call GetLastError. 311 */ EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data)312 boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data); 313 314 /** 315 * The EnumChildWindows function enumerates the child windows that belong to 316 * the specified parent window by passing the handle to each child window, 317 * in turn, to an application-defined callback function. EnumChildWindows 318 * continues until the last child window is enumerated or the callback 319 * function returns FALSE. 320 * 321 * @param hWnd 322 * Handle to the parent window whose child windows are to be 323 * enumerated. If this parameter is NULL, this function is 324 * equivalent to EnumWindows. 325 * @param lpEnumFunc 326 * Pointer to an application-defined callback function. 327 * @param data 328 * Specifies an application-defined value to be passed to the 329 * callback function. 330 * @return If the function succeeds, the return value is nonzero. If the 331 * function fails, the return value is zero. To get extended error 332 * information, call GetLastError. If EnumChildProc returns zero, 333 * the return value is also zero. In this case, the callback 334 * function should call SetLastError to obtain a meaningful error 335 * code to be returned to the caller of EnumChildWindows. 336 */ EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data)337 boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data); 338 339 /** 340 * The EnumThreadWindows function enumerates all nonchild windows associated 341 * with a thread by passing the handle to each window, in turn, to an 342 * application-defined callback function. EnumThreadWindows continues until 343 * the last window is enumerated or the callback function returns FALSE. To 344 * enumerate child windows of a particular window, use the EnumChildWindows 345 * function. 346 * 347 * @param dwThreadId 348 * Identifies the thread whose windows are to be enumerated. 349 * @param lpEnumFunc 350 * Pointer to an application-defined callback function. 351 * @param data 352 * Specifies an application-defined value to be passed to the 353 * callback function. 354 * @return If the callback function returns TRUE for all windows in the 355 * thread specified by dwThreadId, the return value is TRUE. If the 356 * callback function returns FALSE on any enumerated window, or if 357 * there are no windows found in the thread specified by dwThreadId, 358 * the return value is FALSE. 359 */ EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data)360 boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data); 361 362 /** 363 * The FlashWindowEx function flashes the specified window. It does not 364 * change the active state of the window. 365 * 366 * @param pfwi 367 * Pointer to the FLASHWINFO structure. 368 * @return The return value specifies the window's state before the call to 369 * the FlashWindowEx function. If the window caption was drawn as 370 * active before the call, the return value is nonzero. Otherwise, 371 * the return value is zero. 372 */ FlashWindowEx(FLASHWINFO pfwi)373 boolean FlashWindowEx(FLASHWINFO pfwi); 374 375 /** 376 * This function loads the specified icon resource from the executable 377 * (.exe) file associated with an application instance. 378 * 379 * @param hInstance 380 * Handle to an instance of the module whose executable file 381 * contains the icon to be loaded. This parameter must be NULL 382 * when a standard icon is being loaded. 383 * @param iconName 384 * Long pointer to a null-terminated string that contains the 385 * name of the icon resource to be loaded. Alternatively, this 386 * parameter can contain the resource identifier in the low-order 387 * word and zero in the high-order word. Use the MAKEINTRESOURCE 388 * macro to create this value. 389 * <p> 390 * To use one of the predefined icons, set the hInstance 391 * parameter to NULL and the lpIconName parameter to one of the 392 * following values: {@link WinUser#IDC_APPSTARTING} etc.</p> 393 * @return A handle to the newly loaded icon indicates success. NULL 394 * indicates failure. To get extended error information, call 395 * GetLastError. 396 */ LoadIcon(HINSTANCE hInstance, String iconName)397 HICON LoadIcon(HINSTANCE hInstance, String iconName); 398 399 /** 400 * This function loads an icon, cursor, or bitmap. 401 * 402 * @param hinst 403 * Handle to an instance of the module that contains the image to 404 * be loaded. 405 * @param name 406 * Pointer to a null-terminated string that contains the name of 407 * the image resource in the hinst module that identifies the 408 * image to load. 409 * @param type 410 * Specifies the type of image to be loaded. 411 * @param xDesired 412 * Specifies the width, in pixels, of the icon or cursor. If this 413 * parameter is zero, the function uses the SM_CXICON or 414 * SM_CXCURSOR system metric value to set the width. If uType is 415 * IMAGE_BITMAP, this parameter must be zero. 416 * @param yDesired 417 * Specifies the height, in pixels, of the icon or cursor. If 418 * this parameter is zero, the function uses the SM_CYICON or 419 * SM_CYCURSOR system metric value to set the height. If uType is 420 * IMAGE_BITMAP, this parameter must be zero. 421 * @param load 422 * Set to zero. 423 * @return The handle of the newly loaded image indicates success. NULL 424 * indicates failure. To get extended error information, call 425 * GetLastError. 426 */ LoadImage(HINSTANCE hinst, String name, int type, int xDesired, int yDesired, int load)427 HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired, 428 int yDesired, int load); 429 430 /** 431 * This function destroys an icon and frees any memory the icon occupied. 432 * 433 * @param hicon 434 * Handle to the icon to be destroyed. The icon must not be in 435 * use. 436 * @return Nonzero indicates success. Zero indicates failure. To get 437 * extended error information, call GetLastError. 438 */ DestroyIcon(HICON hicon)439 boolean DestroyIcon(HICON hicon); 440 441 /** 442 * This function retrieves information about the specified window. 443 * GetWindowLong also retrieves the 32-bit (long) value at the specified 444 * offset into the extra window memory of a window. 445 * 446 * @param hWnd 447 * Handle to the window and, indirectly, the class to which the 448 * window belongs. 449 * @param nIndex 450 * Specifies the zero-based offset to the value to be retrieved. 451 * @return The requested 32-bit value indicates success. Zero indicates 452 * failure. To get extended error information, call GetLastError. 453 */ GetWindowLong(HWND hWnd, int nIndex)454 int GetWindowLong(HWND hWnd, int nIndex); 455 456 /** 457 * This function changes an attribute of the specified window. SetWindowLong 458 * also sets a 32-bit (LONG) value at the specified offset into the extra 459 * window memory of a window. 460 * 461 * @param hWnd 462 * Handle to the window and, indirectly, the class to which the 463 * window belongs. 464 * @param nIndex 465 * Specifies the zero-based offset to the value to be set. 466 * @param dwNewLong 467 * Specifies the replacement value. 468 * @return The previous value of the specified 32-bit integer indicates 469 * success. Zero indicates failure. To get extended error 470 * information, call GetLastError. 471 */ SetWindowLong(HWND hWnd, int nIndex, int dwNewLong)472 int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong); 473 474 /** 475 * The GetWindowLongPtr function retrieves information about the specified 476 * window. The function also retrieves the value at a specified offset into 477 * the extra window memory. 478 * 479 * @param hWnd 480 * Handle to the window and, indirectly, the class to which the 481 * window belongs. 482 * @param nIndex 483 * Specifies the zero-based offset to the value to be retrieved. 484 * @return If the function succeeds, the return value is the requested 485 * value. If the function fails, the return value is zero. To get 486 * extended error information, call GetLastError. If SetWindowLong 487 * or SetWindowLongPtr has not been called previously, 488 * GetWindowLongPtr returns zero for values in the extra window or 489 * class memory. 490 */ GetWindowLongPtr(HWND hWnd, int nIndex)491 LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex); 492 493 /** 494 * The SetWindowLongPtr function changes an attribute of the specified 495 * window. The function also sets a value at the specified offset in the 496 * extra window memory. 497 * 498 * @param hWnd 499 * Handle to the window and, indirectly, the class to which the 500 * window belongs. 501 * @param nIndex 502 * Specifies the zero-based offset to the value to be set. 503 * @param dwNewLongPtr 504 * Specifies the replacement value. 505 * @return If the function succeeds, the return value is the previous value 506 * of the specified offset. If the function fails, the return value 507 * is zero. To get extended error information, call GetLastError. If 508 * the previous value is zero and the function succeeds, the return 509 * value is zero, but the function does not clear the last error 510 * information. To determine success or failure, clear the last 511 * error information by calling SetLastError(0), then call 512 * SetWindowLongPtr. Function failure will be indicated by a return 513 * value of zero and a GetLastError result that is nonzero. 514 */ SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr)515 Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr); 516 517 /** 518 * The SetLayeredWindowAttributes function sets the opacity and transparency 519 * color key of a layered window. 520 * 521 * @param hwnd 522 * Handle to the layered window. 523 * @param crKey 524 * COLORREF structure that specifies the transparency color key 525 * to be used when composing the layered window. 526 * @param bAlpha 527 * Alpha value used to describe the opacity of the layered 528 * window. 529 * @param dwFlags 530 * Specifies an action to take. 531 * @return If the function succeeds, the return value is nonzero. If the 532 * function fails, the return value is zero. To get extended error 533 * information, call GetLastError. 534 */ SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha, int dwFlags)535 boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha, int dwFlags); 536 537 /** 538 * The GetLayeredWindowAttributes function retrieves the opacity and 539 * transparency color key of a layered window. 540 * 541 * @param hwnd 542 * Handle to the layered window. A layered window is created by 543 * specifying WS_EX_LAYERED when creating the window with the 544 * CreateWindowEx function or by setting WS_EX_LAYERED via 545 * SetWindowLong after the window has been created. 546 * @param pcrKey 547 * Pointer to a COLORREF value that receives the transparency 548 * color key to be used when composing the layered window. All 549 * pixels painted by the window in this color will be 550 * transparent. This can be NULL if the argument is not needed. 551 * @param pbAlpha 552 * Pointer to a BYTE that receives the Alpha value used to 553 * describe the opacity of the layered window. Similar to the 554 * SourceConstantAlpha member of the BLENDFUNCTION structure. 555 * When the variable referred to by pbAlpha is 0, the window is 556 * completely transparent. When the variable referred to by 557 * pbAlpha is 255, the window is opaque. This can be NULL if the 558 * argument is not needed. 559 * @param pdwFlags 560 * Pointer to a DWORD that receives a layering flag. This can be 561 * NULL if the argument is not needed. 562 * @return If the function succeeds, the return value is nonzero. If the 563 * function fails, the return value is zero. To get extended error 564 * information, call GetLastError. 565 */ GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey, ByteByReference pbAlpha, IntByReference pdwFlags)566 boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey, 567 ByteByReference pbAlpha, IntByReference pdwFlags); 568 569 /** 570 * The UpdateLayeredWindow function updates the position, size, shape, 571 * content, and translucency of a layered window. 572 * 573 * @param hwnd 574 * Handle to a layered window. A layered window is created by 575 * specifying WS_EX_LAYERED when creating the window with the 576 * CreateWindowEx function. 577 * @param hdcDst 578 * Handle to a device context (DC) for the screen. This handle is 579 * obtained by specifying NULL when calling the function. It is 580 * used for palette color matching when the window contents are 581 * updated. If hdcDst isNULL, the default palette will be used. 582 * If hdcSrc is NULL, hdcDst must be NULL. 583 * @param pptDst 584 * Pointer to a POINT structure that specifies the new screen 585 * position of the layered window. If the current position is not 586 * changing, pptDst can be NULL. 587 * @param psize 588 * Pointer to a SIZE structure that specifies the new size of the 589 * layered window. If the size of the window is not changing, 590 * psize can be NULL. If hdcSrc is NULL, psize must be NULL. 591 * @param hdcSrc 592 * Handle to a DC for the surface that defines the layered 593 * window. This handle can be obtained by calling the 594 * CreateCompatibleDC function. If the shape and visual context 595 * of the window are not changing, hdcSrc can be NULL. 596 * @param pptSrc 597 * Pointer to a POINT structure that specifies the location of 598 * the layer in the device context. If hdcSrc is NULL, pptSrc 599 * should be NULL. 600 * @param crKey 601 * Pointer to a COLORREF value that specifies the color key to be 602 * used when composing the layered window. To generate a 603 * COLORREF, use the RGB macro. 604 * @param pblend 605 * Pointer to a BLENDFUNCTION structure that specifies the 606 * transparency value to be used when composing the layered 607 * window. 608 * @param dwFlags 609 * ULW_* flags. 610 * @return If the function succeeds, the return value is nonzero. If the 611 * function fails, the return value is zero. To get extended error 612 * information, call GetLastError. 613 */ UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst, SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey, BLENDFUNCTION pblend, int dwFlags)614 boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst, 615 SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey, 616 BLENDFUNCTION pblend, int dwFlags); 617 618 /** 619 * This function sets the window region of a window. The window region 620 * determines the area within the window where the system permits drawing. 621 * The system does not display any portion of a window that lies outside of 622 * the window region. 623 * 624 * @param hWnd 625 * Handle to the window whose window region is to be set. 626 * @param hRgn 627 * Handle to a region. The function sets the window region of the 628 * window to this region. If hRgn is NULL, the function sets the 629 * window region to NULL. 630 * @param bRedraw 631 * Specifies whether the system redraws the window after setting 632 * the window region. If bRedraw is TRUE, the system does so; 633 * otherwise, it does not. Typically, you set bRedraw to TRUE if 634 * the window is visible. 635 * @return Nonzero indicates success. Zero indicates failure. To get 636 * extended error information, call GetLastError. 637 */ SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw)638 int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw); 639 640 /** 641 * The GetKeyboardState function copies the status of the 256 virtual keys 642 * to the specified buffer. 643 * 644 * @param lpKeyState 645 * Pointer to the 256-byte array that receives the status data 646 * for each virtual key. 647 * @return If the function succeeds, the return value is nonzero. If the 648 * function fails, the return value is zero. To get extended error 649 * information, call GetLastError. 650 */ GetKeyboardState(byte[] lpKeyState)651 boolean GetKeyboardState(byte[] lpKeyState); 652 653 /** 654 * This function determines whether a key is up or down at the time the 655 * function is called, and whether the key was pressed after a previous call 656 * to GetAsyncKeyState. 657 * 658 * @param vKey 659 * Specifies one of 256 possible virtual-key codes. 660 * @return If the function succeeds, the return value specifies whether the 661 * key was pressed since the last call to GetAsyncKeyState, and 662 * whether the key is currently up or down. If the most significant 663 * bit is set, the key is down. 664 */ GetAsyncKeyState(int vKey)665 short GetAsyncKeyState(int vKey); 666 667 /** 668 * The SetWindowsHookEx function installs an application-defined hook 669 * procedure into a hook chain. You would install a hook procedure to 670 * monitor the system for certain types of events. These events are 671 * associated either with a specific thread or with all threads in the same 672 * desktop as the calling thread. 673 * 674 * @param idHook 675 * Specifies the type of hook procedure to be installed. 676 * @param lpfn 677 * Pointer to the hook procedure. 678 * @param hMod 679 * Handle to the DLL containing the hook procedure pointed to by 680 * the lpfn parameter. 681 * @param dwThreadId 682 * Specifies the identifier of the thread with which the hook 683 * procedure is to be associated. 684 * @return If the function succeeds, the return value is the handle to the 685 * hook procedure. If the function fails, the return value is NULL. 686 * To get extended error information, call GetLastError. 687 */ SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, int dwThreadId)688 HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, int dwThreadId); 689 690 /** 691 * The CallNextHookEx function passes the hook information to the next hook 692 * procedure in the current hook chain. A hook procedure can call this 693 * function either before or after processing the hook information. 694 * 695 * @param hhk 696 * Ignored. 697 * @param nCode 698 * Specifies the hook code passed to the current hook procedure. 699 * The next hook procedure uses this code to determine how to 700 * process the hook information. 701 * @param wParam 702 * Specifies the wParam value passed to the current hook 703 * procedure. The meaning of this parameter depends on the type 704 * of hook associated with the current hook chain. 705 * @param lParam 706 * Specifies the lParam value passed to the current hook 707 * procedure. The meaning of this parameter depends on the type 708 * of hook associated with the current hook chain. 709 * @return This value is returned by the next hook procedure in the chain. 710 * The current hook procedure must also return this value. The 711 * meaning of the return value depends on the hook type. 712 */ CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam)713 LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam); 714 715 /** 716 * The UnhookWindowsHookEx function removes a hook procedure installed in a 717 * hook chain by the SetWindowsHookEx function. 718 * 719 * @param hhk 720 * Handle to the hook to be removed. This parameter is a hook 721 * handle obtained by a previous call to SetWindowsHookEx. 722 * @return If the function succeeds, the return value is nonzero. If the 723 * function fails, the return value is zero. To get extended error 724 * information, call GetLastError. 725 */ UnhookWindowsHookEx(HHOOK hhk)726 boolean UnhookWindowsHookEx(HHOOK hhk); 727 728 /** 729 * This function retrieves a message from the calling thread's message queue 730 * and places it in the specified structure. 731 * 732 * @param lpMsg 733 * Pointer to an MSG structure that receives message information 734 * from the thread's message queue. 735 * @param hWnd 736 * Handle to the window whose messages are to be retrieved. One 737 * value has a special meaning. 738 * @param wMsgFilterMin 739 * Specifies the integer value of the lowest message value to be 740 * retrieved. 741 * @param wMsgFilterMax 742 * Specifies the integer value of the highest message value to be 743 * retrieved. 744 * @return If the function retrieves a message other than WM_QUIT, the 745 * return value is nonzero. 746 * 747 * <p>If the function retrieves the WM_QUIT message, the return value is zero.</p> 748 * 749 * <p>If there is an error, the return value is -1. For example, the function 750 * fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. 751 * To get extended error information, call GetLastError.</p> 752 */ GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax)753 int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax); 754 755 /** 756 * This function checks a thread message queue for a message and places the 757 * message (if any) in the specified structure. 758 * 759 * @param lpMsg 760 * Pointer to an MSG structure that receives message information. 761 * @param hWnd 762 * Handle to the window whose messages are to be examined. 763 * @param wMsgFilterMin 764 * Specifies the value of the first message in the range of 765 * messages to be examined. 766 * @param wMsgFilterMax 767 * Specifies the value of the last message in the range of 768 * messages to be examined. 769 * @param wRemoveMsg 770 * Specifies how messages are handled. This parameter can be one 771 * of the following values. 772 * @return Nonzero indicates success. Zero indicates failure. 773 */ PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg)774 boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, 775 int wMsgFilterMax, int wRemoveMsg); 776 777 /** 778 * This function translates virtual-key messages into character messages. 779 * The character messages are posted to the calling thread's message queue, 780 * to be read the next time the thread calls the GetMessage or PeekMessage 781 * function. 782 * 783 * @param lpMsg 784 * Pointer to an MSG structure that contains message information 785 * retrieved from the calling thread's message queue by using the 786 * GetMessage or PeekMessage function. 787 * @return Nonzero indicates that the message is translated, that is, a 788 * character message is posted to the thread's message queue. If the 789 * message is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is 790 * nonzero, regardless of the translation. Zero indicates that the 791 * message is not translated, that is, a character message is not 792 * posted to the thread's message queue. 793 */ TranslateMessage(MSG lpMsg)794 boolean TranslateMessage(MSG lpMsg); 795 796 /** 797 * This function dispatches a message to a window procedure. It is typically 798 * used to dispatch a message retrieved by the GetMessage function. 799 * 800 * @param lpMsg 801 * Pointer to an MSG structure that contains the message. 802 * @return The return value specifies the value returned by the window 803 * procedure. Although its meaning depends on the message being 804 * dispatched, the return value generally is ignored. 805 */ DispatchMessage(MSG lpMsg)806 LRESULT DispatchMessage(MSG lpMsg); 807 808 /** 809 * This function places a message in the message queue associated with the 810 * thread that created the specified window and then returns without waiting 811 * for the thread to process the message. Messages in a message queue are 812 * retrieved by calls to the GetMessage or PeekMessage function. 813 * 814 * @param hWnd 815 * Handle to the window whose window procedure is to receive the 816 * message. 817 * @param msg 818 * Specifies the message to be posted. 819 * @param wParam 820 * Specifies additional message-specific information. 821 * @param lParam 822 * Specifies additional message-specific information. 823 */ PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam)824 void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam); 825 826 /** 827 * Posts a message to the message queue of the specified thread. It returns 828 * without waiting for the thread to process the message. 829 * 830 * @param idThread The identifier of the thread to which the message is to 831 * be posted. 832 * 833 * <p>The function fails if the specified thread does not have a 834 * message queue. The system creates a thread's message queue when the 835 * thread makes its first call to one of the User or GDI functions.</p> 836 * 837 * <p>Message posting is subject to UIPI. The thread of a process can post 838 * messages only to posted-message queues of threads in processes of lesser 839 * or equal integrity level.</p> 840 * 841 * <p>This thread must have the SE_TCB_NAME privilege to post a message to a 842 * thread that belongs to a process with the same locally unique identifier 843 * (LUID) but is in a different desktop. Otherwise, the function fails 844 * and returns ERROR_INVALID_THREAD_ID.</p> 845 * 846 * <p>This thread must either belong to the same desktop as the calling 847 * thread or to a process with the same LUID. Otherwise, the function 848 * fails and returns ERROR_INVALID_THREAD_ID.</p> 849 * 850 * @param Msg The type of message to be posted. 851 * 852 * @param wParam Additional message-specific information. 853 * 854 * @param lParam Additional message-specific information. 855 * 856 * @return If the function succeeds, the return value is nonzero. 857 * 858 * <p>If the function fails, the return value is zero. To get extended error 859 * information, call GetLastError.</p><p>GetLastError returns 860 * ERROR_INVALID_THREAD_ID if idThread is not a valid thread identifier, or 861 * if the thread specified by idThread does not have a message queue.</p> 862 * <p>GetLastError returns ERROR_NOT_ENOUGH_QUOTA when the message limit is hit.</p> 863 */ PostThreadMessage(int idThread, int Msg, WPARAM wParam, LPARAM lParam)864 int PostThreadMessage(int idThread, int Msg, WPARAM wParam, LPARAM lParam); 865 866 /** 867 * This function indicates to Windows that a thread has made a request to 868 * terminate (quit). It is typically used in response to a WM_DESTROY 869 * message. 870 * 871 * @param nExitCode 872 * Specifies an application exit code. This value is used as the 873 * wParam parameter of the WM_QUIT message. 874 */ PostQuitMessage(int nExitCode)875 void PostQuitMessage(int nExitCode); 876 877 /** 878 * The GetSystemMetrics function retrieves various system metrics (widths 879 * and heights of display elements) and system configuration settings. All 880 * dimensions retrieved by GetSystemMetrics are in pixels. 881 * 882 * @param nIndex 883 * System metric or configuration setting to retrieve. This 884 * parameter can be one of the following values. Note that all 885 * SM_CX* values are widths and all SM_CY* values are heights. 886 * Also note that all settings designed to return Boolean data 887 * represent TRUE as any nonzero value, and FALSE as a zero 888 * value. 889 * @return If the function succeeds, the return value is the requested 890 * system metric or configuration setting. If the function fails, 891 * the return value is zero. GetLastError does not provide extended 892 * error information. 893 */ GetSystemMetrics(int nIndex)894 int GetSystemMetrics(int nIndex); 895 896 /** 897 * Changes the parent window of the specified child window. 898 * 899 * @param hWndChild 900 * A handle to the child window. 901 * 902 * @param hWndNewParent 903 * A handle to the new parent window. If this parameter is NULL, 904 * the desktop window becomes the new parent window. If this 905 * parameter is HWND_MESSAGE, the child window becomes a 906 * message-only window. 907 * 908 * @return If the function succeeds, the return value is nonzero. 909 * 910 * If the function fails, the return value is zero. To get extended 911 * error information, call GetLastError. 912 */ SetParent(HWND hWndChild, HWND hWndNewParent)913 HWND SetParent(HWND hWndChild, HWND hWndNewParent); 914 915 /** 916 * Determines the visibility state of the specified window. 917 * 918 * @param hWnd 919 * A handle to the window to be tested. 920 * 921 * @return If the specified window, its parent window, its parent's parent 922 * window, and so forth, have the WS_VISIBLE style, the return value 923 * is nonzero. Otherwise, the return value is zero. 924 * 925 * Because the return value specifies whether the window has the 926 * WS_VISIBLE style, it may be nonzero even if the window is totally 927 * obscured by other windows. 928 */ IsWindowVisible(HWND hWnd)929 boolean IsWindowVisible(HWND hWnd); 930 931 /** 932 * Changes the position and dimensions of the specified window. For a 933 * top-level window, the position and dimensions are relative to the 934 * upper-left corner of the screen. For a child window, they are relative to 935 * the upper-left corner of the parent window's client area. 936 * 937 * @param hWnd 938 * A handle to the window. 939 * 940 * @param X 941 * The new position of the left side of the window. 942 * 943 * @param Y 944 * The new position of the top of the window. 945 * 946 * @param nWidth 947 * The new width of the window. 948 * 949 * @param nHeight 950 * The new height of the window. 951 * 952 * @param bRepaint 953 * Indicates whether the window is to be repainted. If this 954 * parameter is TRUE, the window receives a message. If the 955 * parameter is FALSE, no repainting of any kind occurs. This 956 * applies to the client area, the nonclient area (including the 957 * title bar and scroll bars), and any part of the parent window 958 * uncovered as a result of moving a child window. 959 * 960 * @return If the function succeeds, the return value is nonzero. 961 * 962 * If the function fails, the return value is zero. To get extended 963 * error information, call GetLastError. 964 */ MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, boolean bRepaint)965 boolean MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, boolean bRepaint); 966 967 /** 968 * Changes the size, position, and Z order of a child, pop-up, or top-level 969 * window. These windows are ordered according to their appearance on the 970 * screen. The topmost window receives the highest rank and is the first 971 * window in the Z order. 972 * 973 * @param hWnd 974 * A handle to the window. 975 * 976 * @param hWndInsertAfter 977 * A handle to the window to precede the positioned window in the 978 * Z order. 979 * 980 * @param X 981 * The new position of the left side of the window, in client 982 * coordinates. 983 * 984 * @param Y 985 * The new position of the top of the window, in client 986 * coordinates. 987 * 988 * @param cx 989 * The new width of the window, in pixels. 990 * 991 * @param cy 992 * The new height of the window, in pixels. 993 * 994 * @param uFlags 995 * The window sizing and positioning flags. 996 * 997 * @return If the function succeeds, the return value is nonzero. 998 * 999 * If the function fails, the return value is zero. To get extended 1000 * error information, call GetLastError. 1001 */ SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags)1002 boolean SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, 1003 int cy, int uFlags); 1004 1005 /** 1006 * Attaches or detaches the input processing mechanism of one thread to that 1007 * of another thread. 1008 * 1009 * @param idAttach 1010 * The identifier of the thread to be attached to another thread. 1011 * The thread to be attached cannot be a system thread. 1012 * 1013 * @param idAttachTo 1014 * The identifier of the thread to which idAttach will be 1015 * attached. This thread cannot be a system thread. A thread 1016 * cannot attach to itself. Therefore, idAttachTo cannot equal 1017 * idAttach. 1018 * 1019 * @param fAttach 1020 * If this parameter is TRUE, the two threads are attached. If 1021 * the parameter is FALSE, the threads are detached. 1022 * 1023 * @return If the function succeeds, the return value is nonzero. 1024 */ AttachThreadInput(DWORD idAttach, DWORD idAttachTo, boolean fAttach)1025 boolean AttachThreadInput(DWORD idAttach, DWORD idAttachTo, boolean fAttach); 1026 1027 /** 1028 * Brings the thread that created the specified window into the foreground 1029 * and activates the window. Keyboard input is directed to the window, and 1030 * various visual cues are changed for the user. The system assigns a 1031 * slightly higher priority to the thread that created the foreground window 1032 * than it does to other threads. 1033 * 1034 * @param hWnd 1035 * A handle to the window that should be activated and brought to 1036 * the foreground. 1037 * 1038 * @return If the window was brought to the foreground, the return value is 1039 * nonzero. 1040 */ SetForegroundWindow(HWND hWnd)1041 boolean SetForegroundWindow(HWND hWnd); 1042 1043 /** 1044 * Retrieves a handle to the foreground window (the window with which the 1045 * user is currently working). The system assigns a slightly higher priority 1046 * to the thread that creates the foreground window than it does to other 1047 * threads. 1048 * 1049 * @return The return value is a handle to the foreground window. The 1050 * foreground window can be NULL in certain circumstances, such as 1051 * when a window is losing activation. 1052 */ GetForegroundWindow()1053 HWND GetForegroundWindow(); 1054 1055 /** 1056 * Sets the keyboard focus to the specified window. The window must be 1057 * attached to the calling thread's message queue. 1058 * 1059 * @param hWnd 1060 * A handle to the window that will receive the keyboard input. 1061 * If this parameter is NULL, keystrokes are ignored. 1062 * 1063 * @return If the function succeeds, the return value is the handle to the 1064 * window that previously had the keyboard focus. If the hWnd 1065 * parameter is invalid or the window is not attached to the calling 1066 * thread's message queue, the return value is NULL. To get extended 1067 * error information, call GetLastError. 1068 */ SetFocus(HWND hWnd)1069 HWND SetFocus(HWND hWnd); 1070 1071 /** 1072 * Synthesizes keystrokes, mouse motions, and button clicks. 1073 * 1074 * @param nInputs 1075 * The number of structures in the pInputs array. 1076 * 1077 * @param pInputs 1078 * An array of INPUT structures. Each structure represents an 1079 * event to be inserted into the keyboard or mouse input stream. 1080 * 1081 * @param cbSize 1082 * The size, in bytes, of an INPUT structure. If cbSize is not 1083 * the size of an INPUT structure, the function fails. 1084 * 1085 * @return The function returns the number of events that it successfully 1086 * inserted into the keyboard or mouse input stream. If the function 1087 * returns zero, the input was already blocked by another thread. To 1088 * get extended error information, call GetLastError. 1089 * 1090 * This function fails when it is blocked by UIPI. Note that neither 1091 * GetLastError nor the return value will indicate the failure was 1092 * caused by UIPI blocking. 1093 */ SendInput(DWORD nInputs, WinUser.INPUT[] pInputs, int cbSize)1094 DWORD SendInput(DWORD nInputs, WinUser.INPUT[] pInputs, int cbSize); 1095 1096 /** 1097 * Waits until the specified process has finished processing its initial 1098 * input and is waiting for user input with no input pending, or until the 1099 * time-out interval has elapsed. 1100 * 1101 * @param hProcess 1102 * A handle to the process. If this process is a console 1103 * application or does not have a message queue, WaitForInputIdle 1104 * returns immediately. 1105 * 1106 * @param dwMilliseconds 1107 * The time-out interval, in milliseconds. If dwMilliseconds is 1108 * INFINITE, the function does not return until the process is 1109 * idle. 1110 * 1111 * @return The following table shows the possible return values for this 1112 * function. 1113 * <table> 1114 * <caption>Possible return values</caption> 1115 * <tr> 1116 * <th>Return code/value</th> 1117 * <th>Description</th> 1118 * </tr> 1119 * <tr> 1120 * <td>0</td> 1121 * <td>The wait was satisfied successfully.</td> 1122 * </tr> 1123 * <tr> 1124 * <td>WAIT_TIMEOUT</td> 1125 * <td>The wait was terminated because the time-out interval 1126 * elapsed.</td> 1127 * </tr> 1128 * <tr> 1129 * <td>WAIT_FAILED</td> 1130 * <td>An error occurred.</td> 1131 * </tr> 1132 * </table> 1133 */ WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds)1134 DWORD WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds); 1135 1136 /** 1137 * The InvalidateRect function adds a rectangle to the specified window's 1138 * update region. The update region represents the portion of the window's 1139 * client area that must be redrawn. 1140 * 1141 * @param hWnd 1142 * A handle to the window whose update region has changed. If 1143 * this parameter is NULL, the system invalidates and redraws all 1144 * windows, not just the windows for this application, and sends 1145 * the WM_ERASEBKGND and WM_NCPAINT messages before the function 1146 * returns. Setting this parameter to NULL is not recommended. 1147 * 1148 * @param lpRect 1149 * A pointer to a RECT structure that contains the client 1150 * coordinates of the rectangle to be added to the update region. 1151 * If this parameter is NULL, the entire client area is added to 1152 * the update region. 1153 * 1154 * @param bErase 1155 * Specifies whether the background within the update region is 1156 * to be erased when the update region is processed. If this 1157 * parameter is TRUE, the background is erased when the 1158 * BeginPaint function is called. If this parameter is FALSE, the 1159 * background remains unchanged. 1160 * 1161 * @return If the function succeeds, the return value is nonzero. If the 1162 * function fails, the return value is zero. 1163 */ InvalidateRect(HWND hWnd, RECT lpRect, boolean bErase)1164 boolean InvalidateRect(HWND hWnd, RECT lpRect, boolean bErase); 1165 1166 /** 1167 * The RedrawWindow function updates the specified rectangle or region in a 1168 * window's client area. 1169 * 1170 * @param hWnd 1171 * A handle to the window to be redrawn. If this parameter is 1172 * NULL, the desktop window is updated. 1173 * 1174 * @param lprcUpdate 1175 * A pointer to a RECT structure containing the coordinates, in 1176 * device units, of the update rectangle. This parameter is 1177 * ignored if the hrgnUpdate parameter identifies a region. 1178 * 1179 * @param hrgnUpdate 1180 * A handle to the update region. If both the hrgnUpdate and 1181 * lprcUpdate parameters are NULL, the entire client area is 1182 * added to the update region. 1183 * 1184 * @param flags 1185 * One or more redraw flags. This parameter can be used to 1186 * invalidate or validate a window, control repainting, and 1187 * control which windows are affected by RedrawWindow. 1188 * 1189 * @return If the function succeeds, the return value is nonzero. If the 1190 * function fails, the return value is zero. 1191 */ RedrawWindow(HWND hWnd, RECT lprcUpdate, HRGN hrgnUpdate, DWORD flags)1192 boolean RedrawWindow(HWND hWnd, RECT lprcUpdate, HRGN hrgnUpdate, DWORD flags); 1193 1194 /** 1195 * Retrieves a handle to a window that has the specified relationship 1196 * (Z-Order or owner) to the specified window. 1197 * 1198 * @param hWnd 1199 * A handle to a window. The window handle retrieved is relative 1200 * to this window, based on the value of the uCmd parameter. 1201 * 1202 * @param uCmd 1203 * The relationship between the specified window and the window 1204 * whose handle is to be retrieved. 1205 * 1206 * @return If the function succeeds, the return value is a window handle. If 1207 * no window exists with the specified relationship to the specified 1208 * window, the return value is NULL. To get extended error 1209 * information, call GetLastError. 1210 */ GetWindow(HWND hWnd, DWORD uCmd)1211 HWND GetWindow(HWND hWnd, DWORD uCmd); 1212 1213 /** 1214 * The UpdateWindow function updates the client area of the specified window 1215 * by sending a WM_PAINT message to the window if the window's update region 1216 * is not empty. The function sends a WM_PAINT message directly to the 1217 * window procedure of the specified window, bypassing the application 1218 * queue. If the update region is empty, no message is sent. 1219 * 1220 * @param hWnd 1221 * Handle to the window to be updated. 1222 * 1223 * @return If the function succeeds, the return value is nonzero. If the 1224 * function fails, the return value is zero. 1225 */ UpdateWindow(HWND hWnd)1226 boolean UpdateWindow(HWND hWnd); 1227 1228 /** 1229 * Sets the specified window's show state. 1230 * 1231 * @param hWnd 1232 * A handle to the window. 1233 * 1234 * @param nCmdShow 1235 * Controls how the window is to be shown. This parameter is 1236 * ignored the first time an application calls ShowWindow, if the 1237 * program that launched the application provides a STARTUPINFO 1238 * structure. Otherwise, the first time ShowWindow is called, the 1239 * value should be the value obtained by the WinMain function in 1240 * its nCmdShow parameter. 1241 * 1242 * @return If the function succeeds, the return value is nonzero. 1243 * 1244 * If the function fails, the return value is zero. To get extended 1245 * error information, call GetLastError. 1246 */ ShowWindow(HWND hWnd, int nCmdShow)1247 boolean ShowWindow(HWND hWnd, int nCmdShow); 1248 1249 /** 1250 * Minimizes (but does not destroy) the specified window. 1251 * 1252 * @param hWnd 1253 * A handle to the window to be minimized. 1254 * 1255 * @return If the function succeeds, the return value is nonzero. 1256 * 1257 * If the function fails, the return value is zero. To get extended 1258 * error information, call GetLastError. 1259 */ CloseWindow(HWND hWnd)1260 boolean CloseWindow(HWND hWnd); 1261 1262 /** 1263 * Defines a system-wide hot key. 1264 * 1265 * @param hWnd 1266 * A handle to the window that will receive 1267 * @param id 1268 * The identifier of the hot key 1269 * @param fsModifiers 1270 * The keys that must be pressed in combination with the key 1271 * specified by the uVirtKey parameter in order to generate the 1272 * @param vk 1273 * The virtual-key code of the hot key 1274 * @return If the function succeeds, the return value is nonzero. 1275 * 1276 * <p>If the function fails, the return value is zero. To get extended 1277 * error information, call {@link Kernel32#GetLastError}. 1278 * {@link WinUser#WM_HOTKEY} messages generated by the hot key 1279 * {@link WinUser#WM_HOTKEY} message.</p> 1280 * A combination of the following values 1281 * <ul> 1282 * <li>{@link WinUser#MOD_ALT} Either ALT key must be held down.</li> 1283 * <li>{@link WinUser#MOD_CONTROL} Either CTRL key must be held 1284 * down.</li> 1285 * <li>{@link WinUser#MOD_NOREPEAT} Changes the hotkey behavior so 1286 * that the keyboard auto-repeat does not yield multiple hotkey 1287 * notifications. <p><b> 1288 * Windows Vista and Windows XP/2000: This flag is not 1289 * supported.</b></p></li> 1290 * <li>{@link WinUser#MOD_SHIFT} Either SHIFT key must be held down. 1291 * </li> 1292 * <li>{@link WinUser#MOD_WIN} Either WINDOWS key was held down. 1293 * These keys are labeled with the Windows logo.</li> 1294 * </ul> 1295 */ RegisterHotKey(HWND hWnd, int id, int fsModifiers, int vk)1296 boolean RegisterHotKey(HWND hWnd, int id, int fsModifiers, int vk); 1297 1298 /** 1299 * Frees a hot key previously registered by the calling thread. 1300 * 1301 * @param hWnd 1302 * A handle to the window associated with the hot key to be 1303 * freed. This parameter should be NULL if the hot key is not 1304 * associated with a window. 1305 * 1306 * @param id 1307 * The identifier of the hot key to be freed. 1308 * 1309 * @return If the function succeeds, the return value is nonzero. 1310 * 1311 * If the function fails, the return value is zero. To get extended 1312 * error information, call {@link Kernel32#GetLastError}. 1313 */ UnregisterHotKey(Pointer hWnd, int id)1314 boolean UnregisterHotKey(Pointer hWnd, int id); 1315 1316 /** 1317 * Retrieves the time of the last input event. 1318 * 1319 * @param plii 1320 * structure that receives the time of the last input event 1321 * @return If the function succeeds, the return value is nonzero. 1322 * 1323 * If the function fails, the return value is zero. To get extended 1324 * error information, call {@link Kernel32#GetLastError}. 1325 */ GetLastInputInfo(LASTINPUTINFO plii)1326 boolean GetLastInputInfo(LASTINPUTINFO plii); 1327 1328 /** 1329 * Registers a window class for subsequent use in calls to the CreateWindow 1330 * or CreateWindowEx function. 1331 * 1332 * @param lpwcx 1333 * Type: const WNDCLASSEX* A pointer to a WNDCLASSEX structure. 1334 * You must fill the structure with the appropriate class 1335 * attributes before passing it to the function. 1336 * 1337 * @return If the function succeeds, the return value is a class atom that 1338 * uniquely identifies the class being registered. This atom can 1339 * only be used by the CreateWindow, CreateWindowEx, GetClassInfo, 1340 * GetClassInfoEx, FindWindow, FindWindowEx, and UnregisterClass 1341 * functions and the IActiveIMMap::FilterClientWindows method. 1342 * 1343 * If the function fails, the return value is zero. To get extended 1344 * error information, call {@link Kernel32#GetLastError}. 1345 */ RegisterClassEx(WNDCLASSEX lpwcx)1346 ATOM RegisterClassEx(WNDCLASSEX lpwcx); 1347 1348 /** 1349 * Unregisters a window class, freeing the memory required for the class. 1350 * 1351 * @param lpClassName 1352 * [in] Type: LPCTSTR 1353 * 1354 * A null-terminated string or a class atom. If lpClassName is a 1355 * string, it specifies the window class name. This class name 1356 * must have been registered by a previous call to the 1357 * RegisterClass or RegisterClassEx function. System classes, 1358 * such as dialog box controls, cannot be unregistered. If this 1359 * parameter is an atom, it must be a class atom created by a 1360 * previous call to the RegisterClass or RegisterClassEx 1361 * function. The atom must be in the low-order word of 1362 * lpClassName; the high-order word must be zero. 1363 * 1364 * @param hInstance 1365 * [in,optional] Type: HINSTANCE A handle to the instance of the 1366 * module that created the class. * 1367 * 1368 * @return Type: BOOL If the function succeeds, the return value is nonzero. 1369 * 1370 * If the function fails, the return value is zero. To get extended 1371 * error information, call {@link Kernel32#GetLastError}. 1372 */ UnregisterClass(String lpClassName, HINSTANCE hInstance)1373 boolean UnregisterClass(String lpClassName, HINSTANCE hInstance); 1374 1375 /** 1376 * Creates an overlapped, pop-up, or child window with an extended window 1377 * style; otherwise, this function is identical to the CreateWindow 1378 * function. For more information about creating a window and for full 1379 * descriptions of the other parameters of CreateWindowEx, see CreateWindow. 1380 * 1381 * @param dwExStyle 1382 * [in] Type: DWORD 1383 * 1384 * The extended window style of the window being created. For a 1385 * list of possible values,see Extended Window Styles. 1386 * 1387 * @param lpClassName 1388 * [in, optional] Type: LPCTSTR 1389 * 1390 * A null-terminated string or a class atom created by a previous 1391 * call to the RegisterClass or RegisterClassEx function. The 1392 * atom must be in the low-order word of lpClassName; the 1393 * high-order word must be zero. If lpClassName is a string, it 1394 * specifies the window class name. The class name can be any 1395 * name registered with RegisterClass or RegisterClassEx, 1396 * provided that the module that registers the class is also the 1397 * module that creates the window. The class name can also be any 1398 * of the predefined system class names. 1399 * 1400 * @param lpWindowName 1401 * [in, optional] Type: LPCTSTR 1402 * 1403 * The window name. If the window style specifies a title bar, 1404 * the window title pointed to by lpWindowName is displayed in 1405 * the title bar. When using CreateWindow to create controls, 1406 * such as buttons, check boxes, and static controls, use 1407 * lpWindowName to specify the text of the control. When creating 1408 * a static control with the SS_ICON style, use lpWindowName to 1409 * specify the icon name or identifier. To specify an identifier, 1410 * use the syntax "#num". 1411 * 1412 * @param dwStyle 1413 * [in] Type: DWORD 1414 * 1415 * The style of the window being created. This parameter can be a 1416 * combination of the window style values, plus the control 1417 * styles indicated in the Remarks section. 1418 * 1419 * @param x 1420 * [in] Type: int 1421 * 1422 * The initial horizontal position of the window. For an 1423 * overlapped or pop-up window, the x parameter is the initial 1424 * x-coordinate of the window's upper-left corner, in screen 1425 * coordinates. For a child window, x is the x-coordinate of the 1426 * upper-left corner of the window relative to the upper-left 1427 * corner of the parent window's client area. If x is set to 1428 * CW_USEDEFAULT, the system selects the default position for the 1429 * window's upper-left corner and ignores the y parameter. 1430 * CW_USEDEFAULT is valid only for overlapped windows; if it is 1431 * specified for a pop-up or child window, the x and y parameters 1432 * are set to zero. 1433 * 1434 * @param y 1435 * [in] Type: int 1436 * 1437 * The initial vertical position of the window. For an overlapped 1438 * or pop-up window, the y parameter is the initial y-coordinate 1439 * of the window's upper-left corner, in screen coordinates. For 1440 * a child window, y is the initial y-coordinate of the 1441 * upper-left corner of the child window relative to the 1442 * upper-left corner of the parent window's client area. For a 1443 * list box y is the initial y-coordinate of the upper-left 1444 * corner of the list box's client area relative to the 1445 * upper-left corner of the parent window's client area. 1446 * 1447 * If an overlapped window is created with the WS_VISIBLE style 1448 * bit set and the x parameter is set to CW_USEDEFAULT, then the 1449 * y parameter determines how the window is shown. If the y 1450 * parameter is CW_USEDEFAULT, then the window manager calls 1451 * ShowWindow with the SW_SHOW flag after the window has been 1452 * created. If the y parameter is some other value, then the 1453 * window manager calls ShowWindow with that value as the 1454 * nCmdShow parameter. 1455 * 1456 * @param nWidth 1457 * [in] Type: int 1458 * 1459 * The width, in device units, of the window. For overlapped 1460 * windows, nWidth is the window's width, in screen coordinates, 1461 * or CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, the system 1462 * selects a default width and height for the window; the default 1463 * width extends from the initial x-coordinates to the right edge 1464 * of the screen; the default height extends from the initial 1465 * y-coordinate to the top of the icon area. CW_USEDEFAULT is 1466 * valid only for overlapped windows; if CW_USEDEFAULT is 1467 * specified for a pop-up or child window, the nWidth and nHeight 1468 * parameter are set to zero. 1469 * 1470 * @param nHeight 1471 * [in] Type: int 1472 * 1473 * The height, in device units, of the window. For overlapped 1474 * windows, nHeight is the window's height, in screen 1475 * coordinates. If the nWidth parameter is set to CW_USEDEFAULT, 1476 * the system ignores nHeight. 1477 * 1478 * @param hWndParent 1479 * [in, optional] Type: HWND 1480 * 1481 * A handle to the parent or owner window of the window being 1482 * created. To create a child window or an owned window, supply a 1483 * valid window handle. This parameter is optional for pop-up 1484 * windows. 1485 * 1486 * To create a message-only window, supply HWND_MESSAGE or a 1487 * handle to an existing message-only window. 1488 * 1489 * @param hMenu 1490 * [in, optional] Type: HMENU 1491 * 1492 * A handle to a menu, or specifies a child-window identifier, 1493 * depending on the window style. For an overlapped or pop-up 1494 * window, hMenu identifies the menu to be used with the window; 1495 * it can be NULL if the class menu is to be used. For a child 1496 * window, hMenu specifies the child-window identifier, an 1497 * integer value used by a dialog box control to notify its 1498 * parent about events. The application determines the 1499 * child-window identifier; it must be unique for all child 1500 * windows with the same parent window. 1501 * 1502 * @param hInstance 1503 * [in, optional] Type: HINSTANCE 1504 * 1505 * A handle to the instance of the module to be associated with 1506 * the window. 1507 * 1508 * @param lpParam 1509 * [in, optional] Type: LPVOID 1510 * 1511 * Pointer to a value to be passed to the window through the 1512 * CREATESTRUCT structure (lpCreateParams member) pointed to by 1513 * the lParam param of the WM_CREATE message. This message is 1514 * sent to the created window by this function before it returns. 1515 * 1516 * If an application calls CreateWindow to create a MDI client 1517 * window, lpParam should point to a CLIENTCREATESTRUCT 1518 * structure. If an MDI client window calls CreateWindow to 1519 * create an MDI child window, lpParam should point to a 1520 * MDICREATESTRUCT structure. lpParam may be NULL if no 1521 * additional data is needed. 1522 * 1523 * @return Type: HWND 1524 * 1525 * If the function succeeds, the return value is a handle to the new 1526 * window. 1527 * 1528 * If the function fails, the return value is NULL. To get extended 1529 * error information, call GetLastError. 1530 * 1531 * <p>This function typically fails for one of the following reasons:</p> 1532 * <ul> 1533 * <li>an invalid parameter value</li> 1534 * <li>the system class was registered by a different module</li> 1535 * <li>The WH_CBT hook is installed and returns a failure code</li> 1536 * <li>if one of the controls in the dialog template is not registered, 1537 * or its window window procedure fails WM_CREATE or 1538 * WM_NCCREATE</li> 1539 * </ul> 1540 */ CreateWindowEx(int dwExStyle, String lpClassName, String lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)1541 HWND CreateWindowEx(int dwExStyle, String lpClassName, 1542 String lpWindowName, int dwStyle, int x, int y, int nWidth, 1543 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, 1544 LPVOID lpParam); 1545 1546 /** 1547 * Destroys the specified window. The function sends WM_DESTROY and 1548 * WM_NCDESTROY messages to the window to deactivate it and remove the 1549 * keyboard focus from it. The function also destroys the window's menu, 1550 * flushes the thread message queue, destroys timers, removes clipboard 1551 * ownership, and breaks the clipboard viewer chain (if the window is at the 1552 * top of the viewer chain). 1553 * 1554 * If the specified window is a parent or owner window, DestroyWindow 1555 * automatically destroys the associated child or owned windows when it 1556 * destroys the parent or owner window. The function first destroys child or 1557 * owned windows, and then it destroys the parent or owner window. 1558 * 1559 * DestroyWindow also destroys modeless dialog boxes created by the 1560 * CreateDialog function. 1561 * 1562 * @param hWnd 1563 * [in] Type: HWND A handle to the window to be destroyed. 1564 * 1565 * @return Type: BOOL If the function succeeds, the return value is nonzero. 1566 * 1567 * If the function fails, the return value is zero. To get extended 1568 * error information, call {@link Kernel32#GetLastError}. 1569 */ DestroyWindow(HWND hWnd)1570 boolean DestroyWindow(HWND hWnd); 1571 1572 /** 1573 * Retrieves information about a window class, including a handle to the 1574 * small icon associated with the window class. The GetClassInfo function 1575 * does not retrieve a handle to the small icon. 1576 * 1577 * @param hinst 1578 * [in, optional] Type: HINSTANCE 1579 * 1580 * A handle to the instance of the application that created the 1581 * class. To retrieve information about classes defined by the 1582 * system (such as buttons or list boxes), set this parameter to 1583 * NULL. 1584 * 1585 * @param lpszClass 1586 * [in] Type: LPCTSTR 1587 * 1588 * The class name. The name must be that of a preregistered class 1589 * or a class registered by a previous call to the RegisterClass 1590 * or RegisterClassEx function. Alternatively, this parameter can 1591 * be a class atom created by a previous call to RegisterClass or 1592 * RegisterClassEx. The atom must be in the low-order word of 1593 * lpszClass; the high-order word must be zero. 1594 * 1595 * @param lpwcx 1596 * [out] Type: LPWNDCLASSEX 1597 * 1598 * A pointer to a WNDCLASSEX structure that receives the 1599 * information about the class. 1600 * 1601 * @return Type: BOOL If the function finds a matching class and 1602 * successfully copies the data, the return value is nonzero. 1603 * 1604 * If the function fails, the return value is zero. To get extended 1605 * error information, call {@link Kernel32#GetLastError} . 1606 */ GetClassInfoEx(HINSTANCE hinst, String lpszClass, WNDCLASSEX lpwcx)1607 boolean GetClassInfoEx(HINSTANCE hinst, String lpszClass, WNDCLASSEX lpwcx); 1608 1609 /** 1610 * Passes message information to the specified window procedure. 1611 * 1612 * @param lpPrevWndFunc 1613 * The previous window procedure. If this value is obtained by calling 1614 * the GetWindowLong function with the nIndex parameter set to GWL_WNDPROC 1615 * or DWL_DLGPROC, it is actually either the address of a window or dialog 1616 * box procedure, or a special internal value meaningful only to 1617 * CallWindowProc. 1618 * 1619 * @param hWnd 1620 * A handle to the window procedure to receive the message. 1621 * 1622 * @param Msg 1623 * The message. 1624 * 1625 * @param wParam 1626 * Additional message information. The content of this parameter 1627 * depends on the value of the Msg parameter. 1628 * 1629 * @param lParam 1630 * Additional message information. The content of this parameter 1631 * depends on the value of the Msg parameter. 1632 * 1633 * @return The return value is the result of the message processing and depends on 1634 * the message. 1635 * <p> 1636 * If the function fails, the return value is zero. To get extended 1637 * error information, call {@link Kernel32#GetLastError}. 1638 */ CallWindowProc(Pointer lpPrevWndFunc, HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam)1639 LRESULT CallWindowProc(Pointer lpPrevWndFunc, HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam); 1640 1641 /** 1642 * Calls the default window procedure to provide default processing for any 1643 * window messages that an application does not process. This function 1644 * ensures that every message is processed. DefWindowProc is called with the 1645 * same parameters received by the window procedure. 1646 * 1647 * @param hWnd 1648 * [in] Type: HWND 1649 * 1650 * A handle to the window procedure that received the message. 1651 * 1652 * @param Msg 1653 * [in] Type: UINT 1654 * 1655 * The message. 1656 * 1657 * @param wParam 1658 * [in] Type: WPARAM 1659 * 1660 * Additional message information. The content of this parameter 1661 * depends on the value of the Msg parameter. 1662 * 1663 * @param lParam 1664 * [in] Type: LPARAM 1665 * 1666 * Additional message information. The content of this parameter 1667 * depends on the value of the Msg parameter. 1668 * 1669 * @return Type: LRESULT The return value is the result of the message 1670 * processing and depends on the message. 1671 * 1672 * If the function fails, the return value is zero. To get extended 1673 * error information, call {@link Kernel32#GetLastError}. 1674 */ DefWindowProc(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam)1675 LRESULT DefWindowProc(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam); 1676 1677 /** 1678 * Registers the device or type of device for which a window will receive 1679 * notifications. 1680 * 1681 * @param hRecipient [in] A handle to the window or service that will receive 1682 * device events for the devices specified in the 1683 * NotificationFilter parameter. The same window handle can be 1684 * used in multiple calls to RegisterDeviceNotification. 1685 * 1686 * Services can specify either a window handle or service status 1687 * handle. 1688 * 1689 * @param notificationFilter 1690 * [in] A pointer to a block of data that specifies the type of 1691 * device for which notifications should be sent. This block 1692 * always begins with the DEV_BROADCAST_HDR structure. The data 1693 * following this header is dependent on the value of the 1694 * dbch_devicetype member, which can be 1695 * DBT_DEVTYP_DEVICEINTERFACE or DBT_DEVTYP_HANDLE. For more 1696 * information, see Remarks. 1697 * 1698 * @param Flags 1699 * [in] This parameter can be one of the following values. 1700 * DEVICE_NOTIFY_WINDOW_HANDLE0x00000000 The hRecipient parameter 1701 * is a window handle. 1702 * 1703 * DEVICE_NOTIFY_SERVICE_HANDLE0x00000001 The hRecipient 1704 * parameter is a service status handle. 1705 * 1706 * In addition, you can specify the following value. 1707 * 1708 * DEVICE_NOTIFY_ALL_INTERFACE_CLASSES0x00000004 Notifies the 1709 * recipient of device interface events for all device interface 1710 * classes. (The dbcc_classguid member is ignored.) 1711 * 1712 * This value can be used only if the dbch_devicetype member is 1713 * DBT_DEVTYP_DEVICEINTERFACE. 1714 * 1715 * @return value 1716 * 1717 * If the function succeeds, the return value is a device 1718 * notification handle. 1719 * 1720 * If the function fails, the return value is NULL. To get extended 1721 * error information, call GetLastError. 1722 */ RegisterDeviceNotification(HANDLE hRecipient, Structure notificationFilter, int Flags)1723 HDEVNOTIFY RegisterDeviceNotification(HANDLE hRecipient, Structure notificationFilter, int Flags); 1724 1725 /** 1726 * Closes the specified device notification handle. 1727 * 1728 * @param Handle [in] Device notification handle returned by the 1729 * RegisterDeviceNotification function. 1730 * 1731 * @return Return value 1732 * 1733 * If the function succeeds, the return value is nonzero. 1734 * 1735 * If the function fails, the return value is zero. To get extended 1736 * error information, call GetLastError. 1737 */ UnregisterDeviceNotification(HDEVNOTIFY Handle)1738 boolean UnregisterDeviceNotification(HDEVNOTIFY Handle); 1739 1740 /** 1741 * Defines a new window message that is guaranteed to be unique throughout the system. 1742 * The message value can be used when sending or posting messages. 1743 * 1744 * @param string 1745 * The message to be registered. 1746 * 1747 * @return If the message is successfully registered, the return value is a message identifier in the range 0xC000 through 0xFFFF. 1748 * <p> 1749 * If the function fails, the return value is zero. To get extended error information, call GetLastError. 1750 * </p> 1751 */ RegisterWindowMessage(String string)1752 int RegisterWindowMessage(String string); 1753 1754 /** 1755 * Retrieves a handle to the display monitor that contains a specified point. 1756 * @param pt A POINT structure that specifies the point of interest in virtual-screen 1757 * coordinates. 1758 * @param dwFlags Determines the function's return value if the window does not intersect 1759 * any display monitor. This parameter can be one of the following values. 1760 * <ul><li>MONITOR_DEFAULTTONEAREST</li> 1761 * <li>MONITOR_DEFAULTTONULL</li> 1762 * <li>MONITOR_DEFAULTTOPRIMARY</li></ul> 1763 * @return If the point is contained by a display monitor, the return value is an HMONITOR 1764 * handle to that display monitor. If the point is not contained by a display monitor, 1765 * the return value depends on the value of dwFlags. 1766 */ MonitorFromPoint(POINT.ByValue pt, int dwFlags)1767 HMONITOR MonitorFromPoint(POINT.ByValue pt, int dwFlags); 1768 1769 /** 1770 * Retrieves a handle to the display monitor that has the largest area of intersection with 1771 * a specified rectangle. 1772 * @param lprc A pointer to a RECT structure that specifies the rectangle of interest in 1773 * virtual-screen coordinates. 1774 * @param dwFlags Determines the function's return value if the window does not intersect 1775 * any display monitor. This parameter can be one of the following values. 1776 * <ul><li>MONITOR_DEFAULTTONEAREST</li> 1777 * <li>MONITOR_DEFAULTTONULL</li> 1778 * <li>MONITOR_DEFAULTTOPRIMARY</li></ul> 1779 * @return If the rectangle intersects one or more display monitor rectangles, the return 1780 * value is an HMONITOR handle to the display monitor that has the largest area of 1781 * intersection with the rectangle. If the rectangle does not intersect a display 1782 * monitor, the return value depends on the value of dwFlags. 1783 */ MonitorFromRect(RECT lprc, int dwFlags)1784 HMONITOR MonitorFromRect(RECT lprc, int dwFlags); 1785 1786 /** 1787 * Retrieves a handle to the display monitor that has the largest area of intersection with 1788 * the bounding rectangle of a specified window. 1789 * <p> 1790 * If the window is currently minimized, MonitorFromWindow uses the rectangle of the window 1791 * before it was minimized.</p> 1792 * @param hwnd A handle to the window of interest. 1793 * @param dwFlags Determines the function's return value if the window does not intersect 1794 * any display monitor. This parameter can be one of the following values. 1795 * <ul><li>MONITOR_DEFAULTTONEAREST</li> 1796 * <li>MONITOR_DEFAULTTONULL</li> 1797 * <li>MONITOR_DEFAULTTOPRIMARY</li></ul> 1798 * @return If the window intersects one or more display monitor rectangles, the return value 1799 * is an HMONITOR handle to the display monitor that has the largest area of 1800 * intersection with the window. If the window does not intersect a display monitor, 1801 * the return value depends on the value of dwFlags. 1802 */ MonitorFromWindow(HWND hwnd, int dwFlags)1803 HMONITOR MonitorFromWindow(HWND hwnd, int dwFlags); 1804 1805 /** 1806 * Retrieves information about a display monitor. 1807 * @param hMonitor A handle to the display monitor of interest. 1808 * @param lpmi A pointer to a {@link WinUser.MONITORINFO} structure that receives information about 1809 * the specified display monitor. 1810 * @return If the function succeeds, the return value is nonzero. If the function 1811 * fails, the return value is zero. 1812 */ GetMonitorInfo(HMONITOR hMonitor, MONITORINFO lpmi)1813 BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFO lpmi); 1814 1815 /** 1816 * Retrieves information about a display monitor. 1817 * @param hMonitor A handle to the display monitor of interest. 1818 * @param lpmi A pointer to a {@link WinUser.MONITORINFOEX} structure that receives information about 1819 * the specified display monitor. 1820 * @return If the function succeeds, the return value is nonzero. If the function 1821 * fails, the return value is zero. 1822 */ GetMonitorInfo(HMONITOR hMonitor, MONITORINFOEX lpmi)1823 BOOL GetMonitorInfo(HMONITOR hMonitor, MONITORINFOEX lpmi); 1824 1825 /** 1826 * Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) 1827 * that intersect a region formed by the intersection of a specified clipping rectangle and the visible 1828 * region of a device context. EnumDisplayMonitors calls an application-defined MonitorEnumProc callback 1829 * function once for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts 1830 * only the display monitors. 1831 * 1832 * @param hdc A handle to a display device context that defines the visible region of interest. If this 1833 * parameter is NULL, the hdcMonitor parameter passed to the callback function will be NULL, and 1834 * the visible region of interest is the virtual screen that encompasses all the displays on the 1835 * desktop. 1836 * @param lprcClip A pointer to a RECT structure that specifies a clipping rectangle. The region of 1837 * interest is the intersection of the clipping rectangle with the visible region specified by hdc. 1838 * If hdc is non-NULL, the coordinates of the clipping rectangle are relative to the origin of the 1839 * hdc. If hdc is NULL, the coordinates are virtual-screen coordinates. This parameter can be NULL 1840 * if you don't want to clip the region specified by hdc. 1841 * @param lpfnEnum A pointer to an application-defined callback function. 1842 * @param dwData Application-defined data that EnumDisplayMonitors passes directly to the lpfnEnum function. 1843 * @return If the function succeeds, the return value is nonzero. If the function fails, the return value 1844 * is zero. 1845 */ EnumDisplayMonitors(HDC hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData)1846 BOOL EnumDisplayMonitors(HDC hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData); 1847 1848 /** 1849 * Retrieves the show state and the restored, minimized, and maximized 1850 * positions of the specified window. 1851 * 1852 * @param hwnd A handle to the window. 1853 * @param lpwndpl A pointer to the WINDOWPLACEMENT structure that receives the 1854 * show state and position information. 1855 * @return The number of characters copied to the specified buffer indicates 1856 * success. Zero indicates failure. To get extended error 1857 * information, call GetLastError. 1858 */ GetWindowPlacement(HWND hwnd, WINDOWPLACEMENT lpwndpl)1859 BOOL GetWindowPlacement(HWND hwnd, WINDOWPLACEMENT lpwndpl); 1860 1861 /** 1862 * Sets the show state and the restored, minimized, and maximized positions 1863 * of the specified window. 1864 * 1865 * @param hwnd A handle to the window. 1866 * @param lpwndpl A pointer to a WINDOWPLACEMENT structure that specifies the 1867 * new show state and window positions. 1868 * @return The number of characters copied to the specified buffer indicates 1869 * success. Zero indicates failure. To get extended error 1870 * information, call GetLastError. 1871 */ SetWindowPlacement(HWND hwnd, WINDOWPLACEMENT lpwndpl)1872 BOOL SetWindowPlacement(HWND hwnd, WINDOWPLACEMENT lpwndpl); 1873 1874 /** 1875 * Calculates the required size of the window rectangle, based on the desired 1876 * client-rectangle size. The window rectangle can then be passed to the CreateWindow 1877 * function to create a window whose client area is the desired size. 1878 * 1879 * To specify an extended window style, use the AdjustWindowRectEx function. 1880 * 1881 * A client rectangle is the smallest rectangle that completely encloses a 1882 * client area. A window rectangle is the smallest rectangle that completely 1883 * encloses the window, which includes the client area and the nonclient area. 1884 * 1885 * The AdjustWindowRect function does not add extra space when a menu bar wraps 1886 * to two or more rows. 1887 * 1888 * The AdjustWindowRect function does not take the WS_VSCROLL or WS_HSCROLL 1889 * styles into account. To account for the scroll bars, call the GetSystemMetrics 1890 * function with SM_CXVSCROLL or SM_CYHSCROLL. 1891 * 1892 * @param lpRect A pointer to a RECT structure that contains the coordinates 1893 * of the top-left and bottom-right corners of the desired client area. 1894 * When the function returns, the structure contains the coordinates 1895 * of the top-left and bottom-right corners of the window to accommodate 1896 * the desired client area. 1897 * @param dwStyle The window style of the window whose required size is to be 1898 * calculated. Note that you cannot specify the WS_OVERLAPPED style. 1899 * @param bMenu Indicates whether the window has a menu. 1900 * @return The number of characters copied to the specified buffer indicates 1901 * success. Zero indicates failure. To get extended error 1902 * information, call GetLastError. 1903 */ AdjustWindowRect(RECT lpRect, DWORD dwStyle, BOOL bMenu)1904 BOOL AdjustWindowRect(RECT lpRect, DWORD dwStyle, BOOL bMenu); 1905 1906 /** 1907 * Calculates the required size of the window rectangle, based on the desired 1908 * client-rectangle size. The window rectangle can then be passed to the CreateWindowEx 1909 * function to create a window whose client area is the desired size. 1910 * 1911 * A client rectangle is the smallest rectangle that completely encloses a 1912 * client area. A window rectangle is the smallest rectangle that completely 1913 * encloses the window, which includes the client area and the nonclient area. 1914 * 1915 * The AdjustWindowRectEx function does not add extra space when a menu bar wraps 1916 * to two or more rows. 1917 * 1918 * The AdjustWindowRectEx function does not take the WS_VSCROLL or WS_HSCROLL 1919 * styles into account. To account for the scroll bars, call the GetSystemMetrics 1920 * function with SM_CXVSCROLL or SM_CYHSCROLL. 1921 * 1922 * @param lpRect A pointer to a RECT structure that contains the coordinates 1923 * of the top-left and bottom-right corners of the desired client area. 1924 * When the function returns, the structure contains the coordinates 1925 * of the top-left and bottom-right corners of the window to accommodate 1926 * the desired client area. 1927 * @param dwStyle The window style of the window whose required size is to be 1928 * calculated. Note that you cannot specify the WS_OVERLAPPED style. 1929 * @param bMenu Indicates whether the window has a menu. 1930 * @param dwExStyle The extended window style of the window whose required size 1931 * is to be calculated. 1932 * @return The number of characters copied to the specified buffer indicates 1933 * success. Zero indicates failure. To get extended error 1934 * information, call GetLastError. 1935 */ AdjustWindowRectEx(RECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)1936 BOOL AdjustWindowRectEx(RECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); 1937 1938 /** 1939 * Logs off the interactive user, shuts down the system, or shuts down and restarts 1940 * the system. It sends the WM_QUERYENDSESSION message to all applications to 1941 * determine if they can be terminated. 1942 * 1943 * When this function is called, the caller must specify whether or not applications 1944 * with unsaved changes should be forcibly closed. If the caller chooses not to force 1945 * these applications to close and an application with unsaved changes is running on 1946 * the console session, the shutdown will remain in progress until the user logged 1947 * into the console session aborts the shutdown, saves changes, closes the application, 1948 * or forces the application to close. During this period, the shutdown may not be 1949 * aborted except by the console user, and another shutdown may not be initiated. 1950 * 1951 * Calling this function with the value of the uFlags parameter set to EWX_FORCE avoids 1952 * this situation. Remember that doing this may result in loss of data. 1953 * 1954 * To set a shutdown priority for an application relative to other applications in the 1955 * system, use the SetProcessShutdownParameters function. 1956 * 1957 * During a shutdown or log-off operation, running applications are allowed a specific 1958 * amount of time to respond to the shutdown request. If this time expires before all 1959 * applications have stopped, the system displays a user interface that allows the user 1960 * to forcibly shut down the system or to cancel the shutdown request. If the EWX_FORCE 1961 * value is specified, the system forces running applications to stop when the time expires. 1962 * 1963 * If the EWX_FORCEIFHUNG value is specified, the system forces hung applications to close 1964 * and does not display the dialog box. 1965 * 1966 * Console processes receive a separate notification message, CTRL_SHUTDOWN_EVENT or 1967 * CTRL_LOGOFF_EVENT, as the situation warrants. A console process routes these messages 1968 * to its HandlerRoutine function. ExitWindowsEx sends these notification messages 1969 * asynchronously; thus, an application cannot assume that the console notification messages 1970 * have been handled when a call to ExitWindowsEx returns. 1971 * 1972 * To shut down or restart the system, the calling process must use the {@link com.sun.jna.platform.win32.Advapi32#AdjustTokenPrivileges} 1973 * function to enable the SE_SHUTDOWN_NAME privilege. For more information, see Running with Special Privileges. 1974 * 1975 * @param uFlags The shutdown type. This parameter must include one of EWX_HYBRID_SHUTDOWN, 1976 * EWX_LOGOFF, EWX_POWEROFF, EWX_REBOOT, EWX_RESTARTAPPS, or EWX_SHUTDOWN. This 1977 * parameter can optionally include one of EWX_FORCE or EWX_FORCEIFHUNG. 1978 * @param dReason The reason for initiating the shutdown. This parameter must be one 1979 * of the system shutdown reason codes. If this parameter is zero, the 1980 * SHTDN_REASON_FLAG_PLANNED reason code will not be set and therefore the 1981 * default action is an undefined shutdown that is logged as "No title for 1982 * this reason could be found". By default, it is also an unplanned shutdown. 1983 * Depending on how the system is configured, an unplanned shutdown triggers 1984 * the creation of a file that contains the system state information, which 1985 * can delay shutdown. Therefore, do not use zero for this parameter. 1986 * @return If the function succeeds, the return value is nonzero. Because the function 1987 * executes asynchronously, a nonzero return value indicates that the shutdown has been 1988 * initiated. It does not indicate whether the shutdown will succeed. It is possible 1989 * that the system, the user, or another application will abort the shutdown. If the 1990 * function fails, the return value is zero. To get extended error information, call GetLastError. 1991 */ ExitWindowsEx(UINT uFlags, DWORD dReason)1992 BOOL ExitWindowsEx(UINT uFlags, DWORD dReason); 1993 1994 /** 1995 * Locks the workstation's display. Locking a workstation protects it from unauthorized use. The 1996 * LockWorkStation function is callable only by processes running on the interactive desktop. 1997 * In addition, the user must be logged on, and the workstation cannot already be locked. 1998 * 1999 * @return If the function succeeds, the return value is nonzero. Because the function executes 2000 * asynchronously, a nonzero return value indicates that the operation has been initiated. 2001 * It does not indicate whether the workstation has been successfully locked. If the 2002 * function fails, the return value is zero. To get extended error information, call GetLastError. 2003 */ LockWorkStation()2004 BOOL LockWorkStation(); 2005 2006 /** 2007 * Retrieves information about the specified icon or cursor. 2008 * 2009 * @param hIcon 2010 * A handle to the icon or cursor. 2011 * <p> 2012 * To retrieve information about a standard icon or cursor, 2013 * specify one of the following values and use the 2014 * MAKEINTRESOURCE macro to create this value: 2015 * {@link WinUser#IDC_APPSTARTING} etc.</p> 2016 * @param piconinfo 2017 * A pointer to an ICONINFO structure. The function fills in the 2018 * structure's members. 2019 * @return If the function succeeds, the return value is {@code true} and 2020 * the function fills in the members of the specified ICONINFO 2021 * structure. 2022 * <p> 2023 * If the function fails, the return value is zero. To get extended 2024 * error information, call {@link Kernel32#GetLastError()}.</p> 2025 */ GetIconInfo(HICON hIcon, ICONINFO piconinfo)2026 boolean GetIconInfo(HICON hIcon, ICONINFO piconinfo); 2027 2028 /** 2029 * Sends the specified message to one or more windows. 2030 * 2031 * @param hWnd 2032 * A handle to the window whose window procedure will receive the 2033 * message. 2034 * <p> 2035 * If this parameter is HWND_BROADCAST ((HWND)0xffff), the 2036 * message is sent to all top-level windows in the system, 2037 * including disabled or invisible unowned windows. The function 2038 * does not return until each window has timed out. Therefore, 2039 * the total wait time can be up to the value of uTimeout 2040 * multiplied by the number of top-level windows.</p> 2041 * @param msg 2042 * The message to be sent. 2043 * @param wParam 2044 * Any additional message-specific information. 2045 * @param lParam 2046 * Any additional message-specific information. 2047 * @param fuFlags 2048 * The behavior of this function. This parameter can be one or 2049 * more of the following values: {@link WinUser#SMTO_ABORTIFHUNG} 2050 * etc. 2051 * @param uTimeout 2052 * The duration of the time-out period, in milliseconds. If the 2053 * message is a broadcast message, each window can use the full 2054 * time-out period. For example, if you specify a five second 2055 * time-out period and there are three top-level windows that 2056 * fail to process the message, you could have up to a 15 second 2057 * delay. 2058 * @param lpdwResult 2059 * The result of the message processing. The value of this 2060 * parameter depends on the message that is specified. 2061 * @return If the function succeeds, the return value is nonzero. 2062 * SendMessageTimeout does not provide information about individual 2063 * windows timing out if HWND_BROADCAST is used. 2064 * <p> 2065 * If the function fails or times out, the return value is 0. To get 2066 * extended error information, call GetLastError. If GetLastError 2067 * returns ERROR_TIMEOUT, then the function timed out. 2068 * </p> 2069 * Windows 2000: If {@link Kernel32#GetLastError()} returns 0, then 2070 * the function timed out. 2071 */ SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, int fuFlags, int uTimeout, DWORDByReference lpdwResult)2072 LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, 2073 int fuFlags, int uTimeout, DWORDByReference lpdwResult); 2074 2075 /** 2076 * Retrieves the specified value from the WNDCLASSEX structure associated 2077 * with the specified window. 2078 * 2079 * @param hWnd 2080 * A handle to the window and, indirectly, the class to which the 2081 * window belongs. 2082 * @param nIndex 2083 * The value to be retrieved. To retrieve a value from the extra 2084 * class memory, specify the positive, zero-based byte offset of 2085 * the value to be retrieved. Valid values are in the range zero 2086 * through the number of bytes of extra class memory, minus 2087 * eight; for example, if you specified 24 or more bytes of extra 2088 * class memory, a value of 16 would be an index to the third 2089 * integer.To retrieve any other value from the WNDCLASSEX 2090 * structure, specify one of the following values: 2091 * {@link WinUser#GCW_ATOM} etc. 2092 * @return If the function succeeds, the return value is the requested 2093 * value. 2094 * <p> 2095 * If the function fails, the return value is zero. To get extended 2096 * error information, call {@link Kernel32#GetLastError()}.</p> 2097 */ GetClassLongPtr(HWND hWnd, int nIndex)2098 ULONG_PTR GetClassLongPtr(HWND hWnd, int nIndex); 2099 2100 /** 2101 * @param pRawInputDeviceList 2102 * An array of {@link WinUser.RAWINPUTDEVICELIST} structures for the devices 2103 * attached to the system. If (@code null}, the number of devices is 2104 * returned in <tt>puiNumDevices</tt> 2105 * @param puiNumDevices 2106 * If <tt>pRawInputDeviceList</tt> is {@code null}, the function populates 2107 * this variable with the number of devices attached to the system; 2108 * otherwise, this variable specifies the number of {@link WinUser.RAWINPUTDEVICELIST} 2109 * structures that can be contained in the buffer to which <tt>pRawInputDeviceList</tt> 2110 * points. If this value is less than the number of devices attached to 2111 * the system, the function returns the actual number of devices in this 2112 * variable and fails with ERROR_INSUFFICIENT_BUFFER. 2113 * @param cbSize 2114 * The size of a {@link WinUser.RAWINPUTDEVICELIST} structure, in bytes. 2115 * @return If the function is successful, the return value is the number of devices 2116 * stored in the buffer pointed to by <tt>pRawInputDeviceList</tt>. On 2117 * any other error, the function returns -1 and {@code GetLastError} 2118 * returns the error indication. 2119 * @see WinUser.RAWINPUTDEVICELIST#sizeof() 2120 * @see <A HREF="https://msdn.microsoft.com/en-us/library/windows/desktop/ms645598(v=vs.85).aspx">GetRawInputDeviceList</A> 2121 */ GetRawInputDeviceList(RAWINPUTDEVICELIST[] pRawInputDeviceList, IntByReference puiNumDevices, int cbSize)2122 int GetRawInputDeviceList(RAWINPUTDEVICELIST[] pRawInputDeviceList, IntByReference puiNumDevices, int cbSize); 2123 2124 2125 /** 2126 * Retrieves a handle to the desktop window. The desktop window covers the 2127 * entire screen. The desktop window is the area on top of which other 2128 * windows are painted. 2129 * 2130 * @return Type: HWND The return value is a handle to the desktop window. 2131 */ GetDesktopWindow()2132 HWND GetDesktopWindow(); 2133 2134 /** 2135 * The PrintWindow function copies a visual window into the specified device 2136 * context (DC), typically a printer DC. 2137 * 2138 * @param hWnd 2139 * A handle to the window that will be copied. 2140 * @param dest 2141 * A handle to the destination device context. 2142 * @param flags 2143 * The drawing options. It can be one of the following values: 2144 * <br> 2145 * PW_CLIENTONLY:<br> 2146 * Only the client area of the window is copied to hdcBlt. By 2147 * default, the entire window is copied. 2148 * @return If the function succeeds, it returns true (MSDN: a nonzero 2149 * value). If the function fails, it returns false (MSDN: zero). 2150 */ PrintWindow(HWND hWnd, HDC dest, int flags)2151 boolean PrintWindow(HWND hWnd, HDC dest, int flags); 2152 2153 /** 2154 * Determines whether the specified window is enabled for mouse and keyboard 2155 * input. 2156 * 2157 * @param hWnd 2158 * A handle to the window to be tested. 2159 * @return If the window is enabled, the return value is true (nonzero).<br> 2160 * If the window is not enabled, the return value is false (zero). 2161 */ IsWindowEnabled(HWND hWnd)2162 boolean IsWindowEnabled(HWND hWnd); 2163 2164 /** 2165 * Determines whether the specified window handle identifies an existing 2166 * window. <br> 2167 * A thread should not use IsWindow for a window that it did not create 2168 * because the window could be destroyed after this function was called.<br> 2169 * Further, because window handles are recycled the handle could even point 2170 * to a different window. 2171 * 2172 * @param hWnd 2173 * A handle to the window to be tested. 2174 * @return If the window handle identifies an existing window, the return 2175 * value is true (nonzero).<br> 2176 * If the window handle does not identify an existing window, the 2177 * return value is false (zero). 2178 */ IsWindow(HWND hWnd)2179 boolean IsWindow(HWND hWnd); 2180 2181 /** 2182 * @param parent 2183 * Type: <strong>HWND</strong><br> 2184 * A handle to the parent window whose child windows are to be 2185 * searched.<br> 2186 * If <em>hwndParent</em> is <strong>NULL</strong>, the function 2187 * uses the desktop window as the parent window. The function 2188 * searches among windows that are child windows of the desktop. 2189 * <br> 2190 * If <em>hwndParent</em> is <strong>HWND_MESSAGE</strong>, the 2191 * function searches all <a href= 2192 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms632599(v=vs.85).aspx#message_only"> 2193 * message-only windows</a>.<br> 2194 * @param child 2195 * Type: <strong>HWND</strong><br> 2196 * A handle to a child window. The search begins with the next 2197 * child window in the Z order. The child window must be a direct 2198 * child window of <em>hwndParent</em>, not just a descendant 2199 * window.<br> 2200 * If <em>hwndChildAfter</em> is <strong>NULL</strong>, the 2201 * search begins with the first child window of 2202 * <em>hwndParent</em>.<br> 2203 * Note that if both <em>hwndParent</em> and 2204 * <em>hwndChildAfter</em> are <strong>NULL</strong>, the 2205 * function searches all top-level and message-only windows.<br> 2206 * @param className 2207 * Type: <strong>LPCTSTR</strong><br> 2208 * The class name or a class atom created by a previous call to 2209 * the <a href= 2210 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms633586(v=vs.85).aspx"> 2211 * <strong xmlns="http://www.w3.org/1999/xhtml">RegisterClass 2212 * </strong></a> or <a href= 2213 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms633587(v=vs.85).aspx"> 2214 * <strong xmlns="http://www.w3.org/1999/xhtml">RegisterClassEx 2215 * </strong></a> function. The atom must be placed in the 2216 * low-order word of <em>lpszClass</em>; the high-order word must 2217 * be zero.<br> 2218 * If <em>lpszClass</em> is a string, it specifies the window 2219 * class name. The class name can be any name registered with 2220 * <a href= 2221 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms633586(v=vs.85).aspx"> 2222 * <strong xmlns="http://www.w3.org/1999/xhtml">RegisterClass 2223 * </strong></a> or <a href= 2224 * "https://msdn.microsoft.com/en-us/library/windows/desktop/ms633587(v=vs.85).aspx"> 2225 * <strong xmlns="http://www.w3.org/1999/xhtml">RegisterClassEx 2226 * </strong></a>, or any of the predefined control-class names, 2227 * or it can be <code>MAKEINTATOM(0x8000)</code>. In this latter 2228 * case, 0x8000 is the atom for a menu class. For more 2229 * information, see the Remarks section of this topic.<br> 2230 * @param window 2231 * Type: <strong>LPCTSTR</strong><br> 2232 * The window name (the window's title). If this parameter is 2233 * <strong>NULL</strong>, all window names match. 2234 * @return If the function succeeds, the return value is a handle to the 2235 * window that has the specified class and window names. <br> 2236 * If the function fails, the return value is NULL. To get extended 2237 * error information, call GetLastError. 2238 */ FindWindowEx(HWND parent, HWND child, String className, String window)2239 HWND FindWindowEx(HWND parent, HWND child, String className, String window); 2240 2241 /** 2242 * Retrieves the handle to the ancestor of the specified window. 2243 * 2244 * @param hwnd 2245 * A handle to the window whose ancestor is to be retrieved. If 2246 * this parameter is the desktop window, the function returns 2247 * NULL. 2248 * @param gaFlags 2249 * The ancestor to be retrieved. This parameter can be one of the 2250 * following values:<br> 2251 * <ul> 2252 * <li>GA_PARENT (1) -- Retrieves the parent window. This does 2253 * not include the owner, as it does with the GetParent function. 2254 * </li> 2255 * <li>GA_ROOT (2) -- Retrieves the root window by walking the 2256 * chain of parent windows..</li> 2257 * <li>GA_ROOTOWNER (3) -- Retrieves the owned root window by 2258 * walking the chain of parent and owner windows returned by 2259 * GetParent..</li> 2260 * </ul> 2261 * @return The return value is the handle to the ancestor window. 2262 */ GetAncestor(HWND hwnd, int gaFlags)2263 HWND GetAncestor(HWND hwnd, int gaFlags); 2264 2265 /** 2266 * Retrieves the position of the mouse cursor, in screen coordinates. 2267 * 2268 * @param p 2269 * lpPoint [out]<br> 2270 * Type: LPPOINT<br> 2271 * A pointer to a POINT structure that receives the screen 2272 * coordinates of the cursor. 2273 * @return Type: BOOL.<br> 2274 * Returns nonzero if successful or zero otherwise. To get extended 2275 * error information, call GetLastError. 2276 */ GetCursorPos(POINT p)2277 boolean GetCursorPos(POINT p); 2278 2279 /** 2280 * Moves the cursor to the specified screen coordinates.<br> 2281 * If the new coordinates are not within the screen rectangle set by the 2282 * most recent ClipCursor function call, the system automatically adjusts 2283 * the coordinates so that the cursor stays within the rectangle. 2284 * 2285 * @param x 2286 * The new x-coordinate of the cursor, in screen coordinates. 2287 * @param y 2288 * The new y-coordinate of the cursor, in screen coordinates. 2289 * @return Type: BOOL.<br> 2290 * Returns nonzero if successful or zero otherwise. To get extended 2291 * error information, call GetLastError. 2292 */ SetCursorPos(long x, long y)2293 boolean SetCursorPos(long x, long y); 2294 2295 /** 2296 * @param eventMin 2297 * Type: UINT<br> 2298 * Specifies the event constant for the lowest event value in the 2299 * range of events that are handled by the hook function.<br> 2300 * This parameter can be set to EVENT_MIN to indicate the lowest 2301 * possible event value. 2302 * @param eventMax 2303 * Type: UINT<br> 2304 * Specifies the event constant for the highest event value in 2305 * the range of events that are handled by the hook function.<br> 2306 * This parameter can be set to EVENT_MAX to indicate the highest 2307 * possible event value. 2308 * @param hmodWinEventProc 2309 * Type: HMODULE<br> 2310 * Handle to the DLL that contains the hook function at 2311 * lpfnWinEventProc, if the WINEVENT_INCONTEXT flag is specified 2312 * in the dwFlags parameter.<br> 2313 * If the hook function is not located in a DLL, or if the 2314 * WINEVENT_OUTOFCONTEXT flag is specified, this parameter is 2315 * NULL. 2316 * @param winEventProc 2317 * Type: WINEVENTPROC<br> 2318 * Pointer to the event hook function. For more information about 2319 * this function, see WinEventProc. 2320 * @param processID 2321 * Type: DWORD<br> 2322 * Specifies the ID of the process from which the hook function 2323 * receives events.<br> 2324 * Specify zero (0) to receive events from all processes on the 2325 * current desktop. 2326 * @param threadID 2327 * Type: DWORD<br> 2328 * Specifies the ID of the thread from which the hook function 2329 * receives events.<br> 2330 * If this parameter is zero, the hook function is associated 2331 * with all existing threads on the current desktop. 2332 * @param flags 2333 * Type: UINT<br> 2334 * Flag values that specify the location of the hook function and 2335 * of the events to be skipped.<br> 2336 * The following flags are valid:<br> 2337 * <ul> 2338 * <li><b> WINEVENT_INCONTEXT:</b> The DLL that contains the 2339 * callback function is mapped into the address space of the 2340 * process that generates the event.<br> 2341 * With this flag, the system sends event notifications to the 2342 * callback function as they occur.<br> 2343 * The hook function must be in a DLL when this flag is 2344 * specified. <br> 2345 * This flag has no effect when both the calling process and the 2346 * generating process are not 32-bit or 64-bit processes, or when 2347 * the generating process is a console application.<br> 2348 * For more information, see In-Context Hook Functions.</li> 2349 * <li><b>WINEVENT_OUTOFCONTEXT:</b> The callback function is not 2350 * mapped into the address space of the process that generates 2351 * the event.<br> 2352 * Because the hook function is called across process boundaries, 2353 * the system must queue events.<br> 2354 * Although this method is asynchronous, events are guaranteed to 2355 * be in sequential order. <br> 2356 * For more information, see Out-of-Context Hook Functions.</li> 2357 * <li><b>WINEVENT_SKIPOWNPROCESS:</b><br> 2358 * Prevents this instance of the hook from receiving the events 2359 * that are generated by threads in this process. <br> 2360 * This flag does not prevent threads from generating events. 2361 * </li> 2362 * <li><b>WINEVENT_SKIPOWNTHREAD:</b><br> 2363 * Prevents this instance of the hook from receiving the events 2364 * that are generated by the thread that is registering this 2365 * hook.</li> 2366 * </ul> 2367 * @return Type: HWINEVENTHOOK<br> 2368 * If successful, returns an HWINEVENTHOOK value that identifies 2369 * this event hook instance. Applications save this return value to 2370 * use it with the UnhookWinEvent function.<br> 2371 * If unsuccessful, returns zero.<br> 2372 */ SetWinEventHook(int eventMin, int eventMax, HMODULE hmodWinEventProc, WinEventProc winEventProc, int processID, int threadID, int flags)2373 HANDLE SetWinEventHook(int eventMin, int eventMax, HMODULE hmodWinEventProc, WinEventProc winEventProc, 2374 int processID, int threadID, int flags); 2375 2376 /** 2377 * Removes an event hook function created by a previous call to 2378 * SetWinEventHook. 2379 * 2380 * @param hook 2381 * Type: HWINEVENTHOOK<br> 2382 * Handle to the event hook returned in the previous call to 2383 * SetWinEventHook. 2384 * @return Type: BOOL If successful, returns TRUE; otherwise, returns FALSE. 2385 * <br> 2386 * Three common errors cause this function to fail:<br> 2387 * The hWinEventHook parameter is NULL or not valid.<br> 2388 * The event hook specified by hWinEventHook was already removed. 2389 * <br> 2390 * UnhookWinEvent is called from a thread that is different from the 2391 * original call to SetWinEventHook.<br> 2392 */ UnhookWinEvent(HANDLE hook)2393 boolean UnhookWinEvent(HANDLE hook); 2394 2395 /** 2396 * Copies the specified icon from another module to the current module. 2397 * 2398 * @param hIcon 2399 * A handle to the icon to be copied. 2400 * @return If the function succeeds, the return value is a handle to the 2401 * duplicate icon. <br> 2402 * If the function fails, the return value is NULL. To get extended 2403 * error information, call GetLastError. 2404 * @see <a href="https://msdn.microsoft.com/en-us/library/ms648058(S.85).aspx">MSDN</a> 2405 */ CopyIcon(HICON hIcon)2406 HICON CopyIcon(HICON hIcon); 2407 2408 /** 2409 * Retrieves the specified 32-bit (DWORD) value from the WNDCLASSEX 2410 * structure associated with the specified window. Note If you are 2411 * retrieving a pointer or a handle, this function has been superseded by 2412 * the GetClassLongPtr function. <br> 2413 * (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit 2414 * Windows.) 2415 * 2416 * @param hWnd 2417 * A handle to the window and, indirectly, the class to which the 2418 * window belongs. 2419 * @param nIndex 2420 * The value to be retrieved. To retrieve a value from the extra 2421 * class memory, specify the positive, zero-based byte offset of 2422 * the value to be retrieved. Valid values are in the range zero 2423 * through the number of bytes of extra class memory, minus four; 2424 * for example, if you specified 12 or more bytes of extra class 2425 * memory, a value of 8 would be an index to the third integer. 2426 * To retrieve any other value from the WNDCLASSEX structure, 2427 * specify one of the following values.<br> GCW_ATOM: -32<br> 2428 * Retrieves an ATOM value that uniquely identifies the window 2429 * class. This is the same atom that the RegisterClassEx function 2430 * returns.<br> 2431 * GCL_CBCLSEXTRA: -20<br> 2432 * Retrieves the size, in bytes, of the extra memory associated 2433 * with the class.<br> 2434 * GCL_CBWNDEXTRA: -18<br> 2435 * Retrieves the size, in bytes, of the extra window memory 2436 * associated with each window in the class. For information on 2437 * how to access this memory, see GetWindowLong.<br> 2438 * GCL_HBRBACKGROUND: -10<br> 2439 * Retrieves a handle to the background brush associated with the 2440 * class.<br> 2441 * GCL_HCURSOR: -12<br> 2442 * Retrieves a handle to the cursor associated with the class. 2443 * <br> 2444 * GCL_HICON: -14<br> 2445 * Retrieves a handle to the icon associated with the class.<br> 2446 * GCL_HICONSM: -34<br> 2447 * Retrieves a handle to the small icon associated with the 2448 * class.<br> 2449 * GCL_HMODULE: -16<br> 2450 * Retrieves a handle to the module that registered the class. 2451 * <br> 2452 * GCL_MENUNAME: -8<br> 2453 * Retrieves the address of the menu name string. The string 2454 * identifies the menu resource associated with the class.<br> 2455 * GCL_STYLE: -26<br> 2456 * Retrieves the window-class style bits.<br> 2457 * GCL_WNDPROC: -24<br> 2458 * Retrieves the address of the window procedure, or a handle 2459 * representing the address of the window procedure. You must use 2460 * the CallWindowProc function to call the window procedure. 2461 * @return Type: DWORD If the function succeeds, the return value is the 2462 * requested value.<br> 2463 * If the function fails, the return value is zero. To get extended 2464 * error information, call GetLastError.<br> 2465 */ GetClassLong(HWND hWnd, int nIndex)2466 int GetClassLong(HWND hWnd, int nIndex); 2467 2468 /** 2469 * Registers a new clipboard format. This format can then be used as a 2470 * valid clipboard format. 2471 * 2472 * @param formatName The name of the new format. 2473 * 2474 * @return If the function succeeds, the return value identifies the 2475 * registered clipboard format. 2476 * 2477 * <p> If the function fails, the return value is zero. To get extended 2478 * error information, call GetLastError.</p> 2479 */ RegisterClipboardFormat(String formatName)2480 public int RegisterClipboardFormat(String formatName); 2481 2482 /** 2483 * Retrieves the window handle to the active window attached to the 2484 * calling thread's message queue. 2485 * 2486 * @return Type: HWND The return value is the handle to the active 2487 * window attached to the calling thread's message queue. Otherwise, 2488 * the return value is NULL. 2489 */ GetActiveWindow()2490 public HWND GetActiveWindow(); 2491 2492 /** 2493 * Sends the specified message to a window or windows. 2494 * The SendMessage function calls the window procedure for the specified window and 2495 * does not return until the window procedure has processed the message. 2496 * 2497 * To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. 2498 * To post a message to a thread's message queue and return immediately, 2499 * use the PostMessage or PostThreadMessage function. 2500 * 2501 * @param hWnd A handle to the window whose window procedure will receive the message. 2502 * If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all 2503 * top-level windows in the system, including disabled or invisible unowned windows, 2504 * overlapped windows, and pop-up windows; but the message is not sent to child windows. 2505 * Message sending is subject to UIPI. The thread of a process can send messages 2506 * only to message queues of threads in processes of lesser or equal integrity level. 2507 * 2508 * @param msg The message to be sent. 2509 * For lists of the system-provided messages, see System-Defined Messages. 2510 * @param wParam Additional message-specific information. 2511 * @param lParam Additional message-specific information. 2512 * 2513 * @return The return value specifies the result of the message processing; it depends on the message sent. 2514 * 2515 * Two classic usage : 2516 * - with a WM_USER+x msg value : wParam and lParam are numeric values 2517 * - with a WM_COPYDATA msg value : wParam is the length of the structure and lParam a pointer to a COPYDATASTRUCT 2518 */ SendMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam)2519 LRESULT SendMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam); 2520 2521 /** 2522 * Retrieves the input locale identifiers (formerly called keyboard layout 2523 * handles) corresponding to the current set of input locales in the system. The 2524 * function copies the identifiers to the specified buffer. 2525 * 2526 * @param nBuff The maximum number of handles that the buffer can hold. 2527 * @param lpList A pointer to the buffer that receives the array of input locale 2528 * identifiers. 2529 * @return If the function succeeds, the return value is the number of input 2530 * locale identifiers copied to the buffer or, if nBuff is zero, the 2531 * return value is the size, in array elements, of the buffer needed to 2532 * receive all current input locale identifiers. If the function fails, 2533 * the return value is zero. To get extended error information, call 2534 * GetLastError. 2535 */ GetKeyboardLayoutList(int nBuff, HKL[] lpList)2536 int GetKeyboardLayoutList(int nBuff, HKL[] lpList); 2537 2538 /** 2539 * Retrieves the active input locale identifier (formerly called the keyboard 2540 * layout). 2541 * 2542 * @param idThread The identifier of the thread to query, or 0 for the current 2543 * thread. 2544 * @return The return value is the input locale identifier for the thread. The 2545 * low word contains a Language Identifier for the input language and 2546 * the high word contains a device handle to the physical layout of the 2547 * keyboard. 2548 */ GetKeyboardLayout(int idThread)2549 HKL GetKeyboardLayout(int idThread); 2550 2551 /** 2552 * This function retrieves the name of the active keyboard layout. 2553 * 2554 * @param pwszKLID [in] Pointer to the buffer of at least {@link #KL_NAMELENGTH} 2555 * characters that is to receive the name of the keyboard 2556 * layout, including the terminating null character. 2557 * @return Nonzero indicates success. Zero indicates failure. To get extended 2558 * error information, call GetLastError. 2559 */ GetKeyboardLayoutName(char[] pwszKLID)2560 boolean GetKeyboardLayoutName(char[] pwszKLID); 2561 2562 /** 2563 * Translates a character to the corresponding virtual-key code and shift state. 2564 * The function translates the character using the input language and physical 2565 * keyboard layout identified by the input locale identifier. 2566 * 2567 * @param ch The character to be translated into a virtual-key code. 2568 * @param dwhkl Input locale identifier to use for translating the specified 2569 * code. This parameter can be any input locale identifier 2570 * previously returned by the #LoadKeyboardLayout() 2571 * function. 2572 * @return If the function succeeds, the low-order byte of the return value 2573 * contains the virtual-key code and the high-order byte contains the 2574 * shift state, which can be a combination of the following flag bits. 2575 * <dl> 2576 * <dt>1</dt> 2577 * <dd>Either SHIFT key is pressed. Use 2578 * {@link WinUser#MODIFIER_SHIFT_MASK}.</dd> 2579 * <dt>2</dt> 2580 * <dd>Either CTRL key is pressed. Use 2581 * {@link WinUser#MODIFIER_CTRL_MASK}.</dd> 2582 * <dt>4</dt> 2583 * <dd>Either ALT key is pressed. Use 2584 * {@link WinUser#MODIFIER_ALT_MASK}.</dd> 2585 * <dt>8</dt> 2586 * <dd>The Hankaku key is pressed. Use 2587 * {@link WinUser#MODIFIER_HANKAKU_MASK}.</dd> 2588 * <dt>16</dt> 2589 * <dd>Reserved (defined by the keyboard layout driver). Use 2590 * {@link WinUser#MODIFIER_RESERVED1_MASK}.</dd> 2591 * <dt>32</dt> 2592 * <dd>Reserved (defined by the keyboard layout driver). Use 2593 * {@link WinUser#MODIFIER_RESERVED2_MASK}.</dd> 2594 * </dl> 2595 * If the function finds no key that translates to the passed character 2596 * code, both the low-order and high-order bytes contain -1. 2597 */ VkKeyScanExA(byte ch, HKL dwhkl)2598 short VkKeyScanExA(byte ch, HKL dwhkl); 2599 2600 /** 2601 * Translates a character to the corresponding virtual-key code and shift state. 2602 * The function translates the character using the input language and physical 2603 * keyboard layout identified by the input locale identifier. 2604 * 2605 * @param ch The character to be translated into a virtual-key code. 2606 * @param dwhkl Input locale identifier to use for translating the specified 2607 * code. This parameter can be any input locale identifier 2608 * previously returned by the #LoadKeyboardLayout() 2609 * function. 2610 * @return If the function succeeds, the low-order byte of the return value 2611 * contains the virtual-key code and the high-order byte contains the 2612 * shift state, which can be a combination of the following flag bits. 2613 * <dl> 2614 * <dt>1</dt> 2615 * <dd>Either SHIFT key is pressed. Use 2616 * {@link WinUser#MODIFIER_SHIFT_MASK}.</dd> 2617 * <dt>2</dt> 2618 * <dd>Either CTRL key is pressed. Use 2619 * {@link WinUser#MODIFIER_CTRL_MASK}.</dd> 2620 * <dt>4</dt> 2621 * <dd>Either ALT key is pressed. Use 2622 * {@link WinUser#MODIFIER_ALT_MASK}.</dd> 2623 * <dt>8</dt> 2624 * <dd>The Hankaku key is pressed. Use 2625 * {@link WinUser#MODIFIER_HANKAKU_MASK}.</dd> 2626 * <dt>16</dt> 2627 * <dd>Reserved (defined by the keyboard layout driver). Use 2628 * {@link WinUser#MODIFIER_RESERVED1_MASK}.</dd> 2629 * <dt>32</dt> 2630 * <dd>Reserved (defined by the keyboard layout driver). Use 2631 * {@link WinUser#MODIFIER_RESERVED2_MASK}.</dd> 2632 * </dl> 2633 * If the function finds no key that translates to the passed character 2634 * code, both the low-order and high-order bytes contain -1. 2635 */ VkKeyScanExW(char ch, HKL dwhkl)2636 short VkKeyScanExW(char ch, HKL dwhkl); 2637 2638 /** 2639 * Translates (maps) a virtual-key code into a scan code or character value, or 2640 * translates a scan code into a virtual-key code. The function translates the 2641 * codes using the input language and an input locale identifier. 2642 * 2643 * @param uCode The virtual-key code or scan code for a key. How this value 2644 * is interpreted depends on the value of the uMapType 2645 * parameter. Starting with Windows Vista, the high byte of the 2646 * uCode value can contain either 0xe0 or 0xe1 to specify the 2647 * extended scan code. 2648 * @param uMapType The translation to perform. The value of this parameter 2649 * depends on the value of the uCode parameter. One of 2650 * {@link WinUser#MAPVK_VK_TO_CHAR}, 2651 * {@link WinUser#MAPVK_VK_TO_VSC}, 2652 * {@link WinUser#MAPVK_VK_TO_VSC_EX}, 2653 * {@link WinUser#MAPVK_VSC_TO_VK}, 2654 * {@link WinUser#MAPVK_VSC_TO_VK_EX} 2655 * 2656 * @param dwhkl Input locale identifier to use for translating the specified 2657 * code. This parameter can be any input locale identifier 2658 * previously returned by the #LoadKeyboardLayout() 2659 * function. 2660 * @return The return value is either a scan code, a virtual-key code, or a 2661 * character value, depending on the value of uCode and uMapType. If 2662 * there is no translation, the return value is zero. 2663 */ MapVirtualKeyEx(int uCode, int uMapType, HKL dwhkl)2664 int MapVirtualKeyEx(int uCode, int uMapType, HKL dwhkl); 2665 2666 /** 2667 * Translates the specified virtual-key code and keyboard state to the 2668 * corresponding Unicode character or characters. 2669 * 2670 * @param wVirtKey The virtual-key code to be translated. 2671 * @param wScanCode The hardware scan code of the key to be translated. The 2672 * high-order bit of this value is set if the key is up. 2673 * @param lpKeyState A pointer to a 256-byte array that contains the current 2674 * keyboard state. Each element (byte) in the array contains 2675 * the state of one key. If the high-order bit of a byte is 2676 * set, the key is down. 2677 * @param pwszBuff The buffer that receives the translated Unicode character 2678 * or characters. However, this buffer may be returned without 2679 * being null-terminated even though the variable name 2680 * suggests that it is null-terminated. 2681 * @param cchBuff The size, in characters, of the buffer pointed to by the 2682 * pwszBuff parameter. 2683 * @param wFlags The behavior of the function. If bit 0 is set, a menu is 2684 * active. If bit 2 is set, keyboard state is not changed 2685 * (Windows 10, version 1607 and newer) All other bits 2686 * (through 31) are reserved. 2687 * @param dwhkl Input locale identifier to use for translating the 2688 * specified code. This parameter can be any input locale 2689 * identifier previously returned by the 2690 * #LoadKeyboardLayout() function. 2691 * @return The function returns one of the following values. 2692 * <dl> 2693 * <dt>-1</dt> 2694 * <dd>The specified virtual key is a dead-key character (accent or 2695 * diacritic). This value is returned regardless of the keyboard layout, 2696 * even if several characters have been typed and are stored in the 2697 * keyboard state. If possible, even with Unicode keyboard layouts, the 2698 * function has written a spacing version of the dead-key character to 2699 * the buffer specified by pwszBuff. For example, the function writes 2700 * the character SPACING ACUTE (0x00B4), rather than the character 2701 * NON_SPACING ACUTE (0x0301).</dd> 2702 * <dt>0</dt> 2703 * <dd>The specified virtual key has no translation for the current 2704 * state of the keyboard. Nothing was written to the buffer specified by 2705 * pwszBuff.</dd> 2706 * <dt>1</dt> 2707 * <dd>One character was written to the buffer specified by 2708 * pwszBuff.</dd> 2709 * <dt>2≤value</dt> 2710 * <dd>Two or more characters were written to the buffer specified by 2711 * pwszBuff. The most common cause for this is that a dead-key character 2712 * (accent or diacritic) stored in the keyboard layout could not be 2713 * combined with the specified virtual key to form a single character. 2714 * However, the buffer may contain more characters than the return value 2715 * specifies. When this happens, any extra characters are invalid and 2716 * should be ignored.</dd> 2717 * </dl> 2718 * 2719 */ ToUnicodeEx(int wVirtKey, int wScanCode, byte[] lpKeyState, char[] pwszBuff, int cchBuff, int wFlags, HKL dwhkl)2720 int ToUnicodeEx(int wVirtKey, int wScanCode, byte[] lpKeyState, char[] pwszBuff, int cchBuff, int wFlags, 2721 HKL dwhkl); 2722 2723 /** 2724 * Loads a string resource from the executable file associated with a specified 2725 * module, copies the string into a buffer, and appends a terminating null 2726 * character. 2727 * 2728 * @param hInstance A handle to an instance of the module whose executable 2729 * file contains the string resource. To get the handle to 2730 * the application itself, call the GetModuleHandle function 2731 * with NULL. 2732 * @param uID The identifier of the string to be loaded. 2733 * @param lpBuffer The buffer is to receive the string. Must be of 2734 * sufficient length to hold a pointer (8 bytes). 2735 * @param cchBufferMax The size of the buffer, in characters. The string is 2736 * truncated and null-terminated if it is longer than the 2737 * number of characters specified. If this parameter is 0, 2738 * then lpBuffer receives a read-only pointer to the 2739 * resource itself. 2740 * @return If the function succeeds, the return value is the number of 2741 * characters copied into the buffer, not including the terminating null 2742 * character, or zero if the string resource does not exist. To get 2743 * extended error information, call GetLastError. 2744 * 2745 */ LoadString(HINSTANCE hInstance, int uID, Pointer lpBuffer, int cchBufferMax)2746 int LoadString(HINSTANCE hInstance, int uID, Pointer lpBuffer, int cchBufferMax); 2747 } 2748