/
User32.java
2715 lines (2596 loc) · 130 KB
/
User32.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, All Rights Reserved
*
* The contents of this file is dual-licensed under 2
* alternative Open Source/Free licenses: LGPL 2.1 or later and
* Apache License 2.0. (starting with JNA version 4.0.0).
*
* You can freely decide which license you want to apply to
* the project.
*
* You may obtain a copy of the LGPL License at:
*
* http://www.gnu.org/licenses/licenses.html
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "LGPL2.1".
*
* You may obtain a copy of the Apache License at:
*
* http://www.apache.org/licenses/
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "AL2.0".
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinGDI.ICONINFO;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Provides access to the w32 user32 library. Incomplete implementation to
* support demos.
*
* @author Todd Fast, todd.fast@sun.com
* @author twalljava@dev.java.net
* @author Tobias Wolf, wolf.tobias@gmx.net
* @author Markus KARG (markus[at]headcrashing[dot]eu)
* @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de
*/
public interface User32 extends StdCallLibrary, WinUser, WinNT {
/** The instance. */
User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS);
/**
* Handle for message-only window.
*/
HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3));
/** The cs globalclass. */
int CS_GLOBALCLASS = 0x4000;
/** The ws ex topmost. */
int WS_EX_TOPMOST = 0x00000008;
/** The hRecipient parameter is a window handle. */
int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000;
/** The hRecipient parameter is a service status handle. */
int DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001;
/** The device notify all interface classes. */
int DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x00000004;
/**
* <p>
* Sets the show state based on the SW_ value specified in the <a href=
* "https://msdn.microsoft.com/en-us/library/windows/desktop/ms686331(v=vs.85).aspx">
* <strong xmlns="http://www.w3.org/1999/xhtml">STARTUPINFO</strong></a>
* structure passed to the <a href=
* "https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx">
* <strong xmlns="http://www.w3.org/1999/xhtml">CreateProcess</strong></a>
* function by the program that started the application.
* </p>
*/
int SW_SHOWDEFAULT = 10;
/**
* This function retrieves a handle to a display device context (DC) for the
* client area of the specified window. The display device context can be
* used in subsequent graphics display interface (GDI) functions to draw in
* the client area of the window.
*
* @param hWnd
* Handle to the window whose device context is to be retrieved.
* If this value is NULL, GetDC retrieves the device context for
* the entire screen.
* @return The handle the device context for the specified window's client
* area indicates success. NULL indicates failure. To get extended
* error information, call GetLastError.
*/
HDC GetDC(HWND hWnd);
/**
* This function releases a device context (DC), freeing it for use by other
* applications. The effect of ReleaseDC depends on the type of device
* context.
*
* @param hWnd
* Handle to the window whose device context is to be released.
* @param hDC
* Handle to the device context to be released.
* @return The return value specifies whether the device context is
* released. 1 indicates that the device context is released. Zero
* indicates that the device context is not released.
*/
int ReleaseDC(HWND hWnd, HDC hDC);
/**
* This function retrieves the handle to the top-level window whose class
* name and window name match the specified strings. This function does not
* search child windows.
*
* @param lpClassName
* Long pointer to a null-terminated string that specifies the
* class name or is an atom that identifies the class-name
* string. If this parameter is an atom, it must be a global atom
* created by a previous call to the GlobalAddAtom function. The
* atom, a 16-bit value, must be placed in the low-order word of
* lpClassName; the high-order word must be zero.
* @param lpWindowName
* Long pointer to a null-terminated string that specifies the
* window name (the window's title). If this parameter is NULL,
* all window names match.
* @return A handle to the window that has the specified class name and
* window name indicates success. NULL indicates failure. To get
* extended error information, call GetLastError.
*/
HWND FindWindow(String lpClassName, String lpWindowName);
/**
* This function retrieves the name of the class to which the specified
* window belongs.
*
* @param hWnd
* Handle to the window and, indirectly, the class to which the
* window belongs.
* @param lpClassName
* Long pointer to the buffer that is to receive the class name
* string.
* @param nMaxCount
* Specifies the length, in characters, of the buffer pointed to
* by the lpClassName parameter. The class name string is
* truncated if it is longer than the buffer.
* @return The number of characters copied to the specified buffer indicates
* success. Zero indicates failure. To get extended error
* information, call GetLastError.
*/
int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount);
/**
* Retrieves information about the active window or a specified graphical
* user interface (GUI) thread.
*
* @param idThread
* Identifies the thread for which information is to be
* retrieved. To retrieve this value, use the
* GetWindowThreadProcessId function. If this parameter is NULL,
* the function returns information for the foreground thread.
* @param lpgui
* Pointer to a GUITHREADINFO structure that receives information
* describing the thread. Note that you must set
* GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling
* this function.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
/**
* The GetWindowInfo function retrieves information about the specified
* window.
*
* @param hWnd
* Handle to the window whose information is to be retrieved.
* @param pwi
* Pointer to a WINDOWINFO structure to receive the information.
* Note that you must set WINDOWINFO.cbSize to sizeof(WINDOWINFO)
* before calling this function.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero.
*/
boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi);
/**
* This function retrieves the dimensions of the bounding rectangle of the
* specified window. The dimensions are given in screen coordinates that are
* relative to the upper-left corner of the screen.
*
* @param hWnd
* Handle to the window.
* @param rect
* Long pointer to a RECT structure that receives the screen
* coordinates of the upper-left and lower-right corners of the
* window.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero.
*/
boolean GetWindowRect(HWND hWnd, RECT rect);
/**
* This function retrieves the coordinates of a window's client area.
* The client coordinates specify the upper-left and lower-right corners of the
* client area. Because client coordinates are relative to the upper-left
* corner of a window's client area, the coordinates of the upper-left corner
* are (0,0).
*
* @param hWnd
* Handle to the window.
* @param rect
* Long pointer to a RECT structure that structure that receives
* the client coordinates. The left and top members are zero. The
* right and bottom members contain the width and height of the
* window.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero.
*/
boolean GetClientRect(HWND hWnd, RECT rect);
/**
* This function copies the text of the specified window's title bar - if it
* has one - into a buffer. If the specified window is a control, the text
* of the control is copied.
*
* @param hWnd
* Handle to the window or control containing the text.
* @param lpString
* Long pointer to the buffer that will receive the text.
* @param nMaxCount
* Specifies the maximum number of characters to copy to the
* buffer, including the NULL character. If the text exceeds this
* limit, it is truncated.
* @return The length, in characters, of the copied string, not including
* the terminating null character, indicates success. Zero indicates
* that the window has no title bar or text, if the title bar is
* empty, or if the window or control handle is invalid. To get
* extended error information, call GetLastError. This function
* cannot retrieve the text of an edit control in another
* application.
*/
int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount);
/**
* This function retrieves the length, in characters, of the specified
* window's title bar text - if the window has a title bar. If the specified
* window is a control, the function retrieves the length of the text within
* the control.
*
* @param hWnd
* Handle to the window or control.
* @return The length, in characters, of the text indicates success. Under
* certain conditions, this value may actually be greater than the
* length of the text. Zero indicates that the window has no text.
* To get extended error information, call GetLastError.
*/
int GetWindowTextLength(HWND hWnd);
/**
* The GetWindowModuleFileName function retrieves the full path and file
* name of the module associated with the specified window handle.
*
* @param hWnd
* Handle to the window whose module file name will be retrieved.
* @param lpszFileName
* Pointer to a buffer that receives the path and file name.
* @param cchFileNameMax
* Specifies the maximum number of TCHARs that can be copied into
* the lpszFileName buffer.
* @return The return value is the total number of TCHARs copied into the
* buffer.
*/
int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, int cchFileNameMax);
/**
* This function retrieves the identifier of the thread that created the
* specified window and, optionally, the identifier of the process that
* created the window.
*
* @param hWnd
* Handle to the window.
* @param lpdwProcessId
* Pointer to a 32-bit value that receives the process
* identifier. If this parameter is not NULL,
* GetWindowThreadProcessId copies the identifier of the process
* to the 32-bit value; otherwise, it does not.
* @return The return value is the identifier of the thread that created the
* window.
*/
int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId);
/**
* This function enumerates all top-level windows on the screen by passing
* the handle to each window, in turn, to an application-defined callback
* function. EnumWindows continues until the last top-level window is
* enumerated or the callback function returns FALSE.
*
* @param lpEnumFunc
* Long pointer to an application-defined callback function.
* @param data
* Specifies an application-defined value to be passed to the
* callback function.
* @return Nonzero indicates success. Zero indicates failure. To get
* extended error information, call GetLastError.
*/
boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
/**
* The EnumChildWindows function enumerates the child windows that belong to
* the specified parent window by passing the handle to each child window,
* in turn, to an application-defined callback function. EnumChildWindows
* continues until the last child window is enumerated or the callback
* function returns FALSE.
*
* @param hWnd
* Handle to the parent window whose child windows are to be
* enumerated. If this parameter is NULL, this function is
* equivalent to EnumWindows.
* @param lpEnumFunc
* Pointer to an application-defined callback function.
* @param data
* Specifies an application-defined value to be passed to the
* callback function.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError. If EnumChildProc returns zero,
* the return value is also zero. In this case, the callback
* function should call SetLastError to obtain a meaningful error
* code to be returned to the caller of EnumChildWindows.
*/
boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);
/**
* The EnumThreadWindows function enumerates all nonchild windows associated
* with a thread by passing the handle to each window, in turn, to an
* application-defined callback function. EnumThreadWindows continues until
* the last window is enumerated or the callback function returns FALSE. To
* enumerate child windows of a particular window, use the EnumChildWindows
* function.
*
* @param dwThreadId
* Identifies the thread whose windows are to be enumerated.
* @param lpEnumFunc
* Pointer to an application-defined callback function.
* @param data
* Specifies an application-defined value to be passed to the
* callback function.
* @return If the callback function returns TRUE for all windows in the
* thread specified by dwThreadId, the return value is TRUE. If the
* callback function returns FALSE on any enumerated window, or if
* there are no windows found in the thread specified by dwThreadId,
* the return value is FALSE.
*/
boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data);
/**
* The FlashWindowEx function flashes the specified window. It does not
* change the active state of the window.
*
* @param pfwi
* Pointer to the FLASHWINFO structure.
* @return The return value specifies the window's state before the call to
* the FlashWindowEx function. If the window caption was drawn as
* active before the call, the return value is nonzero. Otherwise,
* the return value is zero.
*/
boolean FlashWindowEx(FLASHWINFO pfwi);
/**
* This function loads the specified icon resource from the executable
* (.exe) file associated with an application instance.
*
* @param hInstance
* Handle to an instance of the module whose executable file
* contains the icon to be loaded. This parameter must be NULL
* when a standard icon is being loaded.
* @param iconName
* Long pointer to a null-terminated string that contains the
* name of the icon resource to be loaded. Alternatively, this
* parameter can contain the resource identifier in the low-order
* word and zero in the high-order word. Use the MAKEINTRESOURCE
* macro to create this value.
* <p>
* To use one of the predefined icons, set the hInstance
* parameter to NULL and the lpIconName parameter to one of the
* following values: {@link WinUser#IDC_APPSTARTING} etc.</p>
* @return A handle to the newly loaded icon indicates success. NULL
* indicates failure. To get extended error information, call
* GetLastError.
*/
HICON LoadIcon(HINSTANCE hInstance, String iconName);
/**
* This function loads an icon, cursor, or bitmap.
*
* @param hinst
* Handle to an instance of the module that contains the image to
* be loaded.
* @param name
* Pointer to a null-terminated string that contains the name of
* the image resource in the hinst module that identifies the
* image to load.
* @param type
* Specifies the type of image to be loaded.
* @param xDesired
* Specifies the width, in pixels, of the icon or cursor. If this
* parameter is zero, the function uses the SM_CXICON or
* SM_CXCURSOR system metric value to set the width. If uType is
* IMAGE_BITMAP, this parameter must be zero.
* @param yDesired
* Specifies the height, in pixels, of the icon or cursor. If
* this parameter is zero, the function uses the SM_CYICON or
* SM_CYCURSOR system metric value to set the height. If uType is
* IMAGE_BITMAP, this parameter must be zero.
* @param load
* Set to zero.
* @return The handle of the newly loaded image indicates success. NULL
* indicates failure. To get extended error information, call
* GetLastError.
*/
HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired,
int yDesired, int load);
/**
* This function destroys an icon and frees any memory the icon occupied.
*
* @param hicon
* Handle to the icon to be destroyed. The icon must not be in
* use.
* @return Nonzero indicates success. Zero indicates failure. To get
* extended error information, call GetLastError.
*/
boolean DestroyIcon(HICON hicon);
/**
* This function retrieves information about the specified window.
* GetWindowLong also retrieves the 32-bit (long) value at the specified
* offset into the extra window memory of a window.
*
* @param hWnd
* Handle to the window and, indirectly, the class to which the
* window belongs.
* @param nIndex
* Specifies the zero-based offset to the value to be retrieved.
* @return The requested 32-bit value indicates success. Zero indicates
* failure. To get extended error information, call GetLastError.
*/
int GetWindowLong(HWND hWnd, int nIndex);
/**
* This function changes an attribute of the specified window. SetWindowLong
* also sets a 32-bit (LONG) value at the specified offset into the extra
* window memory of a window.
*
* @param hWnd
* Handle to the window and, indirectly, the class to which the
* window belongs.
* @param nIndex
* Specifies the zero-based offset to the value to be set.
* @param dwNewLong
* Specifies the replacement value.
* @return The previous value of the specified 32-bit integer indicates
* success. Zero indicates failure. To get extended error
* information, call GetLastError.
*/
int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
/**
* The GetWindowLongPtr function retrieves information about the specified
* window. The function also retrieves the value at a specified offset into
* the extra window memory.
*
* @param hWnd
* Handle to the window and, indirectly, the class to which the
* window belongs.
* @param nIndex
* Specifies the zero-based offset to the value to be retrieved.
* @return If the function succeeds, the return value is the requested
* value. If the function fails, the return value is zero. To get
* extended error information, call GetLastError. If SetWindowLong
* or SetWindowLongPtr has not been called previously,
* GetWindowLongPtr returns zero for values in the extra window or
* class memory.
*/
LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex);
/**
* The SetWindowLongPtr function changes an attribute of the specified
* window. The function also sets a value at the specified offset in the
* extra window memory.
*
* @param hWnd
* Handle to the window and, indirectly, the class to which the
* window belongs.
* @param nIndex
* Specifies the zero-based offset to the value to be set.
* @param dwNewLongPtr
* Specifies the replacement value.
* @return If the function succeeds, the return value is the previous value
* of the specified offset. If the function fails, the return value
* is zero. To get extended error information, call GetLastError. If
* the previous value is zero and the function succeeds, the return
* value is zero, but the function does not clear the last error
* information. To determine success or failure, clear the last
* error information by calling SetLastError(0), then call
* SetWindowLongPtr. Function failure will be indicated by a return
* value of zero and a GetLastError result that is nonzero.
*/
Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr);
/**
* The SetLayeredWindowAttributes function sets the opacity and transparency
* color key of a layered window.
*
* @param hwnd
* Handle to the layered window.
* @param crKey
* COLORREF structure that specifies the transparency color key
* to be used when composing the layered window.
* @param bAlpha
* Alpha value used to describe the opacity of the layered
* window.
* @param dwFlags
* Specifies an action to take.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha, int dwFlags);
/**
* The GetLayeredWindowAttributes function retrieves the opacity and
* transparency color key of a layered window.
*
* @param hwnd
* Handle to the layered window. A layered window is created by
* specifying WS_EX_LAYERED when creating the window with the
* CreateWindowEx function or by setting WS_EX_LAYERED via
* SetWindowLong after the window has been created.
* @param pcrKey
* Pointer to a COLORREF value that receives the transparency
* color key to be used when composing the layered window. All
* pixels painted by the window in this color will be
* transparent. This can be NULL if the argument is not needed.
* @param pbAlpha
* Pointer to a BYTE that receives the Alpha value used to
* describe the opacity of the layered window. Similar to the
* SourceConstantAlpha member of the BLENDFUNCTION structure.
* When the variable referred to by pbAlpha is 0, the window is
* completely transparent. When the variable referred to by
* pbAlpha is 255, the window is opaque. This can be NULL if the
* argument is not needed.
* @param pdwFlags
* Pointer to a DWORD that receives a layering flag. This can be
* NULL if the argument is not needed.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey,
ByteByReference pbAlpha, IntByReference pdwFlags);
/**
* The UpdateLayeredWindow function updates the position, size, shape,
* content, and translucency of a layered window.
*
* @param hwnd
* Handle to a layered window. A layered window is created by
* specifying WS_EX_LAYERED when creating the window with the
* CreateWindowEx function.
* @param hdcDst
* Handle to a device context (DC) for the screen. This handle is
* obtained by specifying NULL when calling the function. It is
* used for palette color matching when the window contents are
* updated. If hdcDst isNULL, the default palette will be used.
* If hdcSrc is NULL, hdcDst must be NULL.
* @param pptDst
* Pointer to a POINT structure that specifies the new screen
* position of the layered window. If the current position is not
* changing, pptDst can be NULL.
* @param psize
* Pointer to a SIZE structure that specifies the new size of the
* layered window. If the size of the window is not changing,
* psize can be NULL. If hdcSrc is NULL, psize must be NULL.
* @param hdcSrc
* Handle to a DC for the surface that defines the layered
* window. This handle can be obtained by calling the
* CreateCompatibleDC function. If the shape and visual context
* of the window are not changing, hdcSrc can be NULL.
* @param pptSrc
* Pointer to a POINT structure that specifies the location of
* the layer in the device context. If hdcSrc is NULL, pptSrc
* should be NULL.
* @param crKey
* Pointer to a COLORREF value that specifies the color key to be
* used when composing the layered window. To generate a
* COLORREF, use the RGB macro.
* @param pblend
* Pointer to a BLENDFUNCTION structure that specifies the
* transparency value to be used when composing the layered
* window.
* @param dwFlags
* ULW_* flags.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst,
SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey,
BLENDFUNCTION pblend, int dwFlags);
/**
* This function sets the window region of a window. The window region
* determines the area within the window where the system permits drawing.
* The system does not display any portion of a window that lies outside of
* the window region.
*
* @param hWnd
* Handle to the window whose window region is to be set.
* @param hRgn
* Handle to a region. The function sets the window region of the
* window to this region. If hRgn is NULL, the function sets the
* window region to NULL.
* @param bRedraw
* Specifies whether the system redraws the window after setting
* the window region. If bRedraw is TRUE, the system does so;
* otherwise, it does not. Typically, you set bRedraw to TRUE if
* the window is visible.
* @return Nonzero indicates success. Zero indicates failure. To get
* extended error information, call GetLastError.
*/
int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw);
/**
* The GetKeyboardState function copies the status of the 256 virtual keys
* to the specified buffer.
*
* @param lpKeyState
* Pointer to the 256-byte array that receives the status data
* for each virtual key.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean GetKeyboardState(byte[] lpKeyState);
/**
* This function determines whether a key is up or down at the time the
* function is called, and whether the key was pressed after a previous call
* to GetAsyncKeyState.
*
* @param vKey
* Specifies one of 256 possible virtual-key codes.
* @return If the function succeeds, the return value specifies whether the
* key was pressed since the last call to GetAsyncKeyState, and
* whether the key is currently up or down. If the most significant
* bit is set, the key is down.
*/
short GetAsyncKeyState(int vKey);
/**
* The SetWindowsHookEx function installs an application-defined hook
* procedure into a hook chain. You would install a hook procedure to
* monitor the system for certain types of events. These events are
* associated either with a specific thread or with all threads in the same
* desktop as the calling thread.
*
* @param idHook
* Specifies the type of hook procedure to be installed.
* @param lpfn
* Pointer to the hook procedure.
* @param hMod
* Handle to the DLL containing the hook procedure pointed to by
* the lpfn parameter.
* @param dwThreadId
* Specifies the identifier of the thread with which the hook
* procedure is to be associated.
* @return If the function succeeds, the return value is the handle to the
* hook procedure. If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, int dwThreadId);
/**
* The CallNextHookEx function passes the hook information to the next hook
* procedure in the current hook chain. A hook procedure can call this
* function either before or after processing the hook information.
*
* @param hhk
* Ignored.
* @param nCode
* Specifies the hook code passed to the current hook procedure.
* The next hook procedure uses this code to determine how to
* process the hook information.
* @param wParam
* Specifies the wParam value passed to the current hook
* procedure. The meaning of this parameter depends on the type
* of hook associated with the current hook chain.
* @param lParam
* Specifies the lParam value passed to the current hook
* procedure. The meaning of this parameter depends on the type
* of hook associated with the current hook chain.
* @return This value is returned by the next hook procedure in the chain.
* The current hook procedure must also return this value. The
* meaning of the return value depends on the hook type.
*/
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);
/**
* The UnhookWindowsHookEx function removes a hook procedure installed in a
* hook chain by the SetWindowsHookEx function.
*
* @param hhk
* Handle to the hook to be removed. This parameter is a hook
* handle obtained by a previous call to SetWindowsHookEx.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean UnhookWindowsHookEx(HHOOK hhk);
/**
* This function retrieves a message from the calling thread's message queue
* and places it in the specified structure.
*
* @param lpMsg
* Pointer to an MSG structure that receives message information
* from the thread's message queue.
* @param hWnd
* Handle to the window whose messages are to be retrieved. One
* value has a special meaning.
* @param wMsgFilterMin
* Specifies the integer value of the lowest message value to be
* retrieved.
* @param wMsgFilterMax
* Specifies the integer value of the highest message value to be
* retrieved.
* @return If the function retrieves a message other than WM_QUIT, the
* return value is nonzero.
*
* <p>If the function retrieves the WM_QUIT message, the return value is zero.</p>
*
* <p>If there is an error, the return value is -1. For example, the function
* fails if hWnd is an invalid window handle or lpMsg is an invalid pointer.
* To get extended error information, call GetLastError.</p>
*/
int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax);
/**
* This function checks a thread message queue for a message and places the
* message (if any) in the specified structure.
*
* @param lpMsg
* Pointer to an MSG structure that receives message information.
* @param hWnd
* Handle to the window whose messages are to be examined.
* @param wMsgFilterMin
* Specifies the value of the first message in the range of
* messages to be examined.
* @param wMsgFilterMax
* Specifies the value of the last message in the range of
* messages to be examined.
* @param wRemoveMsg
* Specifies how messages are handled. This parameter can be one
* of the following values.
* @return Nonzero indicates success. Zero indicates failure.
*/
boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin,
int wMsgFilterMax, int wRemoveMsg);
/**
* This function translates virtual-key messages into character messages.
* The character messages are posted to the calling thread's message queue,
* to be read the next time the thread calls the GetMessage or PeekMessage
* function.
*
* @param lpMsg
* Pointer to an MSG structure that contains message information
* retrieved from the calling thread's message queue by using the
* GetMessage or PeekMessage function.
* @return Nonzero indicates that the message is translated, that is, a
* character message is posted to the thread's message queue. If the
* message is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is
* nonzero, regardless of the translation. Zero indicates that the
* message is not translated, that is, a character message is not
* posted to the thread's message queue.
*/
boolean TranslateMessage(MSG lpMsg);
/**
* This function dispatches a message to a window procedure. It is typically
* used to dispatch a message retrieved by the GetMessage function.
*
* @param lpMsg
* Pointer to an MSG structure that contains the message.
* @return The return value specifies the value returned by the window
* procedure. Although its meaning depends on the message being
* dispatched, the return value generally is ignored.
*/
LRESULT DispatchMessage(MSG lpMsg);
/**
* This function places a message in the message queue associated with the
* thread that created the specified window and then returns without waiting
* for the thread to process the message. Messages in a message queue are
* retrieved by calls to the GetMessage or PeekMessage function.
*
* @param hWnd
* Handle to the window whose window procedure is to receive the
* message.
* @param msg
* Specifies the message to be posted.
* @param wParam
* Specifies additional message-specific information.
* @param lParam
* Specifies additional message-specific information.
*/
void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam);
/**
* Posts a message to the message queue of the specified thread. It returns
* without waiting for the thread to process the message.
*
* @param idThread The identifier of the thread to which the message is to
* be posted.
*
* <p>The function fails if the specified thread does not have a
* message queue. The system creates a thread's message queue when the
* thread makes its first call to one of the User or GDI functions.</p>
*
* <p>Message posting is subject to UIPI. The thread of a process can post
* messages only to posted-message queues of threads in processes of lesser
* or equal integrity level.</p>
*
* <p>This thread must have the SE_TCB_NAME privilege to post a message to a
* thread that belongs to a process with the same locally unique identifier
* (LUID) but is in a different desktop. Otherwise, the function fails
* and returns ERROR_INVALID_THREAD_ID.</p>
*
* <p>This thread must either belong to the same desktop as the calling
* thread or to a process with the same LUID. Otherwise, the function
* fails and returns ERROR_INVALID_THREAD_ID.</p>
*
* @param Msg The type of message to be posted.
*
* @param wParam Additional message-specific information.
*
* @param lParam Additional message-specific information.
*
* @return If the function succeeds, the return value is nonzero.
*
* <p>If the function fails, the return value is zero. To get extended error
* information, call GetLastError.</p><p>GetLastError returns
* ERROR_INVALID_THREAD_ID if idThread is not a valid thread identifier, or
* if the thread specified by idThread does not have a message queue.</p>
* <p>GetLastError returns ERROR_NOT_ENOUGH_QUOTA when the message limit is hit.</p>
*/
int PostThreadMessage(int idThread, int Msg, WPARAM wParam, LPARAM lParam);
/**
* This function indicates to Windows that a thread has made a request to
* terminate (quit). It is typically used in response to a WM_DESTROY
* message.
*
* @param nExitCode
* Specifies an application exit code. This value is used as the
* wParam parameter of the WM_QUIT message.
*/
void PostQuitMessage(int nExitCode);
/**
* The GetSystemMetrics function retrieves various system metrics (widths
* and heights of display elements) and system configuration settings. All
* dimensions retrieved by GetSystemMetrics are in pixels.
*
* @param nIndex
* System metric or configuration setting to retrieve. This
* parameter can be one of the following values. Note that all
* SM_CX* values are widths and all SM_CY* values are heights.
* Also note that all settings designed to return Boolean data
* represent TRUE as any nonzero value, and FALSE as a zero
* value.
* @return If the function succeeds, the return value is the requested
* system metric or configuration setting. If the function fails,
* the return value is zero. GetLastError does not provide extended
* error information.
*/
int GetSystemMetrics(int nIndex);
/**
* Changes the parent window of the specified child window.
*
* @param hWndChild
* A handle to the child window.
*
* @param hWndNewParent
* A handle to the new parent window. If this parameter is NULL,
* the desktop window becomes the new parent window. If this
* parameter is HWND_MESSAGE, the child window becomes a
* message-only window.
*
* @return If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended
* error information, call GetLastError.
*/
HWND SetParent(HWND hWndChild, HWND hWndNewParent);
/**
* Determines the visibility state of the specified window.
*
* @param hWnd
* A handle to the window to be tested.
*
* @return If the specified window, its parent window, its parent's parent
* window, and so forth, have the WS_VISIBLE style, the return value
* is nonzero. Otherwise, the return value is zero.
*
* Because the return value specifies whether the window has the
* WS_VISIBLE style, it may be nonzero even if the window is totally
* obscured by other windows.
*/
boolean IsWindowVisible(HWND hWnd);
/**
* Changes the position and dimensions of the specified window. For a
* top-level window, the position and dimensions are relative to the
* upper-left corner of the screen. For a child window, they are relative to
* the upper-left corner of the parent window's client area.
*
* @param hWnd
* A handle to the window.
*
* @param X
* The new position of the left side of the window.
*
* @param Y
* The new position of the top of the window.
*
* @param nWidth
* The new width of the window.
*
* @param nHeight
* The new height of the window.
*
* @param bRepaint
* Indicates whether the window is to be repainted. If this
* parameter is TRUE, the window receives a message. If the
* parameter is FALSE, no repainting of any kind occurs. This
* applies to the client area, the nonclient area (including the
* title bar and scroll bars), and any part of the parent window
* uncovered as a result of moving a child window.
*
* @return If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended
* error information, call GetLastError.
*/
boolean MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, boolean bRepaint);
/**
* Changes the size, position, and Z order of a child, pop-up, or top-level
* window. These windows are ordered according to their appearance on the
* screen. The topmost window receives the highest rank and is the first
* window in the Z order.
*
* @param hWnd
* A handle to the window.
*
* @param hWndInsertAfter
* A handle to the window to precede the positioned window in the
* Z order.
*
* @param X
* The new position of the left side of the window, in client
* coordinates.
*
* @param Y
* The new position of the top of the window, in client
* coordinates.
*
* @param cx
* The new width of the window, in pixels.
*
* @param cy
* The new height of the window, in pixels.
*
* @param uFlags
* The window sizing and positioning flags.
*
* @return If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended
* error information, call GetLastError.