win 0.1.27 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/.gitignore +21 -21
- data/LICENSE +20 -20
- data/README.rdoc +175 -175
- data/Rakefile +58 -58
- data/VERSION +1 -1
- data/features/support/env.rb +4 -4
- data/features/win.feature +9 -9
- data/lib/win/dde.rb +1234 -1234
- data/lib/win/error.rb +1223 -1223
- data/lib/win/extensions.rb +41 -41
- data/lib/win/gui.rb +16 -16
- data/lib/win/gui/dialog.rb +50 -50
- data/lib/win/gui/input.rb +319 -319
- data/lib/win/gui/message.rb +807 -807
- data/lib/win/gui/window.rb +679 -679
- data/lib/win/library.rb +463 -463
- data/spec/spec.opts +2 -2
- data/spec/spec_helper.rb +140 -135
- data/spec/test_apps/locknote/LockNote.exe +0 -0
- data/spec/win/dde_spec.rb +528 -528
- data/spec/win/error_spec.rb +112 -112
- data/spec/win/extensions_spec.rb +73 -73
- data/spec/win/gui/dialog_spec.rb +43 -43
- data/spec/win/gui/input_spec.rb +101 -101
- data/spec/win/gui/message_spec.rb +236 -236
- data/spec/win/gui/window_spec.rb +549 -548
- data/spec/win/library_spec.rb +341 -341
- data/win.gemspec +87 -87
- metadata +34 -17
data/lib/win/gui/message.rb
CHANGED
@@ -1,807 +1,807 @@
|
|
1
|
-
require 'win/library'
|
2
|
-
|
3
|
-
module Win
|
4
|
-
module
|
5
|
-
# Contains constants and Win32API functions related to Windows messaging
|
6
|
-
#
|
7
|
-
# Below is a table of system-defined message prefixes:
|
8
|
-
#
|
9
|
-
# *Prefix*:: *Message* *category*
|
10
|
-
# ABM:: Application desktop toolbar
|
11
|
-
# BM:: Button control
|
12
|
-
# CB:: Combo box control
|
13
|
-
# CBEM:: Extended combo box control
|
14
|
-
# CDM:: Common dialog box
|
15
|
-
# DBT:: Device
|
16
|
-
# DL:: Drag list box
|
17
|
-
# DM:: Default push button control
|
18
|
-
# DTM:: Date and time picker control
|
19
|
-
# EM:: Edit control
|
20
|
-
# HDM:: Header control
|
21
|
-
# HKM:: Hot key control
|
22
|
-
# IPM:: IP address control
|
23
|
-
# LB:: List box control
|
24
|
-
# LVM:: List view control
|
25
|
-
# MCM:: Month calendar control
|
26
|
-
# PBM:: Progress bar
|
27
|
-
# PGM:: Pager control
|
28
|
-
# PSM:: Property sheet
|
29
|
-
# RB:: Rebar control
|
30
|
-
# SB:: Status bar window
|
31
|
-
# SBM:: Scroll bar control
|
32
|
-
# STM:: Static control
|
33
|
-
# TB:: Toolbar
|
34
|
-
# TBM:: Trackbar
|
35
|
-
# TCM:: Tab control
|
36
|
-
# TTM:: Tooltip control
|
37
|
-
# TVM:: Tree-view control
|
38
|
-
# UDM:: Up-down control
|
39
|
-
# WM:: General window
|
40
|
-
module Message
|
41
|
-
include Win::Library
|
42
|
-
|
43
|
-
# General window messages cover a wide range of information and requests, including messages for mouse and
|
44
|
-
# keyboard input, menu and dialog box input, window creation and management, and Dynamic Data Exchange (DDE).
|
45
|
-
# General window messages WM/WA:
|
46
|
-
|
47
|
-
#
|
48
|
-
WM_NULL = 0x0000
|
49
|
-
WA_INACTIVE = 0x0000
|
50
|
-
WM_CREATE = 0x0001
|
51
|
-
WA_ACTIVE = 0x0001
|
52
|
-
WM_DESTROY = 0x0002
|
53
|
-
WA_CLICKACTIVE = 0x0002
|
54
|
-
WM_MOVE = 0x0003
|
55
|
-
WM_SIZE = 0x0005
|
56
|
-
WM_ACTIVATE = 0x0006
|
57
|
-
WM_SETFOCUS = 0x0007
|
58
|
-
WM_KILLFOCUS = 0x0008
|
59
|
-
WM_ENABLE = 0x000A
|
60
|
-
WM_SETREDRAW = 0x000B
|
61
|
-
WM_SETTEXT = 0x000C
|
62
|
-
# Windows Message Get Text
|
63
|
-
WM_GETTEXT = 0x000D
|
64
|
-
WM_GETTEXTLENGTH = 0x000E
|
65
|
-
WM_PAINT = 0x000F
|
66
|
-
WM_CLOSE = 0x0010
|
67
|
-
WM_QUERYENDSESSION= 0x0011
|
68
|
-
WM_QUIT = 0x0012
|
69
|
-
WM_QUERYOPEN = 0x0013
|
70
|
-
WM_ERASEBKGND = 0x0014
|
71
|
-
WM_SYSCOLORCHANGE = 0x0015
|
72
|
-
WM_ENDSESSION = 0x0016
|
73
|
-
WM_SHOWWINDOW = 0x0018
|
74
|
-
WM_WININICHANGE = 0x001A
|
75
|
-
WM_SETTINGCHANGE = WM_WININICHANGE
|
76
|
-
WM_DEVMODECHANGE = 0x001B
|
77
|
-
WM_ACTIVATEAPP = 0x001C
|
78
|
-
WM_FONTCHANGE = 0x001D
|
79
|
-
WM_TIMECHANGE = 0x001E
|
80
|
-
WM_CANCELMODE = 0x001F
|
81
|
-
WM_SETCURSOR = 0x0020
|
82
|
-
WM_MOUSEACTIVATE = 0x0021
|
83
|
-
WM_CHILDACTIVATE = 0x0022
|
84
|
-
WM_QUEUESYNC = 0x0023
|
85
|
-
WM_GETMINMAXINFO = 0x0024
|
86
|
-
WM_PAINTICON = 0x0026
|
87
|
-
WM_ICONERASEBKGND = 0x0027
|
88
|
-
WM_NEXTDLGCTL = 0x0028
|
89
|
-
WM_SPOOLERSTATUS = 0x002A
|
90
|
-
WM_DRAWITEM = 0x002B
|
91
|
-
WM_MEASUREITEM = 0x002C
|
92
|
-
WM_DELETEITEM = 0x002D
|
93
|
-
WM_VKEYTOITEM = 0x002E
|
94
|
-
WM_CHARTOITEM = 0x002F
|
95
|
-
WM_SETFONT = 0x0030
|
96
|
-
WM_GETFONT = 0x0031
|
97
|
-
WM_SETHOTKEY = 0x0032
|
98
|
-
WM_GETHOTKEY = 0x0033
|
99
|
-
WM_QUERYDRAGICON = 0x0037
|
100
|
-
WM_COMPAREITEM = 0x0039
|
101
|
-
WM_COMPACTING = 0x0041
|
102
|
-
WM_COMMNOTIFY = 0x0044 # no longer supported
|
103
|
-
WM_WINDOWPOSCHANGING = 0x0046
|
104
|
-
WM_WINDOWPOSCHANGED = 0x0047
|
105
|
-
WM_POWER = 0x0048
|
106
|
-
WM_COPYDATA = 0x004A
|
107
|
-
WM_CANCELJOURNAL = 0x004B
|
108
|
-
WM_NOTIFY = 0x004E
|
109
|
-
WM_INPUTLANGCHANGEREQUEST = 0x0050
|
110
|
-
WM_INPUTLANGCHANGE = 0x0051
|
111
|
-
WM_TCARD = 0x0052
|
112
|
-
WM_HELP = 0x0053
|
113
|
-
WM_USERCHANGED = 0x0054
|
114
|
-
WM_NOTIFYFORMAT = 0x0055
|
115
|
-
WM_CONTEXTMENU = 0x007B
|
116
|
-
WM_STYLECHANGING = 0x007C
|
117
|
-
WM_STYLECHANGED = 0x007D
|
118
|
-
WM_DISPLAYCHANGE = 0x007E
|
119
|
-
WM_GETICON = 0x007F
|
120
|
-
WM_SETICON = 0x0080
|
121
|
-
WM_NCCREATE = 0x0081
|
122
|
-
WM_NCDESTROY = 0x0082
|
123
|
-
WM_NCCALCSIZE = 0x0083
|
124
|
-
WM_NCHITTEST = 0x0084
|
125
|
-
WM_NCPAINT = 0x0085
|
126
|
-
WM_NCACTIVATE = 0x0086
|
127
|
-
WM_GETDLGCODE = 0x0087
|
128
|
-
WM_SYNCPAINT = 0x0088
|
129
|
-
WM_NCMOUSEMOVE = 0x00A0
|
130
|
-
WM_NCLBUTTONDOWN = 0x00A1
|
131
|
-
WM_NCLBUTTONUP = 0x00A2
|
132
|
-
WM_NCLBUTTONDBLCLK = 0x00A3
|
133
|
-
WM_NCRBUTTONDOWN = 0x00A4
|
134
|
-
WM_NCRBUTTONUP = 0x00A5
|
135
|
-
WM_NCRBUTTONDBLCLK = 0x00A6
|
136
|
-
WM_NCMBUTTONDOWN = 0x00A7
|
137
|
-
WM_NCMBUTTONUP = 0x00A8
|
138
|
-
WM_NCMBUTTONDBLCLK = 0x00A9
|
139
|
-
WM_NCXBUTTONDOWN = 0x00AB
|
140
|
-
WM_NCXBUTTONUP = 0x00AC
|
141
|
-
WM_NCXBUTTONDBLCLK = 0x00AD
|
142
|
-
WM_INPUT = 0x00FF
|
143
|
-
WM_KEYFIRST = 0x0100
|
144
|
-
WM_KEYDOWN = 0x0100
|
145
|
-
WM_KEYUP = 0x0101
|
146
|
-
WM_CHAR = 0x0102
|
147
|
-
WM_DEADCHAR = 0x0103
|
148
|
-
WM_SYSKEYDOWN = 0x0104
|
149
|
-
WM_SYSKEYUP = 0x0105
|
150
|
-
WM_SYSCHAR = 0x0106
|
151
|
-
WM_SYSDEADCHAR = 0x0107
|
152
|
-
WM_UNICHAR = 0x0109
|
153
|
-
WM_IME_STARTCOMPOSITION = 0x010D
|
154
|
-
WM_IME_ENDCOMPOSITION = 0x010E
|
155
|
-
WM_IME_COMPOSITION = 0x010F
|
156
|
-
WM_IME_KEYLAST = 0x010F
|
157
|
-
WM_INITDIALOG = 0x0110
|
158
|
-
WM_COMMAND = 0x0111
|
159
|
-
# Windows Message Sys Command
|
160
|
-
WM_SYSCOMMAND = 0x0112
|
161
|
-
WM_TIMER = 0x0113
|
162
|
-
WM_HSCROLL = 0x0114
|
163
|
-
WM_VSCROLL = 0x0115
|
164
|
-
WM_INITMENU = 0x0116
|
165
|
-
WM_INITMENUPOPUP = 0x0117
|
166
|
-
WM_MENUSELECT = 0x011F
|
167
|
-
WM_MENUCHAR = 0x0120
|
168
|
-
WM_ENTERIDLE = 0x0121
|
169
|
-
WM_MENURBUTTONUP = 0x0122
|
170
|
-
WM_MENUDRAG = 0x0123
|
171
|
-
WM_MENUGETOBJECT = 0x0124
|
172
|
-
WM_UNINITMENUPOPUP = 0x0125
|
173
|
-
WM_MENUCOMMAND = 0x0126
|
174
|
-
WM_CHANGEUISTATE = 0x0127
|
175
|
-
WM_UPDATEUISTATE = 0x0128
|
176
|
-
WM_QUERYUISTATE = 0x0129
|
177
|
-
WM_CTLCOLORMSGBOX = 0x0132
|
178
|
-
WM_CTLCOLOREDIT = 0x0133
|
179
|
-
WM_CTLCOLORLISTBOX = 0x0134
|
180
|
-
WM_CTLCOLORBTN = 0x0135
|
181
|
-
WM_CTLCOLORDLG = 0x0136
|
182
|
-
WM_CTLCOLORSCROLLBAR = 0x0137
|
183
|
-
WM_CTLCOLORSTATIC = 0x0138
|
184
|
-
WM_MOUSEFIRST = 0x0200
|
185
|
-
WM_MOUSEMOVE = 0x0200
|
186
|
-
WM_LBUTTONDOWN = 0x0201
|
187
|
-
WM_LBUTTONUP = 0x0202
|
188
|
-
WM_LBUTTONDBLCLK = 0x0203
|
189
|
-
WM_RBUTTONDOWN = 0x0204
|
190
|
-
WM_RBUTTONUP = 0x0205
|
191
|
-
WM_RBUTTONDBLCLK = 0x0206
|
192
|
-
WM_MBUTTONDOWN = 0x0207
|
193
|
-
WM_MBUTTONUP = 0x0208
|
194
|
-
WM_MBUTTONDBLCLK = 0x0209
|
195
|
-
WM_MOUSEWHEEL = 0x020A
|
196
|
-
WM_XBUTTONDOWN = 0x020B
|
197
|
-
WM_XBUTTONUP = 0x020C
|
198
|
-
WM_XBUTTONDBLCLK = 0x020D
|
199
|
-
WM_MOUSELAST = 0x020D # Win2k or later
|
200
|
-
WM_PARENTNOTIFY = 0x0210
|
201
|
-
WM_ENTERMENULOOP = 0x0211
|
202
|
-
WM_EXITMENULOOP = 0x0212
|
203
|
-
WM_NEXTMENU = 0x0213
|
204
|
-
WM_SIZING = 0x0214
|
205
|
-
WM_CAPTURECHANGED = 0x0215
|
206
|
-
WM_MOVING = 0x0216
|
207
|
-
WM_POWERBROADCAST = 0x0218
|
208
|
-
WM_DEVICECHANGE = 0x0219
|
209
|
-
WM_MDICREATE = 0x0220
|
210
|
-
WM_MDIDESTROY = 0x0221
|
211
|
-
WM_MDIACTIVATE = 0x0222
|
212
|
-
WM_MDIRESTORE = 0x0223
|
213
|
-
WM_MDINEXT = 0x0224
|
214
|
-
WM_MDIMAXIMIZE = 0x0225
|
215
|
-
WM_MDITILE = 0x0226
|
216
|
-
WM_MDICASCADE = 0x0227
|
217
|
-
WM_MDIICONARRANGE = 0x0228
|
218
|
-
WM_MDIGETACTIVE = 0x0229
|
219
|
-
WM_MDISETMENU = 0x0230
|
220
|
-
WM_ENTERSIZEMOVE = 0x0231
|
221
|
-
WM_EXITSIZEMOVE = 0x0232
|
222
|
-
WM_DROPFILES = 0x0233
|
223
|
-
WM_MDIREFRESHMENU = 0x0234
|
224
|
-
WM_IME_SETCONTEXT = 0x0281
|
225
|
-
WM_IME_NOTIFY = 0x0282
|
226
|
-
WM_IME_CONTROL = 0x0283
|
227
|
-
WM_IME_COMPOSITIONFULL = 0x0284
|
228
|
-
WM_IME_SELECT = 0x0285
|
229
|
-
WM_IME_CHAR = 0x0286
|
230
|
-
WM_IME_REQUEST = 0x0288
|
231
|
-
WM_IME_KEYDOWN = 0x0290
|
232
|
-
WM_IME_KEYUP = 0x0291
|
233
|
-
WM_MOUSEHOVER = 0x02A1
|
234
|
-
WM_MOUSELEAVE = 0x02A3
|
235
|
-
WM_NCMOUSEHOVER = 0x02A0
|
236
|
-
WM_NCMOUSELEAVE = 0x02A2
|
237
|
-
WM_WTSSESSION_CHANGE = 0x02B1
|
238
|
-
WM_TABLET_FIRST = 0x02c0
|
239
|
-
WM_TABLET_LAST = 0x02df
|
240
|
-
WM_CUT = 0x0300
|
241
|
-
WM_COPY = 0x0301
|
242
|
-
WM_PASTE = 0x0302
|
243
|
-
WM_CLEAR = 0x0303
|
244
|
-
WM_UNDO = 0x0304
|
245
|
-
WM_RENDERFORMAT = 0x0305
|
246
|
-
WM_RENDERALLFORMATS = 0x0306
|
247
|
-
WM_DESTROYCLIPBOARD = 0x0307
|
248
|
-
WM_DRAWCLIPBOARD = 0x0308
|
249
|
-
WM_PAINTCLIPBOARD = 0x0309
|
250
|
-
WM_VSCROLLCLIPBOARD = 0x030A
|
251
|
-
WM_SIZECLIPBOARD = 0x030B
|
252
|
-
WM_ASKCBFORMATNAME = 0x030C
|
253
|
-
WM_CHANGECBCHAIN = 0x030D
|
254
|
-
WM_HSCROLLCLIPBOARD = 0x030E
|
255
|
-
WM_QUERYNEWPALETTE = 0x030F
|
256
|
-
WM_PALETTEISCHANGING = 0x0310
|
257
|
-
WM_PALETTECHANGED = 0x0311
|
258
|
-
WM_HOTKEY = 0x0312
|
259
|
-
WM_PRINT = 0x0317
|
260
|
-
WM_PRINTCLIENT = 0x0318
|
261
|
-
WM_APPCOMMAND = 0x0319
|
262
|
-
WM_THEMECHANGED = 0x031A
|
263
|
-
WM_HANDHELDFIRST = 0x0358
|
264
|
-
WM_HANDHELDLAST = 0x035F
|
265
|
-
WM_AFXFIRST = 0x0360
|
266
|
-
WM_AFXLAST = 0x037F
|
267
|
-
WM_PENWINFIRST = 0x0380
|
268
|
-
WM_PENWINLAST = 0x038F
|
269
|
-
# User-specific (non-reserved) messages above this one (WM_USER+1, etc...)
|
270
|
-
WM_USER = 0x0400
|
271
|
-
# App-specific (non-reserved) messages above this one (WM_App+1, etc...)
|
272
|
-
WM_APP = 0x8000
|
273
|
-
|
274
|
-
# Sys Commands (wParam to use with WM_SYSCOMMAND message):
|
275
|
-
|
276
|
-
#
|
277
|
-
SC_SIZE = 0xF000
|
278
|
-
SC_MOVE = 0xF010
|
279
|
-
SC_MINIMIZE = 0xF020
|
280
|
-
SC_MAXIMIZE = 0xF030
|
281
|
-
SC_NEXTWINDOW = 0xF040
|
282
|
-
SC_PREVWINDOW = 0xF050
|
283
|
-
# Sys Command Close
|
284
|
-
SC_CLOSE = 0xF060
|
285
|
-
SC_VSCROLL = 0xF070
|
286
|
-
SC_HSCROLL = 0xF080
|
287
|
-
SC_MOUSEMENU = 0xF090
|
288
|
-
SC_KEYMENU = 0xF100
|
289
|
-
SC_ARRANGE = 0xF110
|
290
|
-
SC_RESTORE = 0xF120
|
291
|
-
SC_TASKLIST = 0xF130
|
292
|
-
SC_SCREENSAVE = 0xF140
|
293
|
-
SC_HOTKEY = 0xF150
|
294
|
-
SC_DEFAULT = 0xF160
|
295
|
-
SC_MONITORPOWER = 0xF170
|
296
|
-
SC_CONTEXTHELP = 0xF180
|
297
|
-
|
298
|
-
# Queue status flags:
|
299
|
-
|
300
|
-
#
|
301
|
-
QS_KEY = 0x0001
|
302
|
-
QS_MOUSEMOVE = 0x0002
|
303
|
-
QS_MOUSEBUTTON = 0x0004
|
304
|
-
QS_MOUSE = (QS_MOUSEMOVE | QS_MOUSEBUTTON)
|
305
|
-
QS_POSTMESSAGE = 0x0008
|
306
|
-
QS_TIMER = 0x0010
|
307
|
-
QS_PAINT = 0x0020
|
308
|
-
QS_SENDMESSAGE = 0x0040
|
309
|
-
QS_HOTKEY = 0x0080
|
310
|
-
QS_ALLPOSTMESSAGE= 0x0100
|
311
|
-
QS_RAWINPUT = 0x0400
|
312
|
-
QS_INPUT = (QS_MOUSE | QS_KEY | QS_RAWINPUT)
|
313
|
-
QS_ALLEVENTS = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY)
|
314
|
-
QS_ALLINPUT = (QS_ALLEVENTS | QS_SENDMESSAGE)
|
315
|
-
QS_SMRESULT = 0x8000
|
316
|
-
|
317
|
-
# PeekMessage flags:
|
318
|
-
|
319
|
-
# Messages are not removed from the queue after processing by PeekMessage (default)
|
320
|
-
PM_NOREMOVE = 0x0000
|
321
|
-
# Messages are removed from the queue after processing by PeekMessage.
|
322
|
-
PM_REMOVE = 0x0001
|
323
|
-
# You can optionally combine the value PM_NOYIELD with either PM_NOREMOVE or PM_REMOVE. This flag
|
324
|
-
# prevents the system from releasing any thread that is waiting for the caller to go idle (see WaitForInputIdle).
|
325
|
-
PM_NOYIELD = 0x0002
|
326
|
-
# By default, all message types are processed. To specify that only certain
|
327
|
-
# message should be processed, specify one or more of the following values.
|
328
|
-
# PM_QS_INPUT - Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages.
|
329
|
-
PM_QS_INPUT = (QS_INPUT << 16)
|
330
|
-
# PM_QS_POSTMESSAGE - Win 98/Me/2000/XP: Process all posted messages, including timers and hotkeys.
|
331
|
-
PM_QS_POSTMESSAGE= ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16)
|
332
|
-
# PM_QS_PAINT - Windows 98/Me, Windows 2000/XP: Process paint messages.
|
333
|
-
PM_QS_PAINT = (QS_PAINT << 16)
|
334
|
-
# PM_QS_SENDMESSAGE - Windows 98/Me, Windows 2000/XP: Process all sent messages.
|
335
|
-
PM_QS_SENDMESSAGE= (QS_SENDMESSAGE << 16)
|
336
|
-
|
337
|
-
|
338
|
-
##
|
339
|
-
# The SendAsyncProc function is an application-defined callback function used with the SendMessageCallback
|
340
|
-
# function. The system passes the message to the callback function after passing the message to the
|
341
|
-
# destination window procedure. SendAsyncProc is a placeholder for the application-defined function name.
|
342
|
-
#
|
343
|
-
# [*Syntax*] VOID SendAsyncProc( HWND hwnd, UINT uMsg, ULONG_PTR dwData, LRESULT lResult );
|
344
|
-
#
|
345
|
-
# hwnd:: [in] Handle to the window whose window procedure received the message. If SendMessageCallback
|
346
|
-
# function was called with its hwnd parameter set to HWND_BROADCAST, the system calls the
|
347
|
-
# SendAsyncProc function once for each top-level window.
|
348
|
-
# uMsg:: [in] Specifies the message.
|
349
|
-
# dwData:: [in] Specifies an application-defined value sent from the SendMessageCallback function.
|
350
|
-
# lResult:: [in] Specifies the result of the message processing. This value depends on the message.
|
351
|
-
#
|
352
|
-
# :call-seq:
|
353
|
-
# SendAsyncProc callback block: {|handle, msg, data, l_result| your callback code }
|
354
|
-
#
|
355
|
-
callback :SendAsyncProc, [:HWND, :uint, :ulong, :long], :void
|
356
|
-
|
357
|
-
##
|
358
|
-
# The SendMessageCallback function sends the specified message to a window or windows. It calls the window
|
359
|
-
# procedure for the specified window and returns immediately. After the window procedure processes the message,
|
360
|
-
# the system calls the specified callback function, passing the result of the message processing and an
|
361
|
-
# application-defined value to the callback function.
|
362
|
-
#
|
363
|
-
# [*Syntax*] BOOL SendMessageCallback( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
364
|
-
# SENDASYNCPROC lpCallBack, ULONG_PTR dwData);
|
365
|
-
#
|
366
|
-
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
367
|
-
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
368
|
-
# invisible, unowned, overlapped and pop-up windows; but the message is not sent to child windows.
|
369
|
-
# Msg:: [in] Specifies the message to be sent.
|
370
|
-
# wParam:: [in] Specifies additional message-specific information.
|
371
|
-
# lParam:: [in] Specifies additional message-specific information.
|
372
|
-
# lpCallBack:: [in] Pointer to a callback function that the system calls after the window procedure processes
|
373
|
-
# the message. For more information, see SendAsyncProc. If hWnd is HWND_BROADCAST, the system calls
|
374
|
-
# SendAsyncProc callback function once for each top-level window.
|
375
|
-
# dwData:: [in] Specifies an application-defined value to be sent to the callback function pointed to by
|
376
|
-
# the lpCallBack parameter.
|
377
|
-
# *Returns*:: Nonzero if the function succeeds, zero if it fails. For extended error info, call GetLastError.
|
378
|
-
# ---
|
379
|
-
# *Remarks*:
|
380
|
-
# - If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage,
|
381
|
-
# SendNotifyMessage, and SendMessageCallback), its message parameters cannot include pointers. Otherwise,
|
382
|
-
# the operation will fail. The functions will return before the receiving thread has had a chance
|
383
|
-
# to process the message and the sender will free the memory before it is used.
|
384
|
-
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
385
|
-
# to obtain a unique message for inter-application communication.
|
386
|
-
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send
|
387
|
-
# messages (>= WM_USER) to another process, you must do custom marshalling.
|
388
|
-
# - The callback function is called only when the thread that called SendMessageCallback also calls GetMessage,
|
389
|
-
# PeekMessage, or WaitMessage.
|
390
|
-
#
|
391
|
-
# :call-seq:
|
392
|
-
# success = send_message_callback(handle, msg, w_param, l_param, [data=0])
|
393
|
-
# {|handle, msg, data, l_result| callback code }
|
394
|
-
#
|
395
|
-
function :SendMessageCallback, [:HWND, :uint, :uint, :pointer, :SendAsyncProc, :ulong], :int8, boolean: true,
|
396
|
-
&->(api, handle, msg, w_param, l_param, data=0, &block){
|
397
|
-
api.call(handle, msg, w_param, l_param, block, data)}
|
398
|
-
|
399
|
-
|
400
|
-
##
|
401
|
-
# The PostMessage function places (posts) a message in the message queue associated with the thread that
|
402
|
-
# created the specified window and returns without waiting for the thread to process the message.
|
403
|
-
# To post a message in the message queue associate with a thread, use the PostThreadMessage function.
|
404
|
-
#
|
405
|
-
# [*Syntax*] BOOL PostMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
406
|
-
#
|
407
|
-
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
408
|
-
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
409
|
-
# invisible unowned windows, overlapped windows, and pop-up windows; but the message is not posted to
|
410
|
-
# child windows. If it is NULL, the function behaves like a call to PostThreadMessage()
|
411
|
-
# with the dwThreadId parameter set to the identifier of the current thread.
|
412
|
-
# Msg:: [in] Specifies the message to be posted.
|
413
|
-
# wParam:: [in] Specifies additional message-specific information.
|
414
|
-
# lParam:: [in] Specifies additional message-specific information.
|
415
|
-
#
|
416
|
-
# *Returns*:: Nonzero if the function succeeds, zero if it fails. For extended error info, call GetLastError.
|
417
|
-
# ---
|
418
|
-
# *Remarks*:
|
419
|
-
# - Microsoft Windows Vista and later. When a message is blocked by UIPI the last error, retrieved with
|
420
|
-
# GetLastError, is set to 5 (access denied). Messages in a message queue are retrieved by calls to the
|
421
|
-
# GetMessage or PeekMessage function.
|
422
|
-
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
423
|
-
# to obtain a unique message for inter-application communication.
|
424
|
-
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other
|
425
|
-
# messages (those >= WM_USER) to another process, you must do custom marshalling.
|
426
|
-
# - If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage,
|
427
|
-
# SendNotifyMessage, and SendMessageCallback), its message parameters cannot include pointers. Otherwise,
|
428
|
-
# the operation will fail. The functions will return before the receiving thread has had a chance to
|
429
|
-
# process the message and the sender will free the memory before it is used. Use the PostQuitMessage
|
430
|
-
# instead of PostMessage to post WM_QUIT message.
|
431
|
-
#
|
432
|
-
#:call-seq:
|
433
|
-
# success = post_message(handle, msg, w_param, l_param)
|
434
|
-
#
|
435
|
-
function :PostMessage, [:ulong, :uint, :uint, :pointer], :int, boolean: true
|
436
|
-
|
437
|
-
##
|
438
|
-
# The SendMessage function sends the specified message to a window or windows. It calls the window procedure for
|
439
|
-
# the specified window and does not return until the window procedure has processed the message.
|
440
|
-
#
|
441
|
-
# To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a
|
442
|
-
# message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
|
443
|
-
#
|
444
|
-
#
|
445
|
-
# [*Syntax*] LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
|
446
|
-
#
|
447
|
-
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
448
|
-
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
449
|
-
# invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to
|
450
|
-
# child windows.
|
451
|
-
# Microsoft Windows Vista and later. Message sending is subject to User Interface Privilege Isolation
|
452
|
-
# (UIPI). The thread of a process can send messages only to message queues of threads in processes of
|
453
|
-
# lesser or equal integrity level.
|
454
|
-
# Msg:: [in] Specifies the message to be sent.
|
455
|
-
# wParam:: [in] Specifies additional message-specific information.
|
456
|
-
# lParam:: [in/out?] Specifies additional message-specific information.
|
457
|
-
#
|
458
|
-
# *Return*:: The return value specifies the result of the message processing; it depends on the message sent.
|
459
|
-
# ---
|
460
|
-
# *Remarks*:
|
461
|
-
# - Microsoft Windows Vista and later. When a message is blocked by UIPI the last error, retrieved with
|
462
|
-
# GetLastError, is set to 5 (access denied).
|
463
|
-
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
464
|
-
# to obtain a unique message for inter-application communication.
|
465
|
-
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other
|
466
|
-
# messages (those >= WM_USER) to another process, you must do custom marshalling.
|
467
|
-
# - If the specified window was created by the calling thread, the window procedure is called immediately as
|
468
|
-
# a subroutine. If the specified window was created by a different thread, the system switches to that thread
|
469
|
-
# and calls the appropriate window procedure. Messages sent between threads are processed only when the
|
470
|
-
# receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread
|
471
|
-
# processes the message. However, the sending thread will process incoming nonqueued messages while waiting
|
472
|
-
# for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more
|
473
|
-
# information on nonqueued messages, see Nonqueued Messages.
|
474
|
-
#
|
475
|
-
#:call-seq:
|
476
|
-
# send_message(handle, msg, w_param, l_param)
|
477
|
-
#
|
478
|
-
function :SendMessage, [:ulong, :uint, :uint, :pointer], :int # LPARAM different from PostMessage!
|
479
|
-
|
480
|
-
# The MSG structure contains message information from a thread's message queue.
|
481
|
-
#
|
482
|
-
# typedef struct {
|
483
|
-
# HWND hwnd;
|
484
|
-
# UINT message;
|
485
|
-
# WPARAM wParam;
|
486
|
-
# LPARAM lParam;
|
487
|
-
# DWORD time;
|
488
|
-
# POINT pt;
|
489
|
-
# } MSG, *PMSG;
|
490
|
-
#
|
491
|
-
# hwnd:: Handle to the window whose window procedure receives the message. NULL when the message is a thread message.
|
492
|
-
# message:: Message identifier. Applications can only use the low word; the high word is reserved by the system.
|
493
|
-
# wParam:: Additional info about the message. Exact meaning depends on the value of the message member.
|
494
|
-
# lParam:: Additional info about the message. Exact meaning depends on the value of the message member.
|
495
|
-
# time:: Specifies the time at which the message was posted.
|
496
|
-
# pt:: POINT structure - the cursor position, in screen coordinates, when the message was posted.
|
497
|
-
# (in my definition, it is changed to two longs: x, y - has the same effect, just avoid nested structs)
|
498
|
-
class Msg < FFI::Struct
|
499
|
-
layout :hwnd, :ulong,
|
500
|
-
:message, :uint,
|
501
|
-
:w_param, :long,
|
502
|
-
:l_param, :pointer,
|
503
|
-
:time, :uint32,
|
504
|
-
:x, :long,
|
505
|
-
:y, :long
|
506
|
-
end
|
507
|
-
|
508
|
-
##
|
509
|
-
# The GetMessage function retrieves a message from the calling thread's message queue. The function
|
510
|
-
# dispatches incoming sent messages until a posted message is available for retrieval.
|
511
|
-
# Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
|
512
|
-
#
|
513
|
-
# [*Syntax*] BOOL GetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax );
|
514
|
-
#
|
515
|
-
# lpMsg:: [out] Pointer to an MSG structure that receives message information from the thread's message
|
516
|
-
# queue.
|
517
|
-
# hWnd:: [in] Handle to the window whose messages are to be retrieved. The window must belong to the current
|
518
|
-
# thread. If hWnd is NULL, GetMessage retrieves messages for any window that belongs to the current
|
519
|
-
# thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG
|
520
|
-
# structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.
|
521
|
-
# If hWnd is -1, GetMessage retrieves only messages on the current thread's message queue whose hwnd
|
522
|
-
# value is NULL, that is, thread messages as posted by PostMessage (when the hWnd parameter is NULL) or
|
523
|
-
# PostThreadMessage.
|
524
|
-
# wMsgFilterMin:: [in] Specifies the integer value of the lowest message value to be retrieved. Use WM_KEYFIRST
|
525
|
-
# to specify the first keyboard message or WM_MOUSEFIRST to specify the first mouse message.
|
526
|
-
# Windows XP: Use WM_INPUT here and in wMsgFilterMax to specify only the WM_INPUT messages.
|
527
|
-
# If wMsgFilterMin and wMsgFilterMax are both zero, GetMessage returns all available messages
|
528
|
-
# (that is, no range filtering is performed).
|
529
|
-
# wMsgFilterMax:: [in] Specifies the integer value of the highest message value to be retrieved. Use
|
530
|
-
# WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the last
|
531
|
-
# mouse message.
|
532
|
-
#
|
533
|
-
# *Returns*:: If the function retrieves a message other than WM_QUIT, the return value is nonzero.
|
534
|
-
# If the function retrieves the WM_QUIT message, the return value is zero.
|
535
|
-
# If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid
|
536
|
-
# window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
|
537
|
-
# *Warning*
|
538
|
-
# Because the return value can be nonzero, zero, or -1, avoid code like this:
|
539
|
-
# while (GetMessage( lpMsg, hWnd, 0, 0)) ...
|
540
|
-
# The possibility of a -1 return value means that such code can lead to fatal application errors.
|
541
|
-
# Instead, use code like this:
|
542
|
-
# while( (bRet = GetMessage( msg, hWnd, 0, 0 )) != 0)
|
543
|
-
# if (bRet == -1)
|
544
|
-
# // handle the error and possibly exit
|
545
|
-
# else
|
546
|
-
# TranslateMessage(msg);
|
547
|
-
# DispatchMessage(msg);
|
548
|
-
# end
|
549
|
-
# end
|
550
|
-
# ---
|
551
|
-
# *Remarks*:
|
552
|
-
# An application typically uses the return value to determine whether to end the main message loop and
|
553
|
-
# exit the program.
|
554
|
-
#
|
555
|
-
# The GetMessage function retrieves messages associated with the window identified by the hWnd parameter
|
556
|
-
# or any of its children, as specified by the IsChild function, and within the range of message values
|
557
|
-
# given by the wMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low
|
558
|
-
# word in the wMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
|
559
|
-
# Note that GetMessage always retrieves WM_QUIT messages, no matter which values you specify for
|
560
|
-
# wMsgFilterMin and wMsgFilterMax.
|
561
|
-
#
|
562
|
-
# During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows
|
563
|
-
# owned by the calling thread using the SendMessage, SendMessageCallback, SendMessageTimeout, or
|
564
|
-
# SendNotifyMessage function. Then the first queued message that matches the specified filter is
|
565
|
-
# retrieved. The system may also process internal events. If no filter is specified, messages are
|
566
|
-
# processed in the following order:
|
567
|
-
# 1. Sent messages
|
568
|
-
# 2. Posted messages
|
569
|
-
# 3. Input (hardware) messages and system internal events
|
570
|
-
# 4. Sent messages (again)
|
571
|
-
# 5. WM_PAINT messages
|
572
|
-
# 6. WM_TIMER messages
|
573
|
-
#
|
574
|
-
# To retrieve input messages before posted messages, use the wMsgFilterMin and wMsgFilterMax parameters.
|
575
|
-
# GetMessage does not remove WM_PAINT messages from the queue. The messages remain in the queue until
|
576
|
-
# processed.
|
577
|
-
#
|
578
|
-
# Windows XP: If a top-level window stops responding to messages for more than several seconds, the
|
579
|
-
# system considers the window to be not responding and replaces it with a ghost window that has the same
|
580
|
-
# z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even
|
581
|
-
# close the application. However, these are the only actions available because the application is
|
582
|
-
# actually not responding. When in the debugger mode, the system does not generate a ghost window.
|
583
|
-
# ---
|
584
|
-
# <b>Enhanced (snake_case) API: makes all args optional, returns: *false* if WM_QUIT was posted,
|
585
|
-
# *nil* if error was encountered, and retrieved Msg (FFI structure) in all other cases </b>
|
586
|
-
#
|
587
|
-
# :call-seq:
|
588
|
-
# msg = get_message([msg], [handle=0], [msg_filter_min=0], [msg_filter_max=0])
|
589
|
-
#
|
590
|
-
function :GetMessage, [:pointer, :HWND, :uint, :uint], :int8,
|
591
|
-
&->(api, msg=Msg.new, handle=0, msg_filter_min=0, msg_filter_max=0){
|
592
|
-
case api.call(msg, handle, msg_filter_min, msg_filter_max)
|
593
|
-
when 0
|
594
|
-
false
|
595
|
-
when -1
|
596
|
-
nil
|
597
|
-
else
|
598
|
-
msg
|
599
|
-
end }
|
600
|
-
# weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
|
601
|
-
|
602
|
-
##
|
603
|
-
# The PeekMessage function dispatches incoming sent messages, checks the thread message queue for a
|
604
|
-
# posted message, and retrieves the message (if any exist).
|
605
|
-
#
|
606
|
-
# [*Syntax*] BOOL PeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
607
|
-
# UINT wRemoveMsg );
|
608
|
-
#
|
609
|
-
# lpMsg:: [out] Pointer to an MSG structure that receives message information.
|
610
|
-
# hWnd:: [in] Handle to the window whose messages are to be retrieved. The window must belong to the current
|
611
|
-
# thread. If hWnd is NULL, PeekMessage retrieves messages for any window that belongs to the current
|
612
|
-
# thread, and any messages on the current thread's message queue whose hwnd value is NULL (see MSG).
|
613
|
-
# Therefore if hWnd is NULL, both window messages and thread messages are processed.
|
614
|
-
# If hWnd is -1, PeekMessage retrieves only messages on the current thread's message queue whose hwnd
|
615
|
-
# value is NULL, that is, thread messages as posted by PostMessage (when the hWnd parameter is NULL) or
|
616
|
-
# PostThreadMessage.
|
617
|
-
# wMsgFilterMin:: [in] Specifies the value of the first message in the range of messages to be examined.
|
618
|
-
# Use WM_KEYFIRST to specify the first keyboard message or WM_MOUSEFIRST to specify the
|
619
|
-
# first mouse message. If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns all
|
620
|
-
# available messages (that is, no range filtering is performed).
|
621
|
-
# wMsgFilterMax:: [in] Specifies the value of the last message in the range of messages to be examined.
|
622
|
-
# Use WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the
|
623
|
-
# last mouse message.
|
624
|
-
# wRemoveMsg:: [in] Specifies how messages are handled. This parameter can be one of the following values.
|
625
|
-
# - PM_NOREMOVE - Messages are not removed from the queue after processing by PeekMessage.
|
626
|
-
# - PM_REMOVE - Messages are removed from the queue after processing by PeekMessage.
|
627
|
-
# You can optionally combine the value PM_NOYIELD with either PM_NOREMOVE or PM_REMOVE. This flag
|
628
|
-
# prevents the system from releasing any thread that is waiting for the caller to go idle (see
|
629
|
-
# WaitForInputIdle). By default, all message types are processed. To specify that only certain
|
630
|
-
# message should be processed, specify one or more of the following values.
|
631
|
-
# - PM_QS_INPUT - Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages.
|
632
|
-
# - PM_QS_PAINT - Windows 98/Me, Windows 2000/XP: Process paint messages.
|
633
|
-
# - PM_QS_POSTMESSAGE - Win 98/Me/2000/XP: Process all posted messages, including timers and hotkeys.
|
634
|
-
# - PM_QS_SENDMESSAGE - Windows 98/Me, Windows 2000/XP: Process all sent messages.
|
635
|
-
#
|
636
|
-
# *Returns*:: If a message is available, returns nonzero. If no messages are available, the return value is zero.
|
637
|
-
# ---
|
638
|
-
# *Remarks*:
|
639
|
-
# PeekMessage retrieves messages associated with the window identified by the hWnd parameter or any of
|
640
|
-
# its children as specified by the IsChild function, and within the range of message values given by the
|
641
|
-
# wMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low word in the
|
642
|
-
# wMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
|
643
|
-
#
|
644
|
-
# Note that PeekMessage always retrieves WM_QUIT messages, no matter which values you specify for
|
645
|
-
# wMsgFilterMin and wMsgFilterMax.
|
646
|
-
#
|
647
|
-
# During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows
|
648
|
-
# owned by the calling thread using the SendMessage, SendMessageCallback, SendMessageTimeout, or
|
649
|
-
# SendNotifyMessage function. Then the first queued message that matches the specified filter is
|
650
|
-
# retrieved. The system may also process internal events. If no filter is specified, messages are
|
651
|
-
# processed in the following order:
|
652
|
-
# 1. Sent messages
|
653
|
-
# 2. Posted messages
|
654
|
-
# 3. Input (hardware) messages and system internal events
|
655
|
-
# 4. Sent messages (again)
|
656
|
-
# 5. WM_PAINT messages
|
657
|
-
# 6. WM_TIMER messages
|
658
|
-
#
|
659
|
-
# To retrieve input messages before posted messages, use the wMsgFilterMin and wMsgFilterMax parameters.
|
660
|
-
#
|
661
|
-
# The PeekMessage function normally does not remove WM_PAINT messages from the queue. WM_PAINT messages
|
662
|
-
# remain in the queue until they are processed. However, if a WM_PAINT message has a NULL update region,
|
663
|
-
# PeekMessage does remove it from the queue.
|
664
|
-
#
|
665
|
-
# Windows XP: If a top-level window stops responding to messages for more than several seconds, the
|
666
|
-
# system considers the window to be not responding and replaces it with a ghost window that has the same
|
667
|
-
# z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even
|
668
|
-
# close the application. However, these are the only actions available because the application is
|
669
|
-
# actually not responding. When an application is being debugged, the system does not generate a ghost
|
670
|
-
# window.
|
671
|
-
# ---
|
672
|
-
# <b>Enhanced (snake_case) API: makes all args optional, returns *nil* if no message in queue,
|
673
|
-
# returns retrieved Msg (FFI structure) if there is message in queue</b>
|
674
|
-
#
|
675
|
-
# :call-seq:
|
676
|
-
# msg = peek_message([msg], [handle], [msg_filter_min], [msg_filter_max], [remove_msg])
|
677
|
-
#
|
678
|
-
function :PeekMessage, [:pointer, :HWND, :uint, :uint, :uint], :int8,
|
679
|
-
&->(api, msg=Msg.new, handle=0, msg_filter_min=0, msg_filter_max=0, remove_msg=PM_NOREMOVE){
|
680
|
-
res = api.call(msg, handle, msg_filter_min, msg_filter_max, remove_msg)
|
681
|
-
res == 0 ? nil : msg }
|
682
|
-
|
683
|
-
##
|
684
|
-
# The TranslateMessage function translates virtual-key messages into character messages. The character
|
685
|
-
# messages are posted to the calling thread's message queue, to be read the next time the thread calls
|
686
|
-
# the GetMessage or PeekMessage function.
|
687
|
-
#
|
688
|
-
# [*Syntax*] BOOL TranslateMessage( const MSG *lpMsg );
|
689
|
-
#
|
690
|
-
# lpMsg:: [in] Pointer to an MSG structure that contains message information retrieved from the calling
|
691
|
-
# thread's message queue by using the GetMessage or PeekMessage function.
|
692
|
-
#
|
693
|
-
# *Returns*:: If the message is translated (that is, a character message is posted to the thread's
|
694
|
-
# message queue), the return value is nonzero.
|
695
|
-
# If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the return value is
|
696
|
-
# nonzero, regardless of the translation.
|
697
|
-
# If the message is not translated (that is, a character message is not posted to the thread's
|
698
|
-
# message queue), the return value is zero.
|
699
|
-
# ---
|
700
|
-
# *Remarks*:
|
701
|
-
# The TranslateMessage function does not modify the message pointed to by the lpMsg parameter.
|
702
|
-
#
|
703
|
-
# WM_KEYDOWN and WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message. WM_SYSKEYDOWN and
|
704
|
-
# WM_SYSKEYUP combinations produce a WM_SYSCHAR or WM_SYSDEADCHAR message.
|
705
|
-
#
|
706
|
-
# TranslateMessage produces WM_CHAR messages only for keys that are mapped to ASCII characters by the
|
707
|
-
# keyboard driver.
|
708
|
-
#
|
709
|
-
# If applications process virtual-key messages for some other purpose, they should not call
|
710
|
-
# TranslateMessage. For instance, an application should not call TranslateMessage if the
|
711
|
-
# TranslateAccelerator function returns a nonzero value. Note that the application is responsible for
|
712
|
-
# retrieving and dispatching input messages to the dialog box. Most applications use the main message
|
713
|
-
# loop for this. However, to permit the user to move to and to select controls by using the keyboard,
|
714
|
-
# the application must call IsDialogMessage. For more information, see Dialog Box Keyboard Interface.
|
715
|
-
# ---
|
716
|
-
# <b>Enhanced (snake_case) API: returns true/false instead of nonzero/zero</b>
|
717
|
-
#
|
718
|
-
# :call-seq:
|
719
|
-
# success = translate_message(msg)
|
720
|
-
#
|
721
|
-
function :TranslateMessage, [:pointer], :int8, boolean: true
|
722
|
-
|
723
|
-
##
|
724
|
-
# The DispatchMessage function dispatches a message to a window procedure. It is typically used to
|
725
|
-
# dispatch a message retrieved by the GetMessage function.
|
726
|
-
#
|
727
|
-
# [*Syntax*] LRESULT DispatchMessage( const MSG *lpmsg );
|
728
|
-
#
|
729
|
-
# lpmsg:: [in] Pointer to an MSG structure that contains the message.
|
730
|
-
#
|
731
|
-
# *Returns*:: The return value specifies the value returned by the window procedure. Although its
|
732
|
-
# meaning depends on the message being dispatched, the return value generally is ignored.
|
733
|
-
# ---
|
734
|
-
# *Remarks*:
|
735
|
-
# The MSG structure must contain valid message values. If the lpmsg parameter points to a WM_TIMER
|
736
|
-
# message and the lParam parameter of the WM_TIMER message is not NULL, lParam points to a function that
|
737
|
-
# is called instead of the window procedure.
|
738
|
-
#
|
739
|
-
# Note that the application is responsible for retrieving and dispatching input messages to the dialog
|
740
|
-
# box. Most applications use the main message loop for this. However, to permit the user to move to and
|
741
|
-
# to select controls by using the keyboard, the application must call IsDialogMessage. For more
|
742
|
-
# information, see Dialog Box Keyboard Interface.
|
743
|
-
# ---
|
744
|
-
# <b>Enhanced (snake_case) API: </b>
|
745
|
-
#
|
746
|
-
# :call-seq:
|
747
|
-
# dispatch_message(msg)
|
748
|
-
#
|
749
|
-
function :DispatchMessage, [:pointer], :long
|
750
|
-
|
751
|
-
##
|
752
|
-
function :BroadcastSystemMessage, 'LPIIL', 'L'
|
753
|
-
|
754
|
-
##
|
755
|
-
try_function :BroadcastSystemMessageEx, 'LPILLP', 'L' # Windows XP or later
|
756
|
-
|
757
|
-
##
|
758
|
-
function :DefWindowProc, 'LLLL', 'L'
|
759
|
-
|
760
|
-
##
|
761
|
-
function :GetInputState, 'V', 'B'
|
762
|
-
|
763
|
-
##
|
764
|
-
function :GetMessageExtraInfo, 'V', 'L'
|
765
|
-
|
766
|
-
##
|
767
|
-
function :GetMessagePos, 'V', 'L'
|
768
|
-
|
769
|
-
##
|
770
|
-
function :GetMessageTime, 'V', 'L'
|
771
|
-
|
772
|
-
##
|
773
|
-
function :GetQueueStatus, 'I', 'L'
|
774
|
-
|
775
|
-
##
|
776
|
-
function :InSendMessage, 'V', 'B'
|
777
|
-
|
778
|
-
##
|
779
|
-
function :InSendMessageEx, 'L', 'L'
|
780
|
-
|
781
|
-
##
|
782
|
-
function :PostQuitMessage, 'I', 'V'
|
783
|
-
|
784
|
-
##
|
785
|
-
function :PostThreadMessage, 'LILL', 'B'
|
786
|
-
|
787
|
-
##
|
788
|
-
function :RegisterWindowMessage, 'P', 'I'
|
789
|
-
|
790
|
-
##
|
791
|
-
function :ReplyMessage, 'L', 'B'
|
792
|
-
|
793
|
-
##
|
794
|
-
function :SendMessageTimeout, 'LILLIIP', 'L'
|
795
|
-
|
796
|
-
##
|
797
|
-
function :SendNotifyMessage, 'LILLIIP', 'L'
|
798
|
-
|
799
|
-
##
|
800
|
-
function :SetMessageExtraInfo, 'L', 'L'
|
801
|
-
|
802
|
-
##
|
803
|
-
function :WaitMessage, 'V', 'B'
|
804
|
-
end
|
805
|
-
end
|
806
|
-
end
|
807
|
-
|
1
|
+
require 'win/library'
|
2
|
+
|
3
|
+
module Win
|
4
|
+
module Gui
|
5
|
+
# Contains constants and Win32API functions related to Windows messaging
|
6
|
+
#
|
7
|
+
# Below is a table of system-defined message prefixes:
|
8
|
+
#
|
9
|
+
# *Prefix*:: *Message* *category*
|
10
|
+
# ABM:: Application desktop toolbar
|
11
|
+
# BM:: Button control
|
12
|
+
# CB:: Combo box control
|
13
|
+
# CBEM:: Extended combo box control
|
14
|
+
# CDM:: Common dialog box
|
15
|
+
# DBT:: Device
|
16
|
+
# DL:: Drag list box
|
17
|
+
# DM:: Default push button control
|
18
|
+
# DTM:: Date and time picker control
|
19
|
+
# EM:: Edit control
|
20
|
+
# HDM:: Header control
|
21
|
+
# HKM:: Hot key control
|
22
|
+
# IPM:: IP address control
|
23
|
+
# LB:: List box control
|
24
|
+
# LVM:: List view control
|
25
|
+
# MCM:: Month calendar control
|
26
|
+
# PBM:: Progress bar
|
27
|
+
# PGM:: Pager control
|
28
|
+
# PSM:: Property sheet
|
29
|
+
# RB:: Rebar control
|
30
|
+
# SB:: Status bar window
|
31
|
+
# SBM:: Scroll bar control
|
32
|
+
# STM:: Static control
|
33
|
+
# TB:: Toolbar
|
34
|
+
# TBM:: Trackbar
|
35
|
+
# TCM:: Tab control
|
36
|
+
# TTM:: Tooltip control
|
37
|
+
# TVM:: Tree-view control
|
38
|
+
# UDM:: Up-down control
|
39
|
+
# WM:: General window
|
40
|
+
module Message
|
41
|
+
include Win::Library
|
42
|
+
|
43
|
+
# General window messages cover a wide range of information and requests, including messages for mouse and
|
44
|
+
# keyboard input, menu and dialog box input, window creation and management, and Dynamic Data Exchange (DDE).
|
45
|
+
# General window messages WM/WA:
|
46
|
+
|
47
|
+
#
|
48
|
+
WM_NULL = 0x0000
|
49
|
+
WA_INACTIVE = 0x0000
|
50
|
+
WM_CREATE = 0x0001
|
51
|
+
WA_ACTIVE = 0x0001
|
52
|
+
WM_DESTROY = 0x0002
|
53
|
+
WA_CLICKACTIVE = 0x0002
|
54
|
+
WM_MOVE = 0x0003
|
55
|
+
WM_SIZE = 0x0005
|
56
|
+
WM_ACTIVATE = 0x0006
|
57
|
+
WM_SETFOCUS = 0x0007
|
58
|
+
WM_KILLFOCUS = 0x0008
|
59
|
+
WM_ENABLE = 0x000A
|
60
|
+
WM_SETREDRAW = 0x000B
|
61
|
+
WM_SETTEXT = 0x000C
|
62
|
+
# Windows Message Get Text
|
63
|
+
WM_GETTEXT = 0x000D
|
64
|
+
WM_GETTEXTLENGTH = 0x000E
|
65
|
+
WM_PAINT = 0x000F
|
66
|
+
WM_CLOSE = 0x0010
|
67
|
+
WM_QUERYENDSESSION= 0x0011
|
68
|
+
WM_QUIT = 0x0012
|
69
|
+
WM_QUERYOPEN = 0x0013
|
70
|
+
WM_ERASEBKGND = 0x0014
|
71
|
+
WM_SYSCOLORCHANGE = 0x0015
|
72
|
+
WM_ENDSESSION = 0x0016
|
73
|
+
WM_SHOWWINDOW = 0x0018
|
74
|
+
WM_WININICHANGE = 0x001A
|
75
|
+
WM_SETTINGCHANGE = WM_WININICHANGE
|
76
|
+
WM_DEVMODECHANGE = 0x001B
|
77
|
+
WM_ACTIVATEAPP = 0x001C
|
78
|
+
WM_FONTCHANGE = 0x001D
|
79
|
+
WM_TIMECHANGE = 0x001E
|
80
|
+
WM_CANCELMODE = 0x001F
|
81
|
+
WM_SETCURSOR = 0x0020
|
82
|
+
WM_MOUSEACTIVATE = 0x0021
|
83
|
+
WM_CHILDACTIVATE = 0x0022
|
84
|
+
WM_QUEUESYNC = 0x0023
|
85
|
+
WM_GETMINMAXINFO = 0x0024
|
86
|
+
WM_PAINTICON = 0x0026
|
87
|
+
WM_ICONERASEBKGND = 0x0027
|
88
|
+
WM_NEXTDLGCTL = 0x0028
|
89
|
+
WM_SPOOLERSTATUS = 0x002A
|
90
|
+
WM_DRAWITEM = 0x002B
|
91
|
+
WM_MEASUREITEM = 0x002C
|
92
|
+
WM_DELETEITEM = 0x002D
|
93
|
+
WM_VKEYTOITEM = 0x002E
|
94
|
+
WM_CHARTOITEM = 0x002F
|
95
|
+
WM_SETFONT = 0x0030
|
96
|
+
WM_GETFONT = 0x0031
|
97
|
+
WM_SETHOTKEY = 0x0032
|
98
|
+
WM_GETHOTKEY = 0x0033
|
99
|
+
WM_QUERYDRAGICON = 0x0037
|
100
|
+
WM_COMPAREITEM = 0x0039
|
101
|
+
WM_COMPACTING = 0x0041
|
102
|
+
WM_COMMNOTIFY = 0x0044 # no longer supported
|
103
|
+
WM_WINDOWPOSCHANGING = 0x0046
|
104
|
+
WM_WINDOWPOSCHANGED = 0x0047
|
105
|
+
WM_POWER = 0x0048
|
106
|
+
WM_COPYDATA = 0x004A
|
107
|
+
WM_CANCELJOURNAL = 0x004B
|
108
|
+
WM_NOTIFY = 0x004E
|
109
|
+
WM_INPUTLANGCHANGEREQUEST = 0x0050
|
110
|
+
WM_INPUTLANGCHANGE = 0x0051
|
111
|
+
WM_TCARD = 0x0052
|
112
|
+
WM_HELP = 0x0053
|
113
|
+
WM_USERCHANGED = 0x0054
|
114
|
+
WM_NOTIFYFORMAT = 0x0055
|
115
|
+
WM_CONTEXTMENU = 0x007B
|
116
|
+
WM_STYLECHANGING = 0x007C
|
117
|
+
WM_STYLECHANGED = 0x007D
|
118
|
+
WM_DISPLAYCHANGE = 0x007E
|
119
|
+
WM_GETICON = 0x007F
|
120
|
+
WM_SETICON = 0x0080
|
121
|
+
WM_NCCREATE = 0x0081
|
122
|
+
WM_NCDESTROY = 0x0082
|
123
|
+
WM_NCCALCSIZE = 0x0083
|
124
|
+
WM_NCHITTEST = 0x0084
|
125
|
+
WM_NCPAINT = 0x0085
|
126
|
+
WM_NCACTIVATE = 0x0086
|
127
|
+
WM_GETDLGCODE = 0x0087
|
128
|
+
WM_SYNCPAINT = 0x0088
|
129
|
+
WM_NCMOUSEMOVE = 0x00A0
|
130
|
+
WM_NCLBUTTONDOWN = 0x00A1
|
131
|
+
WM_NCLBUTTONUP = 0x00A2
|
132
|
+
WM_NCLBUTTONDBLCLK = 0x00A3
|
133
|
+
WM_NCRBUTTONDOWN = 0x00A4
|
134
|
+
WM_NCRBUTTONUP = 0x00A5
|
135
|
+
WM_NCRBUTTONDBLCLK = 0x00A6
|
136
|
+
WM_NCMBUTTONDOWN = 0x00A7
|
137
|
+
WM_NCMBUTTONUP = 0x00A8
|
138
|
+
WM_NCMBUTTONDBLCLK = 0x00A9
|
139
|
+
WM_NCXBUTTONDOWN = 0x00AB
|
140
|
+
WM_NCXBUTTONUP = 0x00AC
|
141
|
+
WM_NCXBUTTONDBLCLK = 0x00AD
|
142
|
+
WM_INPUT = 0x00FF
|
143
|
+
WM_KEYFIRST = 0x0100
|
144
|
+
WM_KEYDOWN = 0x0100
|
145
|
+
WM_KEYUP = 0x0101
|
146
|
+
WM_CHAR = 0x0102
|
147
|
+
WM_DEADCHAR = 0x0103
|
148
|
+
WM_SYSKEYDOWN = 0x0104
|
149
|
+
WM_SYSKEYUP = 0x0105
|
150
|
+
WM_SYSCHAR = 0x0106
|
151
|
+
WM_SYSDEADCHAR = 0x0107
|
152
|
+
WM_UNICHAR = 0x0109
|
153
|
+
WM_IME_STARTCOMPOSITION = 0x010D
|
154
|
+
WM_IME_ENDCOMPOSITION = 0x010E
|
155
|
+
WM_IME_COMPOSITION = 0x010F
|
156
|
+
WM_IME_KEYLAST = 0x010F
|
157
|
+
WM_INITDIALOG = 0x0110
|
158
|
+
WM_COMMAND = 0x0111
|
159
|
+
# Windows Message Sys Command
|
160
|
+
WM_SYSCOMMAND = 0x0112
|
161
|
+
WM_TIMER = 0x0113
|
162
|
+
WM_HSCROLL = 0x0114
|
163
|
+
WM_VSCROLL = 0x0115
|
164
|
+
WM_INITMENU = 0x0116
|
165
|
+
WM_INITMENUPOPUP = 0x0117
|
166
|
+
WM_MENUSELECT = 0x011F
|
167
|
+
WM_MENUCHAR = 0x0120
|
168
|
+
WM_ENTERIDLE = 0x0121
|
169
|
+
WM_MENURBUTTONUP = 0x0122
|
170
|
+
WM_MENUDRAG = 0x0123
|
171
|
+
WM_MENUGETOBJECT = 0x0124
|
172
|
+
WM_UNINITMENUPOPUP = 0x0125
|
173
|
+
WM_MENUCOMMAND = 0x0126
|
174
|
+
WM_CHANGEUISTATE = 0x0127
|
175
|
+
WM_UPDATEUISTATE = 0x0128
|
176
|
+
WM_QUERYUISTATE = 0x0129
|
177
|
+
WM_CTLCOLORMSGBOX = 0x0132
|
178
|
+
WM_CTLCOLOREDIT = 0x0133
|
179
|
+
WM_CTLCOLORLISTBOX = 0x0134
|
180
|
+
WM_CTLCOLORBTN = 0x0135
|
181
|
+
WM_CTLCOLORDLG = 0x0136
|
182
|
+
WM_CTLCOLORSCROLLBAR = 0x0137
|
183
|
+
WM_CTLCOLORSTATIC = 0x0138
|
184
|
+
WM_MOUSEFIRST = 0x0200
|
185
|
+
WM_MOUSEMOVE = 0x0200
|
186
|
+
WM_LBUTTONDOWN = 0x0201
|
187
|
+
WM_LBUTTONUP = 0x0202
|
188
|
+
WM_LBUTTONDBLCLK = 0x0203
|
189
|
+
WM_RBUTTONDOWN = 0x0204
|
190
|
+
WM_RBUTTONUP = 0x0205
|
191
|
+
WM_RBUTTONDBLCLK = 0x0206
|
192
|
+
WM_MBUTTONDOWN = 0x0207
|
193
|
+
WM_MBUTTONUP = 0x0208
|
194
|
+
WM_MBUTTONDBLCLK = 0x0209
|
195
|
+
WM_MOUSEWHEEL = 0x020A
|
196
|
+
WM_XBUTTONDOWN = 0x020B
|
197
|
+
WM_XBUTTONUP = 0x020C
|
198
|
+
WM_XBUTTONDBLCLK = 0x020D
|
199
|
+
WM_MOUSELAST = 0x020D # Win2k or later
|
200
|
+
WM_PARENTNOTIFY = 0x0210
|
201
|
+
WM_ENTERMENULOOP = 0x0211
|
202
|
+
WM_EXITMENULOOP = 0x0212
|
203
|
+
WM_NEXTMENU = 0x0213
|
204
|
+
WM_SIZING = 0x0214
|
205
|
+
WM_CAPTURECHANGED = 0x0215
|
206
|
+
WM_MOVING = 0x0216
|
207
|
+
WM_POWERBROADCAST = 0x0218
|
208
|
+
WM_DEVICECHANGE = 0x0219
|
209
|
+
WM_MDICREATE = 0x0220
|
210
|
+
WM_MDIDESTROY = 0x0221
|
211
|
+
WM_MDIACTIVATE = 0x0222
|
212
|
+
WM_MDIRESTORE = 0x0223
|
213
|
+
WM_MDINEXT = 0x0224
|
214
|
+
WM_MDIMAXIMIZE = 0x0225
|
215
|
+
WM_MDITILE = 0x0226
|
216
|
+
WM_MDICASCADE = 0x0227
|
217
|
+
WM_MDIICONARRANGE = 0x0228
|
218
|
+
WM_MDIGETACTIVE = 0x0229
|
219
|
+
WM_MDISETMENU = 0x0230
|
220
|
+
WM_ENTERSIZEMOVE = 0x0231
|
221
|
+
WM_EXITSIZEMOVE = 0x0232
|
222
|
+
WM_DROPFILES = 0x0233
|
223
|
+
WM_MDIREFRESHMENU = 0x0234
|
224
|
+
WM_IME_SETCONTEXT = 0x0281
|
225
|
+
WM_IME_NOTIFY = 0x0282
|
226
|
+
WM_IME_CONTROL = 0x0283
|
227
|
+
WM_IME_COMPOSITIONFULL = 0x0284
|
228
|
+
WM_IME_SELECT = 0x0285
|
229
|
+
WM_IME_CHAR = 0x0286
|
230
|
+
WM_IME_REQUEST = 0x0288
|
231
|
+
WM_IME_KEYDOWN = 0x0290
|
232
|
+
WM_IME_KEYUP = 0x0291
|
233
|
+
WM_MOUSEHOVER = 0x02A1
|
234
|
+
WM_MOUSELEAVE = 0x02A3
|
235
|
+
WM_NCMOUSEHOVER = 0x02A0
|
236
|
+
WM_NCMOUSELEAVE = 0x02A2
|
237
|
+
WM_WTSSESSION_CHANGE = 0x02B1
|
238
|
+
WM_TABLET_FIRST = 0x02c0
|
239
|
+
WM_TABLET_LAST = 0x02df
|
240
|
+
WM_CUT = 0x0300
|
241
|
+
WM_COPY = 0x0301
|
242
|
+
WM_PASTE = 0x0302
|
243
|
+
WM_CLEAR = 0x0303
|
244
|
+
WM_UNDO = 0x0304
|
245
|
+
WM_RENDERFORMAT = 0x0305
|
246
|
+
WM_RENDERALLFORMATS = 0x0306
|
247
|
+
WM_DESTROYCLIPBOARD = 0x0307
|
248
|
+
WM_DRAWCLIPBOARD = 0x0308
|
249
|
+
WM_PAINTCLIPBOARD = 0x0309
|
250
|
+
WM_VSCROLLCLIPBOARD = 0x030A
|
251
|
+
WM_SIZECLIPBOARD = 0x030B
|
252
|
+
WM_ASKCBFORMATNAME = 0x030C
|
253
|
+
WM_CHANGECBCHAIN = 0x030D
|
254
|
+
WM_HSCROLLCLIPBOARD = 0x030E
|
255
|
+
WM_QUERYNEWPALETTE = 0x030F
|
256
|
+
WM_PALETTEISCHANGING = 0x0310
|
257
|
+
WM_PALETTECHANGED = 0x0311
|
258
|
+
WM_HOTKEY = 0x0312
|
259
|
+
WM_PRINT = 0x0317
|
260
|
+
WM_PRINTCLIENT = 0x0318
|
261
|
+
WM_APPCOMMAND = 0x0319
|
262
|
+
WM_THEMECHANGED = 0x031A
|
263
|
+
WM_HANDHELDFIRST = 0x0358
|
264
|
+
WM_HANDHELDLAST = 0x035F
|
265
|
+
WM_AFXFIRST = 0x0360
|
266
|
+
WM_AFXLAST = 0x037F
|
267
|
+
WM_PENWINFIRST = 0x0380
|
268
|
+
WM_PENWINLAST = 0x038F
|
269
|
+
# User-specific (non-reserved) messages above this one (WM_USER+1, etc...)
|
270
|
+
WM_USER = 0x0400
|
271
|
+
# App-specific (non-reserved) messages above this one (WM_App+1, etc...)
|
272
|
+
WM_APP = 0x8000
|
273
|
+
|
274
|
+
# Sys Commands (wParam to use with WM_SYSCOMMAND message):
|
275
|
+
|
276
|
+
#
|
277
|
+
SC_SIZE = 0xF000
|
278
|
+
SC_MOVE = 0xF010
|
279
|
+
SC_MINIMIZE = 0xF020
|
280
|
+
SC_MAXIMIZE = 0xF030
|
281
|
+
SC_NEXTWINDOW = 0xF040
|
282
|
+
SC_PREVWINDOW = 0xF050
|
283
|
+
# Sys Command Close
|
284
|
+
SC_CLOSE = 0xF060
|
285
|
+
SC_VSCROLL = 0xF070
|
286
|
+
SC_HSCROLL = 0xF080
|
287
|
+
SC_MOUSEMENU = 0xF090
|
288
|
+
SC_KEYMENU = 0xF100
|
289
|
+
SC_ARRANGE = 0xF110
|
290
|
+
SC_RESTORE = 0xF120
|
291
|
+
SC_TASKLIST = 0xF130
|
292
|
+
SC_SCREENSAVE = 0xF140
|
293
|
+
SC_HOTKEY = 0xF150
|
294
|
+
SC_DEFAULT = 0xF160
|
295
|
+
SC_MONITORPOWER = 0xF170
|
296
|
+
SC_CONTEXTHELP = 0xF180
|
297
|
+
|
298
|
+
# Queue status flags:
|
299
|
+
|
300
|
+
#
|
301
|
+
QS_KEY = 0x0001
|
302
|
+
QS_MOUSEMOVE = 0x0002
|
303
|
+
QS_MOUSEBUTTON = 0x0004
|
304
|
+
QS_MOUSE = (QS_MOUSEMOVE | QS_MOUSEBUTTON)
|
305
|
+
QS_POSTMESSAGE = 0x0008
|
306
|
+
QS_TIMER = 0x0010
|
307
|
+
QS_PAINT = 0x0020
|
308
|
+
QS_SENDMESSAGE = 0x0040
|
309
|
+
QS_HOTKEY = 0x0080
|
310
|
+
QS_ALLPOSTMESSAGE= 0x0100
|
311
|
+
QS_RAWINPUT = 0x0400
|
312
|
+
QS_INPUT = (QS_MOUSE | QS_KEY | QS_RAWINPUT)
|
313
|
+
QS_ALLEVENTS = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY)
|
314
|
+
QS_ALLINPUT = (QS_ALLEVENTS | QS_SENDMESSAGE)
|
315
|
+
QS_SMRESULT = 0x8000
|
316
|
+
|
317
|
+
# PeekMessage flags:
|
318
|
+
|
319
|
+
# Messages are not removed from the queue after processing by PeekMessage (default)
|
320
|
+
PM_NOREMOVE = 0x0000
|
321
|
+
# Messages are removed from the queue after processing by PeekMessage.
|
322
|
+
PM_REMOVE = 0x0001
|
323
|
+
# You can optionally combine the value PM_NOYIELD with either PM_NOREMOVE or PM_REMOVE. This flag
|
324
|
+
# prevents the system from releasing any thread that is waiting for the caller to go idle (see WaitForInputIdle).
|
325
|
+
PM_NOYIELD = 0x0002
|
326
|
+
# By default, all message types are processed. To specify that only certain
|
327
|
+
# message should be processed, specify one or more of the following values.
|
328
|
+
# PM_QS_INPUT - Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages.
|
329
|
+
PM_QS_INPUT = (QS_INPUT << 16)
|
330
|
+
# PM_QS_POSTMESSAGE - Win 98/Me/2000/XP: Process all posted messages, including timers and hotkeys.
|
331
|
+
PM_QS_POSTMESSAGE= ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16)
|
332
|
+
# PM_QS_PAINT - Windows 98/Me, Windows 2000/XP: Process paint messages.
|
333
|
+
PM_QS_PAINT = (QS_PAINT << 16)
|
334
|
+
# PM_QS_SENDMESSAGE - Windows 98/Me, Windows 2000/XP: Process all sent messages.
|
335
|
+
PM_QS_SENDMESSAGE= (QS_SENDMESSAGE << 16)
|
336
|
+
|
337
|
+
|
338
|
+
##
|
339
|
+
# The SendAsyncProc function is an application-defined callback function used with the SendMessageCallback
|
340
|
+
# function. The system passes the message to the callback function after passing the message to the
|
341
|
+
# destination window procedure. SendAsyncProc is a placeholder for the application-defined function name.
|
342
|
+
#
|
343
|
+
# [*Syntax*] VOID SendAsyncProc( HWND hwnd, UINT uMsg, ULONG_PTR dwData, LRESULT lResult );
|
344
|
+
#
|
345
|
+
# hwnd:: [in] Handle to the window whose window procedure received the message. If SendMessageCallback
|
346
|
+
# function was called with its hwnd parameter set to HWND_BROADCAST, the system calls the
|
347
|
+
# SendAsyncProc function once for each top-level window.
|
348
|
+
# uMsg:: [in] Specifies the message.
|
349
|
+
# dwData:: [in] Specifies an application-defined value sent from the SendMessageCallback function.
|
350
|
+
# lResult:: [in] Specifies the result of the message processing. This value depends on the message.
|
351
|
+
#
|
352
|
+
# :call-seq:
|
353
|
+
# SendAsyncProc callback block: {|handle, msg, data, l_result| your callback code }
|
354
|
+
#
|
355
|
+
callback :SendAsyncProc, [:HWND, :uint, :ulong, :long], :void
|
356
|
+
|
357
|
+
##
|
358
|
+
# The SendMessageCallback function sends the specified message to a window or windows. It calls the window
|
359
|
+
# procedure for the specified window and returns immediately. After the window procedure processes the message,
|
360
|
+
# the system calls the specified callback function, passing the result of the message processing and an
|
361
|
+
# application-defined value to the callback function.
|
362
|
+
#
|
363
|
+
# [*Syntax*] BOOL SendMessageCallback( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
364
|
+
# SENDASYNCPROC lpCallBack, ULONG_PTR dwData);
|
365
|
+
#
|
366
|
+
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
367
|
+
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
368
|
+
# invisible, unowned, overlapped and pop-up windows; but the message is not sent to child windows.
|
369
|
+
# Msg:: [in] Specifies the message to be sent.
|
370
|
+
# wParam:: [in] Specifies additional message-specific information.
|
371
|
+
# lParam:: [in] Specifies additional message-specific information.
|
372
|
+
# lpCallBack:: [in] Pointer to a callback function that the system calls after the window procedure processes
|
373
|
+
# the message. For more information, see SendAsyncProc. If hWnd is HWND_BROADCAST, the system calls
|
374
|
+
# SendAsyncProc callback function once for each top-level window.
|
375
|
+
# dwData:: [in] Specifies an application-defined value to be sent to the callback function pointed to by
|
376
|
+
# the lpCallBack parameter.
|
377
|
+
# *Returns*:: Nonzero if the function succeeds, zero if it fails. For extended error info, call GetLastError.
|
378
|
+
# ---
|
379
|
+
# *Remarks*:
|
380
|
+
# - If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage,
|
381
|
+
# SendNotifyMessage, and SendMessageCallback), its message parameters cannot include pointers. Otherwise,
|
382
|
+
# the operation will fail. The functions will return before the receiving thread has had a chance
|
383
|
+
# to process the message and the sender will free the memory before it is used.
|
384
|
+
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
385
|
+
# to obtain a unique message for inter-application communication.
|
386
|
+
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send
|
387
|
+
# messages (>= WM_USER) to another process, you must do custom marshalling.
|
388
|
+
# - The callback function is called only when the thread that called SendMessageCallback also calls GetMessage,
|
389
|
+
# PeekMessage, or WaitMessage.
|
390
|
+
#
|
391
|
+
# :call-seq:
|
392
|
+
# success = send_message_callback(handle, msg, w_param, l_param, [data=0])
|
393
|
+
# {|handle, msg, data, l_result| callback code }
|
394
|
+
#
|
395
|
+
function :SendMessageCallback, [:HWND, :uint, :uint, :pointer, :SendAsyncProc, :ulong], :int8, boolean: true,
|
396
|
+
&->(api, handle, msg, w_param, l_param, data=0, &block){
|
397
|
+
api.call(handle, msg, w_param, l_param, block, data)}
|
398
|
+
|
399
|
+
|
400
|
+
##
|
401
|
+
# The PostMessage function places (posts) a message in the message queue associated with the thread that
|
402
|
+
# created the specified window and returns without waiting for the thread to process the message.
|
403
|
+
# To post a message in the message queue associate with a thread, use the PostThreadMessage function.
|
404
|
+
#
|
405
|
+
# [*Syntax*] BOOL PostMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
406
|
+
#
|
407
|
+
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
408
|
+
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
409
|
+
# invisible unowned windows, overlapped windows, and pop-up windows; but the message is not posted to
|
410
|
+
# child windows. If it is NULL, the function behaves like a call to PostThreadMessage()
|
411
|
+
# with the dwThreadId parameter set to the identifier of the current thread.
|
412
|
+
# Msg:: [in] Specifies the message to be posted.
|
413
|
+
# wParam:: [in] Specifies additional message-specific information.
|
414
|
+
# lParam:: [in] Specifies additional message-specific information.
|
415
|
+
#
|
416
|
+
# *Returns*:: Nonzero if the function succeeds, zero if it fails. For extended error info, call GetLastError.
|
417
|
+
# ---
|
418
|
+
# *Remarks*:
|
419
|
+
# - Microsoft Windows Vista and later. When a message is blocked by UIPI the last error, retrieved with
|
420
|
+
# GetLastError, is set to 5 (access denied). Messages in a message queue are retrieved by calls to the
|
421
|
+
# GetMessage or PeekMessage function.
|
422
|
+
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
423
|
+
# to obtain a unique message for inter-application communication.
|
424
|
+
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other
|
425
|
+
# messages (those >= WM_USER) to another process, you must do custom marshalling.
|
426
|
+
# - If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage,
|
427
|
+
# SendNotifyMessage, and SendMessageCallback), its message parameters cannot include pointers. Otherwise,
|
428
|
+
# the operation will fail. The functions will return before the receiving thread has had a chance to
|
429
|
+
# process the message and the sender will free the memory before it is used. Use the PostQuitMessage
|
430
|
+
# instead of PostMessage to post WM_QUIT message.
|
431
|
+
#
|
432
|
+
#:call-seq:
|
433
|
+
# success = post_message(handle, msg, w_param, l_param)
|
434
|
+
#
|
435
|
+
function :PostMessage, [:ulong, :uint, :uint, :pointer], :int, boolean: true
|
436
|
+
|
437
|
+
##
|
438
|
+
# The SendMessage function sends the specified message to a window or windows. It calls the window procedure for
|
439
|
+
# the specified window and does not return until the window procedure has processed the message.
|
440
|
+
#
|
441
|
+
# To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a
|
442
|
+
# message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
|
443
|
+
#
|
444
|
+
#
|
445
|
+
# [*Syntax*] LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
|
446
|
+
#
|
447
|
+
# hWnd:: [in] Handle to the window whose window procedure will receive the message. If this parameter is
|
448
|
+
# HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or
|
449
|
+
# invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to
|
450
|
+
# child windows.
|
451
|
+
# Microsoft Windows Vista and later. Message sending is subject to User Interface Privilege Isolation
|
452
|
+
# (UIPI). The thread of a process can send messages only to message queues of threads in processes of
|
453
|
+
# lesser or equal integrity level.
|
454
|
+
# Msg:: [in] Specifies the message to be sent.
|
455
|
+
# wParam:: [in] Specifies additional message-specific information.
|
456
|
+
# lParam:: [in/out?] Specifies additional message-specific information.
|
457
|
+
#
|
458
|
+
# *Return*:: The return value specifies the result of the message processing; it depends on the message sent.
|
459
|
+
# ---
|
460
|
+
# *Remarks*:
|
461
|
+
# - Microsoft Windows Vista and later. When a message is blocked by UIPI the last error, retrieved with
|
462
|
+
# GetLastError, is set to 5 (access denied).
|
463
|
+
# - Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function
|
464
|
+
# to obtain a unique message for inter-application communication.
|
465
|
+
# - The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other
|
466
|
+
# messages (those >= WM_USER) to another process, you must do custom marshalling.
|
467
|
+
# - If the specified window was created by the calling thread, the window procedure is called immediately as
|
468
|
+
# a subroutine. If the specified window was created by a different thread, the system switches to that thread
|
469
|
+
# and calls the appropriate window procedure. Messages sent between threads are processed only when the
|
470
|
+
# receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread
|
471
|
+
# processes the message. However, the sending thread will process incoming nonqueued messages while waiting
|
472
|
+
# for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more
|
473
|
+
# information on nonqueued messages, see Nonqueued Messages.
|
474
|
+
#
|
475
|
+
#:call-seq:
|
476
|
+
# send_message(handle, msg, w_param, l_param)
|
477
|
+
#
|
478
|
+
function :SendMessage, [:ulong, :uint, :uint, :pointer], :int # LPARAM different from PostMessage!
|
479
|
+
|
480
|
+
# The MSG structure contains message information from a thread's message queue.
|
481
|
+
#
|
482
|
+
# typedef struct {
|
483
|
+
# HWND hwnd;
|
484
|
+
# UINT message;
|
485
|
+
# WPARAM wParam;
|
486
|
+
# LPARAM lParam;
|
487
|
+
# DWORD time;
|
488
|
+
# POINT pt;
|
489
|
+
# } MSG, *PMSG;
|
490
|
+
#
|
491
|
+
# hwnd:: Handle to the window whose window procedure receives the message. NULL when the message is a thread message.
|
492
|
+
# message:: Message identifier. Applications can only use the low word; the high word is reserved by the system.
|
493
|
+
# wParam:: Additional info about the message. Exact meaning depends on the value of the message member.
|
494
|
+
# lParam:: Additional info about the message. Exact meaning depends on the value of the message member.
|
495
|
+
# time:: Specifies the time at which the message was posted.
|
496
|
+
# pt:: POINT structure - the cursor position, in screen coordinates, when the message was posted.
|
497
|
+
# (in my definition, it is changed to two longs: x, y - has the same effect, just avoid nested structs)
|
498
|
+
class Msg < FFI::Struct
|
499
|
+
layout :hwnd, :ulong,
|
500
|
+
:message, :uint,
|
501
|
+
:w_param, :long,
|
502
|
+
:l_param, :pointer,
|
503
|
+
:time, :uint32,
|
504
|
+
:x, :long,
|
505
|
+
:y, :long
|
506
|
+
end
|
507
|
+
|
508
|
+
##
|
509
|
+
# The GetMessage function retrieves a message from the calling thread's message queue. The function
|
510
|
+
# dispatches incoming sent messages until a posted message is available for retrieval.
|
511
|
+
# Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
|
512
|
+
#
|
513
|
+
# [*Syntax*] BOOL GetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax );
|
514
|
+
#
|
515
|
+
# lpMsg:: [out] Pointer to an MSG structure that receives message information from the thread's message
|
516
|
+
# queue.
|
517
|
+
# hWnd:: [in] Handle to the window whose messages are to be retrieved. The window must belong to the current
|
518
|
+
# thread. If hWnd is NULL, GetMessage retrieves messages for any window that belongs to the current
|
519
|
+
# thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG
|
520
|
+
# structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.
|
521
|
+
# If hWnd is -1, GetMessage retrieves only messages on the current thread's message queue whose hwnd
|
522
|
+
# value is NULL, that is, thread messages as posted by PostMessage (when the hWnd parameter is NULL) or
|
523
|
+
# PostThreadMessage.
|
524
|
+
# wMsgFilterMin:: [in] Specifies the integer value of the lowest message value to be retrieved. Use WM_KEYFIRST
|
525
|
+
# to specify the first keyboard message or WM_MOUSEFIRST to specify the first mouse message.
|
526
|
+
# Windows XP: Use WM_INPUT here and in wMsgFilterMax to specify only the WM_INPUT messages.
|
527
|
+
# If wMsgFilterMin and wMsgFilterMax are both zero, GetMessage returns all available messages
|
528
|
+
# (that is, no range filtering is performed).
|
529
|
+
# wMsgFilterMax:: [in] Specifies the integer value of the highest message value to be retrieved. Use
|
530
|
+
# WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the last
|
531
|
+
# mouse message.
|
532
|
+
#
|
533
|
+
# *Returns*:: If the function retrieves a message other than WM_QUIT, the return value is nonzero.
|
534
|
+
# If the function retrieves the WM_QUIT message, the return value is zero.
|
535
|
+
# If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid
|
536
|
+
# window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
|
537
|
+
# *Warning*
|
538
|
+
# Because the return value can be nonzero, zero, or -1, avoid code like this:
|
539
|
+
# while (GetMessage( lpMsg, hWnd, 0, 0)) ...
|
540
|
+
# The possibility of a -1 return value means that such code can lead to fatal application errors.
|
541
|
+
# Instead, use code like this:
|
542
|
+
# while( (bRet = GetMessage( msg, hWnd, 0, 0 )) != 0)
|
543
|
+
# if (bRet == -1)
|
544
|
+
# // handle the error and possibly exit
|
545
|
+
# else
|
546
|
+
# TranslateMessage(msg);
|
547
|
+
# DispatchMessage(msg);
|
548
|
+
# end
|
549
|
+
# end
|
550
|
+
# ---
|
551
|
+
# *Remarks*:
|
552
|
+
# An application typically uses the return value to determine whether to end the main message loop and
|
553
|
+
# exit the program.
|
554
|
+
#
|
555
|
+
# The GetMessage function retrieves messages associated with the window identified by the hWnd parameter
|
556
|
+
# or any of its children, as specified by the IsChild function, and within the range of message values
|
557
|
+
# given by the wMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low
|
558
|
+
# word in the wMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
|
559
|
+
# Note that GetMessage always retrieves WM_QUIT messages, no matter which values you specify for
|
560
|
+
# wMsgFilterMin and wMsgFilterMax.
|
561
|
+
#
|
562
|
+
# During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows
|
563
|
+
# owned by the calling thread using the SendMessage, SendMessageCallback, SendMessageTimeout, or
|
564
|
+
# SendNotifyMessage function. Then the first queued message that matches the specified filter is
|
565
|
+
# retrieved. The system may also process internal events. If no filter is specified, messages are
|
566
|
+
# processed in the following order:
|
567
|
+
# 1. Sent messages
|
568
|
+
# 2. Posted messages
|
569
|
+
# 3. Input (hardware) messages and system internal events
|
570
|
+
# 4. Sent messages (again)
|
571
|
+
# 5. WM_PAINT messages
|
572
|
+
# 6. WM_TIMER messages
|
573
|
+
#
|
574
|
+
# To retrieve input messages before posted messages, use the wMsgFilterMin and wMsgFilterMax parameters.
|
575
|
+
# GetMessage does not remove WM_PAINT messages from the queue. The messages remain in the queue until
|
576
|
+
# processed.
|
577
|
+
#
|
578
|
+
# Windows XP: If a top-level window stops responding to messages for more than several seconds, the
|
579
|
+
# system considers the window to be not responding and replaces it with a ghost window that has the same
|
580
|
+
# z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even
|
581
|
+
# close the application. However, these are the only actions available because the application is
|
582
|
+
# actually not responding. When in the debugger mode, the system does not generate a ghost window.
|
583
|
+
# ---
|
584
|
+
# <b>Enhanced (snake_case) API: makes all args optional, returns: *false* if WM_QUIT was posted,
|
585
|
+
# *nil* if error was encountered, and retrieved Msg (FFI structure) in all other cases </b>
|
586
|
+
#
|
587
|
+
# :call-seq:
|
588
|
+
# msg = get_message([msg], [handle=0], [msg_filter_min=0], [msg_filter_max=0])
|
589
|
+
#
|
590
|
+
function :GetMessage, [:pointer, :HWND, :uint, :uint], :int8,
|
591
|
+
&->(api, msg=Msg.new, handle=0, msg_filter_min=0, msg_filter_max=0){
|
592
|
+
case api.call(msg, handle, msg_filter_min, msg_filter_max)
|
593
|
+
when 0
|
594
|
+
false
|
595
|
+
when -1
|
596
|
+
nil
|
597
|
+
else
|
598
|
+
msg
|
599
|
+
end }
|
600
|
+
# weird lambda literal instead of block is needed because RDoc goes crazy if block is attached to meta-definition
|
601
|
+
|
602
|
+
##
|
603
|
+
# The PeekMessage function dispatches incoming sent messages, checks the thread message queue for a
|
604
|
+
# posted message, and retrieves the message (if any exist).
|
605
|
+
#
|
606
|
+
# [*Syntax*] BOOL PeekMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
|
607
|
+
# UINT wRemoveMsg );
|
608
|
+
#
|
609
|
+
# lpMsg:: [out] Pointer to an MSG structure that receives message information.
|
610
|
+
# hWnd:: [in] Handle to the window whose messages are to be retrieved. The window must belong to the current
|
611
|
+
# thread. If hWnd is NULL, PeekMessage retrieves messages for any window that belongs to the current
|
612
|
+
# thread, and any messages on the current thread's message queue whose hwnd value is NULL (see MSG).
|
613
|
+
# Therefore if hWnd is NULL, both window messages and thread messages are processed.
|
614
|
+
# If hWnd is -1, PeekMessage retrieves only messages on the current thread's message queue whose hwnd
|
615
|
+
# value is NULL, that is, thread messages as posted by PostMessage (when the hWnd parameter is NULL) or
|
616
|
+
# PostThreadMessage.
|
617
|
+
# wMsgFilterMin:: [in] Specifies the value of the first message in the range of messages to be examined.
|
618
|
+
# Use WM_KEYFIRST to specify the first keyboard message or WM_MOUSEFIRST to specify the
|
619
|
+
# first mouse message. If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns all
|
620
|
+
# available messages (that is, no range filtering is performed).
|
621
|
+
# wMsgFilterMax:: [in] Specifies the value of the last message in the range of messages to be examined.
|
622
|
+
# Use WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the
|
623
|
+
# last mouse message.
|
624
|
+
# wRemoveMsg:: [in] Specifies how messages are handled. This parameter can be one of the following values.
|
625
|
+
# - PM_NOREMOVE - Messages are not removed from the queue after processing by PeekMessage.
|
626
|
+
# - PM_REMOVE - Messages are removed from the queue after processing by PeekMessage.
|
627
|
+
# You can optionally combine the value PM_NOYIELD with either PM_NOREMOVE or PM_REMOVE. This flag
|
628
|
+
# prevents the system from releasing any thread that is waiting for the caller to go idle (see
|
629
|
+
# WaitForInputIdle). By default, all message types are processed. To specify that only certain
|
630
|
+
# message should be processed, specify one or more of the following values.
|
631
|
+
# - PM_QS_INPUT - Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages.
|
632
|
+
# - PM_QS_PAINT - Windows 98/Me, Windows 2000/XP: Process paint messages.
|
633
|
+
# - PM_QS_POSTMESSAGE - Win 98/Me/2000/XP: Process all posted messages, including timers and hotkeys.
|
634
|
+
# - PM_QS_SENDMESSAGE - Windows 98/Me, Windows 2000/XP: Process all sent messages.
|
635
|
+
#
|
636
|
+
# *Returns*:: If a message is available, returns nonzero. If no messages are available, the return value is zero.
|
637
|
+
# ---
|
638
|
+
# *Remarks*:
|
639
|
+
# PeekMessage retrieves messages associated with the window identified by the hWnd parameter or any of
|
640
|
+
# its children as specified by the IsChild function, and within the range of message values given by the
|
641
|
+
# wMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low word in the
|
642
|
+
# wMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
|
643
|
+
#
|
644
|
+
# Note that PeekMessage always retrieves WM_QUIT messages, no matter which values you specify for
|
645
|
+
# wMsgFilterMin and wMsgFilterMax.
|
646
|
+
#
|
647
|
+
# During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows
|
648
|
+
# owned by the calling thread using the SendMessage, SendMessageCallback, SendMessageTimeout, or
|
649
|
+
# SendNotifyMessage function. Then the first queued message that matches the specified filter is
|
650
|
+
# retrieved. The system may also process internal events. If no filter is specified, messages are
|
651
|
+
# processed in the following order:
|
652
|
+
# 1. Sent messages
|
653
|
+
# 2. Posted messages
|
654
|
+
# 3. Input (hardware) messages and system internal events
|
655
|
+
# 4. Sent messages (again)
|
656
|
+
# 5. WM_PAINT messages
|
657
|
+
# 6. WM_TIMER messages
|
658
|
+
#
|
659
|
+
# To retrieve input messages before posted messages, use the wMsgFilterMin and wMsgFilterMax parameters.
|
660
|
+
#
|
661
|
+
# The PeekMessage function normally does not remove WM_PAINT messages from the queue. WM_PAINT messages
|
662
|
+
# remain in the queue until they are processed. However, if a WM_PAINT message has a NULL update region,
|
663
|
+
# PeekMessage does remove it from the queue.
|
664
|
+
#
|
665
|
+
# Windows XP: If a top-level window stops responding to messages for more than several seconds, the
|
666
|
+
# system considers the window to be not responding and replaces it with a ghost window that has the same
|
667
|
+
# z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even
|
668
|
+
# close the application. However, these are the only actions available because the application is
|
669
|
+
# actually not responding. When an application is being debugged, the system does not generate a ghost
|
670
|
+
# window.
|
671
|
+
# ---
|
672
|
+
# <b>Enhanced (snake_case) API: makes all args optional, returns *nil* if no message in queue,
|
673
|
+
# returns retrieved Msg (FFI structure) if there is message in queue</b>
|
674
|
+
#
|
675
|
+
# :call-seq:
|
676
|
+
# msg = peek_message([msg], [handle], [msg_filter_min], [msg_filter_max], [remove_msg])
|
677
|
+
#
|
678
|
+
function :PeekMessage, [:pointer, :HWND, :uint, :uint, :uint], :int8,
|
679
|
+
&->(api, msg=Msg.new, handle=0, msg_filter_min=0, msg_filter_max=0, remove_msg=PM_NOREMOVE){
|
680
|
+
res = api.call(msg, handle, msg_filter_min, msg_filter_max, remove_msg)
|
681
|
+
res == 0 ? nil : msg }
|
682
|
+
|
683
|
+
##
|
684
|
+
# The TranslateMessage function translates virtual-key messages into character messages. The character
|
685
|
+
# messages are posted to the calling thread's message queue, to be read the next time the thread calls
|
686
|
+
# the GetMessage or PeekMessage function.
|
687
|
+
#
|
688
|
+
# [*Syntax*] BOOL TranslateMessage( const MSG *lpMsg );
|
689
|
+
#
|
690
|
+
# lpMsg:: [in] Pointer to an MSG structure that contains message information retrieved from the calling
|
691
|
+
# thread's message queue by using the GetMessage or PeekMessage function.
|
692
|
+
#
|
693
|
+
# *Returns*:: If the message is translated (that is, a character message is posted to the thread's
|
694
|
+
# message queue), the return value is nonzero.
|
695
|
+
# If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the return value is
|
696
|
+
# nonzero, regardless of the translation.
|
697
|
+
# If the message is not translated (that is, a character message is not posted to the thread's
|
698
|
+
# message queue), the return value is zero.
|
699
|
+
# ---
|
700
|
+
# *Remarks*:
|
701
|
+
# The TranslateMessage function does not modify the message pointed to by the lpMsg parameter.
|
702
|
+
#
|
703
|
+
# WM_KEYDOWN and WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message. WM_SYSKEYDOWN and
|
704
|
+
# WM_SYSKEYUP combinations produce a WM_SYSCHAR or WM_SYSDEADCHAR message.
|
705
|
+
#
|
706
|
+
# TranslateMessage produces WM_CHAR messages only for keys that are mapped to ASCII characters by the
|
707
|
+
# keyboard driver.
|
708
|
+
#
|
709
|
+
# If applications process virtual-key messages for some other purpose, they should not call
|
710
|
+
# TranslateMessage. For instance, an application should not call TranslateMessage if the
|
711
|
+
# TranslateAccelerator function returns a nonzero value. Note that the application is responsible for
|
712
|
+
# retrieving and dispatching input messages to the dialog box. Most applications use the main message
|
713
|
+
# loop for this. However, to permit the user to move to and to select controls by using the keyboard,
|
714
|
+
# the application must call IsDialogMessage. For more information, see Dialog Box Keyboard Interface.
|
715
|
+
# ---
|
716
|
+
# <b>Enhanced (snake_case) API: returns true/false instead of nonzero/zero</b>
|
717
|
+
#
|
718
|
+
# :call-seq:
|
719
|
+
# success = translate_message(msg)
|
720
|
+
#
|
721
|
+
function :TranslateMessage, [:pointer], :int8, boolean: true
|
722
|
+
|
723
|
+
##
|
724
|
+
# The DispatchMessage function dispatches a message to a window procedure. It is typically used to
|
725
|
+
# dispatch a message retrieved by the GetMessage function.
|
726
|
+
#
|
727
|
+
# [*Syntax*] LRESULT DispatchMessage( const MSG *lpmsg );
|
728
|
+
#
|
729
|
+
# lpmsg:: [in] Pointer to an MSG structure that contains the message.
|
730
|
+
#
|
731
|
+
# *Returns*:: The return value specifies the value returned by the window procedure. Although its
|
732
|
+
# meaning depends on the message being dispatched, the return value generally is ignored.
|
733
|
+
# ---
|
734
|
+
# *Remarks*:
|
735
|
+
# The MSG structure must contain valid message values. If the lpmsg parameter points to a WM_TIMER
|
736
|
+
# message and the lParam parameter of the WM_TIMER message is not NULL, lParam points to a function that
|
737
|
+
# is called instead of the window procedure.
|
738
|
+
#
|
739
|
+
# Note that the application is responsible for retrieving and dispatching input messages to the dialog
|
740
|
+
# box. Most applications use the main message loop for this. However, to permit the user to move to and
|
741
|
+
# to select controls by using the keyboard, the application must call IsDialogMessage. For more
|
742
|
+
# information, see Dialog Box Keyboard Interface.
|
743
|
+
# ---
|
744
|
+
# <b>Enhanced (snake_case) API: </b>
|
745
|
+
#
|
746
|
+
# :call-seq:
|
747
|
+
# dispatch_message(msg)
|
748
|
+
#
|
749
|
+
function :DispatchMessage, [:pointer], :long
|
750
|
+
|
751
|
+
##
|
752
|
+
function :BroadcastSystemMessage, 'LPIIL', 'L'
|
753
|
+
|
754
|
+
##
|
755
|
+
try_function :BroadcastSystemMessageEx, 'LPILLP', 'L' # Windows XP or later
|
756
|
+
|
757
|
+
##
|
758
|
+
function :DefWindowProc, 'LLLL', 'L'
|
759
|
+
|
760
|
+
##
|
761
|
+
function :GetInputState, 'V', 'B'
|
762
|
+
|
763
|
+
##
|
764
|
+
function :GetMessageExtraInfo, 'V', 'L'
|
765
|
+
|
766
|
+
##
|
767
|
+
function :GetMessagePos, 'V', 'L'
|
768
|
+
|
769
|
+
##
|
770
|
+
function :GetMessageTime, 'V', 'L'
|
771
|
+
|
772
|
+
##
|
773
|
+
function :GetQueueStatus, 'I', 'L'
|
774
|
+
|
775
|
+
##
|
776
|
+
function :InSendMessage, 'V', 'B'
|
777
|
+
|
778
|
+
##
|
779
|
+
function :InSendMessageEx, 'L', 'L'
|
780
|
+
|
781
|
+
##
|
782
|
+
function :PostQuitMessage, 'I', 'V'
|
783
|
+
|
784
|
+
##
|
785
|
+
function :PostThreadMessage, 'LILL', 'B'
|
786
|
+
|
787
|
+
##
|
788
|
+
function :RegisterWindowMessage, 'P', 'I'
|
789
|
+
|
790
|
+
##
|
791
|
+
function :ReplyMessage, 'L', 'B'
|
792
|
+
|
793
|
+
##
|
794
|
+
function :SendMessageTimeout, 'LILLIIP', 'L'
|
795
|
+
|
796
|
+
##
|
797
|
+
function :SendNotifyMessage, 'LILLIIP', 'L'
|
798
|
+
|
799
|
+
##
|
800
|
+
function :SetMessageExtraInfo, 'L', 'L'
|
801
|
+
|
802
|
+
##
|
803
|
+
function :WaitMessage, 'V', 'B'
|
804
|
+
end
|
805
|
+
end
|
806
|
+
end
|
807
|
+
|