ffi-wingui-core 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,252 @@
1
+ require_relative 'common'
2
+
3
+ module WinGUI
4
+ ffi_lib 'kernel32'
5
+ ffi_convention :stdcall
6
+
7
+ attach_function :SetLastError, [
8
+ :ulong
9
+ ], :void
10
+
11
+ attach_function :GetLastError, [
12
+
13
+ ], :ulong
14
+
15
+ def Detonate(on, name, *args)
16
+ raise "#{name} failed" if
17
+ (failed = [*on].include?(result = send(name, *args)))
18
+
19
+ result
20
+ ensure
21
+ yield failed if block_given?
22
+ end
23
+
24
+ def DetonateLastError(on, name, *args)
25
+ raise "#{name} failed (last error: #{GetLastError()})" if
26
+ (failed = [*on].include?(result = send(name, *args)))
27
+
28
+ result
29
+ ensure
30
+ yield failed if block_given?
31
+ end
32
+
33
+ module_function :Detonate, :DetonateLastError
34
+
35
+ class OSVERSIONINFOEX < FFI::Struct
36
+ extend Util::ScopedStruct
37
+
38
+ layout \
39
+ :dwOSVersionInfoSize, :ulong,
40
+ :dwMajorVersion, :ulong,
41
+ :dwMinorVersion, :ulong,
42
+ :dwBuildNumber, :ulong,
43
+ :dwPlatformId, :ulong,
44
+ :szCSDVersion, [:ushort, 128],
45
+ :wServicePackMajor, :ushort,
46
+ :wServicePackMinor, :ushort,
47
+ :wSuiteMask, :ushort,
48
+ :wProductType, :uchar,
49
+ :wReserved, :uchar
50
+ end
51
+
52
+ attach_function :GetVersionEx, :GetVersionExW, [
53
+ OSVERSIONINFOEX.by_ref
54
+ ], :int
55
+
56
+ OSVERSION = OSVERSIONINFOEX.new.tap { |ovi|
57
+ at_exit { OSVERSION.pointer.free }
58
+
59
+ ovi[:dwOSVersionInfoSize] = ovi.size
60
+
61
+ DetonateLastError(0, :GetVersionEx,
62
+ ovi
63
+ )
64
+ }
65
+
66
+ NTDDI_WIN2K = 0x0500_0000
67
+
68
+ NTDDI_WIN2KSP1 = 0x0500_0100
69
+ NTDDI_WIN2KSP2 = 0x0500_0200
70
+ NTDDI_WIN2KSP3 = 0x0500_0300
71
+ NTDDI_WIN2KSP4 = 0x0500_0400
72
+
73
+ NTDDI_WINXP = 0x0501_0000
74
+
75
+ NTDDI_WINXPSP1 = 0x0501_0100
76
+ NTDDI_WINXPSP2 = 0x0501_0200
77
+ NTDDI_WINXPSP3 = 0x0501_0300
78
+ NTDDI_WINXPSP4 = 0x0501_0400
79
+
80
+ NTDDI_WS03 = 0x0502_0000
81
+
82
+ NTDDI_WS03SP1 = 0x0502_0100
83
+ NTDDI_WS03SP2 = 0x0502_0200
84
+ NTDDI_WS03SP3 = 0x0502_0300
85
+ NTDDI_WS03SP4 = 0x0502_0400
86
+
87
+ NTDDI_VISTA = 0x0600_0000
88
+
89
+ NTDDI_VISTASP1 = 0x0600_0100
90
+ NTDDI_VISTASP2 = 0x0600_0200
91
+ NTDDI_VISTASP3 = 0x0600_0300
92
+ NTDDI_VISTASP4 = 0x0600_0400
93
+
94
+ NTDDI_WS08 = NTDDI_VISTASP1
95
+
96
+ NTDDI_WS08SP2 = NTDDI_VISTASP2
97
+ NTDDI_WS08SP3 = NTDDI_VISTASP3
98
+ NTDDI_WS08SP4 = NTDDI_VISTASP4
99
+
100
+ NTDDI_WIN7 = 0x0601_0000
101
+
102
+ NTDDI_VERSION = MAKELONG(
103
+ MAKEWORD(OSVERSION[:wServicePackMinor], OSVERSION[:wServicePackMajor]),
104
+ MAKEWORD(OSVERSION[:dwMinorVersion], OSVERSION[:dwMajorVersion])
105
+ )
106
+
107
+ WIN2K = 0x0500
108
+ WINXP = 0x0501
109
+ WINVISTA = 0x0600
110
+ WIN7 = 0x0601
111
+
112
+ WINVER = HIWORD(NTDDI_VERSION)
113
+
114
+ def TARGETVER(version, message)
115
+ version = MAKELONG(0x0000, version) if version < 0xffff
116
+
117
+ exit(-1) if NTDDI_VERSION < version &&
118
+ MessageBox(nil,
119
+ message,
120
+ APPNAME,
121
+ MB_YESNO | MB_ICONERROR | MB_DEFBUTTON2
122
+ ) == IDNO
123
+ end
124
+
125
+ module_function :TARGETVER
126
+
127
+ attach_function :GetModuleHandle, :GetModuleHandleW, [
128
+ :buffer_in
129
+ ], :pointer
130
+
131
+ attach_function :LoadLibrary, :LoadLibraryW, [
132
+ :buffer_in
133
+ ], :pointer
134
+
135
+ attach_function :FreeLibrary, [
136
+ :pointer
137
+ ], :int
138
+
139
+ if WINVER >= WINXP
140
+ class ACTCTX < FFI::Struct
141
+ extend Util::ScopedStruct
142
+
143
+ layout \
144
+ :cbSize, :ulong,
145
+ :dwFlags, :ulong,
146
+ :lpSource, :pointer,
147
+ :wProcessorArchitecture, :ushort,
148
+ :wLangId, :ushort,
149
+ :lpAssemblyDirectory, :pointer,
150
+ :lpResourceName, :pointer,
151
+ :lpApplicationName, :pointer,
152
+ :hModule, :pointer
153
+ end
154
+
155
+ attach_function :CreateActCtx, :CreateActCtxW, [
156
+ ACTCTX.by_ref
157
+ ], :pointer
158
+
159
+ attach_function :ReleaseActCtx, [
160
+ :pointer
161
+ ], :void
162
+
163
+ attach_function :ActivateActCtx, [
164
+ :pointer,
165
+ :pointer
166
+ ], :int
167
+
168
+ attach_function :DeactivateActCtx, [
169
+ :ulong,
170
+ :ulong
171
+ ], :int
172
+
173
+ COMMON_CONTROLS_ACTCTX = {
174
+ handle: INVALID_HANDLE_VALUE,
175
+ cookie: FFI::MemoryPointer.new(:ulong),
176
+ activated: false
177
+ }
178
+
179
+ at_exit {
180
+ DeactivateActCtx(0, COMMON_CONTROLS_ACTCTX[:cookie].get_ulong(0)) if
181
+ COMMON_CONTROLS_ACTCTX[:activated]
182
+
183
+ ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle]) unless
184
+ COMMON_CONTROLS_ACTCTX[:handle] == INVALID_HANDLE_VALUE
185
+
186
+ COMMON_CONTROLS_ACTCTX[:cookie].free
187
+ }
188
+ end
189
+
190
+ def EnableVisualStyles
191
+ return unless WINVER >= WINXP
192
+
193
+ raise 'Visual styles already enabled' if
194
+ COMMON_CONTROLS_ACTCTX[:activated]
195
+
196
+ manifest = "#{ENV['TEMP']}/Ruby.FFI.WinGUI.Common-Controls.manifest"
197
+
198
+ File.open(manifest, 'w:utf-8') { |file|
199
+ file << <<-XML
200
+ <?xml version='1.0' encoding='utf-8' standalone='yes' ?>
201
+ <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
202
+ <dependency>
203
+ <dependentAssembly>
204
+ <assemblyIdentity
205
+ type='Win32'
206
+ name='Microsoft.Windows.Common-Controls'
207
+ version='6.0.0.0'
208
+ processorArchitecture='*'
209
+ publicKeyToken='6595b64144ccf1df'
210
+ language='*'
211
+ />
212
+ </dependentAssembly>
213
+ </dependency>
214
+ </assembly>
215
+ XML
216
+ }
217
+
218
+ ACTCTX.new { |ac|
219
+ ac[:cbSize] = ac.size
220
+
221
+ PWSTR(L(manifest)) { |source|
222
+ ac[:lpSource] = source
223
+
224
+ COMMON_CONTROLS_ACTCTX[:handle] =
225
+ DetonateLastError(INVALID_HANDLE_VALUE, :CreateActCtx,
226
+ ac
227
+ )
228
+ }
229
+ }
230
+
231
+ DetonateLastError(0, :ActivateActCtx,
232
+ COMMON_CONTROLS_ACTCTX[:handle], COMMON_CONTROLS_ACTCTX[:cookie]
233
+ ) { |failed|
234
+ next unless failed
235
+
236
+ ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle])
237
+ COMMON_CONTROLS_ACTCTX[:handle] = INVALID_HANDLE_VALUE
238
+ }
239
+
240
+ COMMON_CONTROLS_ACTCTX[:activated] = true
241
+ end
242
+
243
+ module_function :EnableVisualStyles
244
+
245
+ EnableVisualStyles() if WINGUI_VISUAL_STYLES
246
+
247
+ attach_function :MulDiv, [
248
+ :int,
249
+ :int,
250
+ :int
251
+ ], :int
252
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'common'
2
+
3
+ module WinGUI
4
+ ffi_lib FFI::Library::LIBC
5
+ ffi_convention :cdecl
6
+
7
+ attach_function :wcslen, [
8
+ :buffer_in
9
+ ], :uint
10
+ end
@@ -0,0 +1,2573 @@
1
+ if __FILE__ == $0
2
+ require_relative 'kernel32'
3
+ require_relative 'gdi32'
4
+ end
5
+ require_relative 'common'
6
+
7
+ module WinGUI
8
+ ffi_lib 'user32'
9
+ ffi_convention :stdcall
10
+
11
+ attach_function :SetRect, [
12
+ RECT.by_ref(:out),
13
+ :int,
14
+ :int,
15
+ :int,
16
+ :int
17
+ ], :int
18
+
19
+ attach_function :CopyRect, [
20
+ RECT.by_ref(:out),
21
+ RECT.by_ref(:in)
22
+ ], :int
23
+
24
+ attach_function :OffsetRect, [
25
+ RECT.by_ref,
26
+ :int,
27
+ :int
28
+ ], :int
29
+
30
+ attach_function :InflateRect, [
31
+ RECT.by_ref,
32
+ :int,
33
+ :int
34
+ ], :int
35
+
36
+ attach_function :SubtractRect, [
37
+ RECT.by_ref(:out),
38
+ RECT.by_ref(:in),
39
+ RECT.by_ref(:in)
40
+ ], :int
41
+
42
+ attach_function :IntersectRect, [
43
+ RECT.by_ref(:out),
44
+ RECT.by_ref(:in),
45
+ RECT.by_ref(:in)
46
+ ], :int
47
+
48
+ attach_function :UnionRect, [
49
+ RECT.by_ref(:out),
50
+ RECT.by_ref(:in),
51
+ RECT.by_ref(:in)
52
+ ], :int
53
+
54
+ attach_function :IsRectEmpty, [
55
+ RECT.by_ref(:in)
56
+ ], :int
57
+
58
+ attach_function :PtInRect, [
59
+ RECT.by_ref(:in),
60
+ POINT.by_value
61
+ ], :int
62
+
63
+ attach_function :EqualRect, [
64
+ RECT.by_ref(:in),
65
+ RECT.by_ref(:in)
66
+ ], :int
67
+
68
+ def NormalizeRect(rect)
69
+ rect[:left], rect[:right] = rect[:right], rect[:left] if
70
+ rect[:left] > rect[:right]
71
+ rect[:top], rect[:bottom] = rect[:bottom], rect[:top] if
72
+ rect[:top] > rect[:bottom]
73
+ end
74
+
75
+ module_function :NormalizeRect
76
+
77
+ attach_function :DrawFocusRect, [
78
+ :pointer,
79
+ RECT.by_ref(:in)
80
+ ], :int
81
+
82
+ attach_function :FrameRect, [
83
+ :pointer,
84
+ RECT.by_ref(:in),
85
+ :pointer
86
+ ], :int
87
+
88
+ attach_function :FillRect, [
89
+ :pointer,
90
+ RECT.by_ref(:in),
91
+ :pointer
92
+ ], :int
93
+
94
+ DT_PREFIXONLY = 0x0020_0000
95
+ DT_HIDEPREFIX = 0x0010_0000
96
+ DT_NOPREFIX = 0x0000_0800
97
+ DT_MODIFYSTRING = 0x0001_0000
98
+ DT_END_ELLIPSIS = 0x0000_8000
99
+ DT_PATH_ELLIPSIS = 0x0000_4000
100
+ DT_WORD_ELLIPSIS = 0x0004_0000
101
+ DT_INTERNAL = 0x0000_1000
102
+ DT_EDITCONTROL = 0x0000_2000
103
+
104
+ DT_SINGLELINE = 0x0000_0020
105
+ DT_WORDBREAK = 0x0000_0010
106
+
107
+ DT_LEFT = 0x0000_0000
108
+ DT_CENTER = 0x0000_0001
109
+ DT_RIGHT = 0x0000_0002
110
+
111
+ DT_TOP = 0x0000_0000
112
+ DT_VCENTER = 0x0000_0004
113
+ DT_BOTTOM = 0x0000_0008
114
+
115
+ DT_EXPANDTABS = 0x0000_0040
116
+ DT_TABSTOP = 0x0000_0080
117
+
118
+ DT_CALCRECT = 0x0000_0400
119
+ DT_EXTERNALLEADING = 0x0000_0200
120
+ DT_NOCLIP = 0x0000_0100
121
+
122
+ attach_function :DrawText, :DrawTextW, [
123
+ :pointer,
124
+ :buffer_inout,
125
+ :int,
126
+ RECT.by_ref,
127
+ :uint
128
+ ], :int
129
+
130
+ if WINVER >= WINVISTA
131
+ attach_function :SetProcessDPIAware, [
132
+
133
+ ], :int
134
+
135
+ Detonate(0, :SetProcessDPIAware) if WINGUI_DPI_AWARE
136
+ end
137
+
138
+ attach_function :GetWindowDC, [
139
+ :pointer
140
+ ], :pointer
141
+
142
+ attach_function :GetDC, [
143
+ :pointer
144
+ ], :pointer
145
+
146
+ attach_function :ReleaseDC, [
147
+ :pointer,
148
+ :pointer
149
+ ], :int
150
+
151
+ def UseWindowDC(hwnd)
152
+ hdc = DetonateLastError(FFI::Pointer::NULL, :GetWindowDC,
153
+ hwnd
154
+ )
155
+
156
+ begin
157
+ yield hdc
158
+ ensure
159
+ ReleaseDC(hwnd, hdc)
160
+ end
161
+ end
162
+
163
+ def UseDC(hwnd)
164
+ hdc = DetonateLastError(FFI::Pointer::NULL, :GetDC,
165
+ hwnd
166
+ )
167
+
168
+ begin
169
+ yield hdc
170
+ ensure
171
+ ReleaseDC(hwnd, hdc)
172
+ end
173
+ end
174
+
175
+ module_function :UseWindowDC, :UseDC
176
+
177
+ UseDC(nil) { |hdc|
178
+ DPIX = GetDeviceCaps(hdc, LOGPIXELSX)
179
+ DPIY = GetDeviceCaps(hdc, LOGPIXELSY)
180
+ }
181
+
182
+ def DPIAwareX(x)
183
+ MulDiv(x, DPIX, 96)
184
+ end
185
+
186
+ def DPIAwareY(y)
187
+ MulDiv(y, DPIY, 96)
188
+ end
189
+
190
+ def DPIAwareXY(*args)
191
+ raise ArgumentError, 'Expected two or more, even count arguments' if
192
+ args.length < 2 || args.length.odd?
193
+
194
+ args.each_with_index { |arg, i|
195
+ args[i] = (i.even?) ? DPIAwareX(arg) : DPIAwareY(arg)
196
+ }
197
+ end
198
+
199
+ module_function :DPIAwareX, :DPIAwareY, :DPIAwareXY
200
+
201
+ SM_CXSCREEN = 0
202
+ SM_CYSCREEN = 1
203
+
204
+ attach_function :GetSystemMetrics, [
205
+ :int
206
+ ], :int
207
+
208
+ class NONCLIENTMETRICS < FFI::Struct
209
+ extend Util::ScopedStruct
210
+
211
+ layout(*[
212
+ :cbSize, :uint,
213
+ :iBorderWidth, :int,
214
+ :iScrollWidth, :int,
215
+ :iScrollHeight, :int,
216
+ :iCaptionWidth, :int,
217
+ :iCaptionHeight, :int,
218
+ :lfCaptionFont, LOGFONT,
219
+ :iSmCaptionWidth, :int,
220
+ :iSmCaptionHeight, :int,
221
+ :lfSmCaptionFont, LOGFONT,
222
+ :iMenuWidth, :int,
223
+ :iMenuHeight, :int,
224
+ :lfMenuFont, LOGFONT,
225
+ :lfStatusFont, LOGFONT,
226
+ :lfMessageFont, LOGFONT,
227
+ (WINVER >= WINVISTA) ? [:iPaddedBorderWidth, :int] : nil
228
+ ].tap { |layout|
229
+ layout.flatten!
230
+ layout.compact!
231
+ })
232
+ end
233
+
234
+ SPI_SETNONCLIENTMETRICS = 0x002a
235
+ SPI_GETNONCLIENTMETRICS = 0x0029
236
+
237
+ attach_function :SystemParametersInfo, :SystemParametersInfoW, [
238
+ :uint,
239
+ :uint,
240
+ :pointer,
241
+ :uint
242
+ ], :int
243
+
244
+ MB_OK = 0x0000_0000
245
+ MB_OKCANCEL = 0x0000_0001
246
+ MB_YESNO = 0x0000_0004
247
+ MB_YESNOCANCEL = 0x0000_0003
248
+ MB_RETRYCANCEL = 0x0000_0005
249
+ MB_ABORTRETRYIGNORE = 0x0000_0002
250
+ MB_CANCELTRYCONTINUE = 0x0000_0006
251
+ MB_HELP = 0x0000_4000
252
+
253
+ MB_ICONINFORMATION = 0x0000_0040
254
+ MB_ICONWARNING = 0x0000_0030
255
+ MB_ICONERROR = 0x0000_0010
256
+ MB_ICONQUESTION = 0x0000_0020
257
+
258
+ MB_DEFBUTTON1 = 0x0000_0000
259
+ MB_DEFBUTTON2 = 0x0000_0100
260
+ MB_DEFBUTTON3 = 0x0000_0200
261
+ MB_DEFBUTTON4 = 0x0000_0300
262
+
263
+ MB_APPLMODAL = 0x0000_0000
264
+ MB_TASKMODAL = 0x0000_2000
265
+ MB_SYSTEMMODAL = 0x0000_1000
266
+
267
+ IDOK = 1
268
+ IDCANCEL = 2
269
+ IDYES = 6
270
+ IDNO = 7
271
+ IDABORT = 3
272
+ IDRETRY = 4
273
+ IDIGNORE = 5
274
+ IDTRYAGAIN = 10
275
+ IDCONTINUE = 11
276
+ if WINVER >= WINXP
277
+ IDTIMEOUT = 32000
278
+ end
279
+
280
+ attach_function :MessageBox, :MessageBoxW, [
281
+ :pointer,
282
+ :buffer_in,
283
+ :buffer_in,
284
+ :uint
285
+ ], :int
286
+
287
+ if WINVER >= WINXP
288
+ begin
289
+ attach_function :MessageBoxTimeout, :MessageBoxTimeoutW, [
290
+ :pointer,
291
+ :buffer_in,
292
+ :buffer_in,
293
+ :uint,
294
+ :ushort,
295
+ :ulong
296
+ ], :int
297
+ rescue FFI::NotFoundError # MessageBoxTimeout is undocumented
298
+
299
+ end
300
+ end
301
+
302
+ WC_DIALOG = FFI::Pointer.new(0x8002)
303
+
304
+ CS_DBLCLKS = 0x0008
305
+ CS_HREDRAW = 0x0002
306
+ CS_VREDRAW = 0x0001
307
+ CS_PARENTDC = 0x0080
308
+ CS_CLASSDC = 0x0040
309
+ CS_OWNDC = 0x0020
310
+ CS_SAVEBITS = 0x0800
311
+ CS_NOCLOSE = 0x0200
312
+ if WINVER >= WINXP
313
+ CS_DROPSHADOW = 0x0002_0000
314
+ end
315
+
316
+ callback :WNDPROC, [
317
+ :pointer,
318
+ :uint,
319
+ :uint,
320
+ :long
321
+ ], :long
322
+
323
+ attach_function :DefWindowProc, :DefWindowProcW, [
324
+ :pointer,
325
+ :uint,
326
+ :uint,
327
+ :long
328
+ ], :long
329
+
330
+ attach_function :DefDlgProc, :DefDlgProcW, [
331
+ :pointer,
332
+ :uint,
333
+ :uint,
334
+ :long
335
+ ], :long
336
+
337
+ attach_function :CallWindowProc, :CallWindowProcW, [
338
+ :WNDPROC,
339
+ :pointer,
340
+ :uint,
341
+ :uint,
342
+ :long
343
+ ], :long
344
+
345
+ callback :DLGPROC, [
346
+ :pointer,
347
+ :uint,
348
+ :uint,
349
+ :long
350
+ ], :int
351
+
352
+ DLGWINDOWEXTRA = 30
353
+
354
+ IMAGE_BITMAP = 0
355
+ IMAGE_ICON = 1
356
+ IMAGE_CURSOR = 2
357
+
358
+ LR_SHARED = 0x0000_8000
359
+ LR_LOADFROMFILE = 0x0000_0010
360
+ LR_CREATEDIBSECTION = 0x0000_2000
361
+ LR_LOADTRANSPARENT = 0x0000_0020
362
+ LR_LOADMAP3DCOLORS = 0x0000_1000
363
+ LR_DEFAULTSIZE = 0x0000_0040
364
+
365
+ attach_function :LoadImage, :LoadImageW, [
366
+ :pointer,
367
+ :buffer_in,
368
+ :uint,
369
+ :int,
370
+ :int,
371
+ :uint
372
+ ], :pointer
373
+
374
+ IDI_WINLOGO = FFI::Pointer.new(32517)
375
+ IDI_APPLICATION = FFI::Pointer.new(32512)
376
+ if WINVER >= WINVISTA
377
+ IDI_SHIELD = FFI::Pointer.new(32518)
378
+ end
379
+
380
+ IDI_INFORMATION = FFI::Pointer.new(32516)
381
+ IDI_WARNING = FFI::Pointer.new(32515)
382
+ IDI_ERROR = FFI::Pointer.new(32513)
383
+ IDI_QUESTION = FFI::Pointer.new(32514)
384
+
385
+ attach_function :LoadIcon, :LoadIconW, [
386
+ :pointer,
387
+ :buffer_in
388
+ ], :pointer
389
+
390
+ attach_function :DestroyIcon, [
391
+ :pointer
392
+ ], :int
393
+
394
+ begin
395
+ attach_function :PrivateExtractIcons, :PrivateExtractIconsW, [
396
+ :buffer_in,
397
+ :int,
398
+ :int,
399
+ :int,
400
+ :pointer,
401
+ :pointer,
402
+ :uint,
403
+ :uint
404
+ ], :uint
405
+ rescue FFI::NotFoundError # PrivateExtractIcons is not intended for general use
406
+
407
+ end
408
+
409
+ IDC_WAIT = FFI::Pointer.new(32514)
410
+ IDC_APPSTARTING = FFI::Pointer.new(32650)
411
+
412
+ IDC_ARROW = FFI::Pointer.new(32512)
413
+ IDC_HAND = FFI::Pointer.new(32649)
414
+ IDC_IBEAM = FFI::Pointer.new(32513)
415
+ IDC_CROSS = FFI::Pointer.new(32515)
416
+ IDC_HELP = FFI::Pointer.new(32651)
417
+ IDC_NO = FFI::Pointer.new(32648)
418
+
419
+ IDC_SIZEALL = FFI::Pointer.new(32646)
420
+ IDC_SIZENS = FFI::Pointer.new(32645)
421
+ IDC_SIZEWE = FFI::Pointer.new(32644)
422
+ IDC_SIZENWSE = FFI::Pointer.new(32642)
423
+ IDC_SIZENESW = FFI::Pointer.new(32643)
424
+
425
+ attach_function :LoadCursor, :LoadCursorW, [
426
+ :pointer,
427
+ :buffer_in
428
+ ], :pointer
429
+
430
+ attach_function :DestroyCursor, [
431
+ :pointer
432
+ ], :int
433
+
434
+ attach_function :SetCursor, [
435
+ :pointer
436
+ ], :pointer
437
+
438
+ attach_function :GetCursor, [
439
+
440
+ ], :pointer
441
+
442
+ attach_function :SetCursorPos, [
443
+ :int,
444
+ :int
445
+ ], :int
446
+
447
+ attach_function :GetCursorPos, [
448
+ POINT.by_ref(:out)
449
+ ], :int
450
+
451
+ attach_function :ShowCursor, [
452
+ :int
453
+ ], :int
454
+
455
+ COLOR_DESKTOP = 1
456
+ COLOR_APPWORKSPACE = 12
457
+ COLOR_WINDOW = 5
458
+ if WINVER >= WINXP
459
+ COLOR_MENUBAR = 30
460
+ end
461
+ COLOR_MENU = 4
462
+
463
+ class WNDCLASSEX < FFI::Struct
464
+ extend Util::ScopedStruct
465
+
466
+ layout \
467
+ :cbSize, :uint,
468
+ :style, :uint,
469
+ :lpfnWndProc, :WNDPROC,
470
+ :cbClsExtra, :int,
471
+ :cbWndExtra, :int,
472
+ :hInstance, :pointer,
473
+ :hIcon, :pointer,
474
+ :hCursor, :pointer,
475
+ :hbrBackground, :pointer,
476
+ :lpszMenuName, :pointer,
477
+ :lpszClassName, :pointer,
478
+ :hIconSm, :pointer
479
+ end
480
+
481
+ attach_function :RegisterClassEx, :RegisterClassExW, [
482
+ WNDCLASSEX.by_ref(:in)
483
+ ], :ushort
484
+
485
+ attach_function :UnregisterClass, :UnregisterClassW, [
486
+ :buffer_in,
487
+ :pointer
488
+ ], :int
489
+
490
+ attach_function :GetClassInfoEx, :GetClassInfoExW, [
491
+ :pointer,
492
+ :buffer_in,
493
+ WNDCLASSEX.by_ref(:out)
494
+ ], :int
495
+
496
+ attach_function :FindWindow, :FindWindowW, [
497
+ :buffer_in,
498
+ :buffer_in
499
+ ], :pointer
500
+
501
+ callback :WNDENUMPROC, [
502
+ :pointer,
503
+ :long
504
+ ], :int
505
+
506
+ attach_function :EnumChildWindows, [
507
+ :pointer,
508
+ :WNDENUMPROC,
509
+ :long
510
+ ], :int
511
+
512
+ attach_function :GetDesktopWindow, [
513
+
514
+ ], :pointer
515
+
516
+ GW_HWNDFIRST = 0
517
+ GW_HWNDLAST = 1
518
+ GW_HWNDNEXT = 2
519
+ GW_HWNDPREV = 3
520
+ GW_OWNER = 4
521
+ GW_ENABLEDPOPUP = 6
522
+ GW_CHILD = 5
523
+
524
+ attach_function :GetWindow, [
525
+ :pointer,
526
+ :uint
527
+ ], :pointer
528
+
529
+ GA_PARENT = 1
530
+ GA_ROOT = 2
531
+ GA_ROOTOWNER = 3
532
+
533
+ attach_function :GetAncestor, [
534
+ :pointer,
535
+ :uint
536
+ ], :pointer
537
+
538
+ attach_function :SetParent, [
539
+ :pointer,
540
+ :pointer
541
+ ], :pointer
542
+
543
+ attach_function :GetParent, [
544
+ :pointer
545
+ ], :pointer
546
+
547
+ WS_EX_WINDOWEDGE = 0x0000_0100
548
+ WS_EX_CLIENTEDGE = 0x0000_0200
549
+ WS_EX_STATICEDGE = 0x0002_0000
550
+ WS_EX_DLGMODALFRAME = 0x0000_0001
551
+ WS_EX_CONTEXTHELP = 0x0000_0400
552
+ WS_EX_ACCEPTFILES = 0x0000_0010
553
+
554
+ WS_EX_TOPMOST = 0x0000_0008
555
+ WS_EX_LAYERED = 0x0008_0000
556
+ if WINVER >= WINXP
557
+ WS_EX_COMPOSITED = 0x0200_0000
558
+ end
559
+ WS_EX_TRANSPARENT = 0x0000_0020
560
+
561
+ WS_EX_NOPARENTNOTIFY = 0x0000_0004
562
+
563
+ WS_EX_APPWINDOW = 0x0004_0000
564
+ WS_EX_OVERLAPPEDWINDOW = \
565
+ WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE
566
+ WS_EX_TOOLWINDOW = 0x0000_0080
567
+ WS_EX_PALETTEWINDOW = WS_EX_TOOLWINDOW |
568
+ WS_EX_WINDOWEDGE | WS_EX_TOPMOST
569
+ WS_EX_CONTROLPARENT = 0x0001_0000
570
+
571
+ WS_BORDER = 0x0080_0000
572
+ WS_DLGFRAME = 0x0040_0000
573
+ WS_CAPTION = 0x00c0_0000
574
+ WS_SYSMENU = 0x0008_0000
575
+ WS_THICKFRAME = 0x0004_0000
576
+ WS_MINIMIZEBOX = 0x0002_0000
577
+ WS_MAXIMIZEBOX = 0x0001_0000
578
+ WS_HSCROLL = 0x0010_0000
579
+ WS_VSCROLL = 0x0020_0000
580
+
581
+ WS_DISABLED = 0x0800_0000
582
+ WS_VISIBLE = 0x1000_0000
583
+ WS_MINIMIZE = 0x2000_0000
584
+ WS_MAXIMIZE = 0x0100_0000
585
+ WS_CLIPCHILDREN = 0x0200_0000
586
+
587
+ WS_GROUP = 0x0002_0000
588
+ WS_TABSTOP = 0x0001_0000
589
+ WS_CLIPSIBLINGS = 0x0400_0000
590
+
591
+ WS_OVERLAPPED = 0x0000_0000
592
+ WS_OVERLAPPEDWINDOW = WS_OVERLAPPED |
593
+ WS_CAPTION | WS_SYSMENU |
594
+ WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
595
+ WS_POPUP = 0x8000_0000
596
+ WS_POPUPWINDOW = WS_POPUP |
597
+ WS_BORDER | WS_SYSMENU
598
+ WS_CHILD = 0x4000_0000
599
+ WS_CHILDWINDOW = WS_CHILD
600
+
601
+ DS_MODALFRAME = 0x80
602
+ DS_ABSALIGN = 0x01
603
+ DS_CENTER = 0x0800
604
+ DS_CENTERMOUSE = 0x1000
605
+ DS_CONTROL = 0x0400
606
+
607
+ CW_USEDEFAULT = 0x8000_0000 - 0x1_0000_0000
608
+
609
+ HWND_DESKTOP = FFI::Pointer.new(0)
610
+ HWND_MESSAGE = FFI::Pointer.new(-3)
611
+
612
+ attach_function :CreateWindowEx, :CreateWindowExW, [
613
+ :ulong,
614
+ :buffer_in,
615
+ :buffer_in,
616
+ :ulong,
617
+ :int,
618
+ :int,
619
+ :int,
620
+ :int,
621
+ :pointer,
622
+ :pointer,
623
+ :pointer,
624
+ :pointer
625
+ ], :pointer
626
+
627
+ class DLGTEMPLATE < FFI::Struct
628
+ extend Util::ScopedStruct
629
+
630
+ layout \
631
+ :style, :ulong,
632
+ :dwExtendedStyle, :ulong,
633
+ :cdit, :ushort,
634
+ :x, :short,
635
+ :y, :short,
636
+ :cx, :short,
637
+ :cy, :short,
638
+ :menu, :ushort,
639
+ :windowClass, :ushort,
640
+ :title, :ushort
641
+ end
642
+
643
+ attach_function :CreateDialogIndirectParam, :CreateDialogIndirectParamW, [
644
+ :pointer,
645
+ DLGTEMPLATE.by_ref(:in),
646
+ :pointer,
647
+ :DLGPROC,
648
+ :long
649
+ ], :pointer
650
+
651
+ attach_function :DestroyWindow, [
652
+ :pointer
653
+ ], :int
654
+
655
+ attach_function :DialogBoxIndirectParam, :DialogBoxIndirectParamW, [
656
+ :pointer,
657
+ DLGTEMPLATE.by_ref(:in),
658
+ :pointer,
659
+ :DLGPROC,
660
+ :long
661
+ ], :int
662
+
663
+ attach_function :EndDialog, [
664
+ :pointer,
665
+ :int
666
+ ], :int
667
+
668
+ GCL_STYLE = -26
669
+ GCL_WNDPROC = -24
670
+ GCL_CBCLSEXTRA = -20
671
+ GCL_CBWNDEXTRA = -18
672
+ GCL_HMODULE = -16
673
+ GCL_HICON = -14
674
+ GCL_HCURSOR = -12
675
+ GCL_HBRBACKGROUND = -10
676
+ GCL_MENUNAME = -8
677
+ GCL_HICONSM = -34
678
+ GCW_ATOM = -32
679
+
680
+ attach_function :SetClassLong, :SetClassLongW, [
681
+ :pointer,
682
+ :int,
683
+ :long
684
+ ], :ulong
685
+
686
+ attach_function :GetClassLong, :GetClassLongW, [
687
+ :pointer,
688
+ :int
689
+ ], :ulong
690
+
691
+ attach_function :GetClassName, :GetClassNameW, [
692
+ :pointer,
693
+ :buffer_out,
694
+ :int
695
+ ], :int
696
+
697
+ GWL_WNDPROC = -4
698
+ GWL_EXSTYLE = -20
699
+ GWL_STYLE = -16
700
+ GWL_HWNDPARENT = -8
701
+ GWL_ID = -12
702
+ GWL_HINSTANCE = -6
703
+ GWL_USERDATA = -21
704
+
705
+ DWL_DLGPROC = 4
706
+ DWL_MSGRESULT = 0
707
+ DWL_USER = 8
708
+
709
+ attach_function :SetWindowLong, :SetWindowLongW, [
710
+ :pointer,
711
+ :int,
712
+ :long
713
+ ], :long
714
+
715
+ attach_function :GetWindowLong, :GetWindowLongW, [
716
+ :pointer,
717
+ :int
718
+ ], :long
719
+
720
+ attach_function :SetProp, :SetPropW, [
721
+ :pointer,
722
+ :buffer_in,
723
+ :long # HANDLE (void *) in the original prototype
724
+ ], :int
725
+
726
+ attach_function :RemoveProp, :RemovePropW, [
727
+ :pointer,
728
+ :buffer_in
729
+ ], :long # HANDLE (void *) in the original prototype
730
+
731
+ attach_function :GetProp, :GetPropW, [
732
+ :pointer,
733
+ :buffer_in
734
+ ], :long # HANDLE (void *) in the original prototype
735
+
736
+ callback :PROPENUMPROCEX, [
737
+ :pointer,
738
+ :buffer_in,
739
+ :long, # HANDLE (void *) in the original prototype
740
+ :ulong
741
+ ], :int
742
+
743
+ attach_function :EnumPropsEx, :EnumPropsExW, [
744
+ :pointer,
745
+ :PROPENUMPROCEX,
746
+ :long
747
+ ], :int
748
+
749
+ LWA_COLORKEY = 0x0000_0001
750
+ LWA_ALPHA = 0x0000_0002
751
+
752
+ attach_function :SetLayeredWindowAttributes, [
753
+ :pointer,
754
+ :ulong,
755
+ :uchar,
756
+ :ulong
757
+ ], :int
758
+
759
+ if WINVER >= WINXP
760
+ attach_function :GetLayeredWindowAttributes, [
761
+ :pointer,
762
+ :pointer,
763
+ :pointer,
764
+ :pointer
765
+ ], :int
766
+ end
767
+
768
+ attach_function :SetWindowRgn, [
769
+ :pointer,
770
+ :pointer,
771
+ :int
772
+ ], :int
773
+
774
+ attach_function :GetWindowRgn, [
775
+ :pointer,
776
+ :pointer
777
+ ], :int
778
+
779
+ attach_function :IsWindowEnabled, [
780
+ :pointer
781
+ ], :int
782
+
783
+ attach_function :EnableWindow, [
784
+ :pointer,
785
+ :int
786
+ ], :int
787
+
788
+ attach_function :SetActiveWindow, [
789
+ :pointer
790
+ ], :pointer
791
+
792
+ attach_function :GetActiveWindow, [
793
+
794
+ ], :pointer
795
+
796
+ attach_function :SetForegroundWindow, [
797
+ :pointer
798
+ ], :int
799
+
800
+ attach_function :GetForegroundWindow, [
801
+
802
+ ], :pointer
803
+
804
+ attach_function :SetFocus, [
805
+ :pointer
806
+ ], :pointer
807
+
808
+ attach_function :GetFocus, [
809
+
810
+ ], :pointer
811
+
812
+ attach_function :IsWindowVisible, [
813
+ :pointer
814
+ ], :int
815
+
816
+ attach_function :IsIconic, [
817
+ :pointer
818
+ ], :int
819
+
820
+ attach_function :IsZoomed, [
821
+ :pointer
822
+ ], :int
823
+
824
+ SW_SHOWDEFAULT = 10
825
+ SW_HIDE = 0
826
+ SW_SHOW = 5
827
+ SW_SHOWNA = 8
828
+ SW_SHOWNORMAL = 1
829
+ SW_SHOWNOACTIVATE = 4
830
+ SW_SHOWMINIMIZED = 2
831
+ SW_SHOWMINNOACTIVE = 7
832
+ SW_MINIMIZE = 6
833
+ SW_FORCEMINIMIZE = 11
834
+ SW_SHOWMAXIMIZED = 3
835
+ SW_MAXIMIZE = 3
836
+ SW_RESTORE = 9
837
+
838
+ attach_function :ShowWindow, [
839
+ :pointer,
840
+ :int
841
+ ], :int
842
+
843
+ attach_function :ShowWindowAsync, [
844
+ :pointer,
845
+ :int
846
+ ], :int
847
+
848
+ AW_HIDE = 0x0001_0000
849
+ AW_ACTIVATE = 0x0002_0000
850
+ AW_CENTER = 0x0000_0010
851
+ AW_SLIDE = 0x0004_0000
852
+ AW_HOR_POSITIVE = 0x0000_0001
853
+ AW_HOR_NEGATIVE = 0x0000_0002
854
+ AW_VER_POSITIVE = 0x0000_0004
855
+ AW_VER_NEGATIVE = 0x0000_0008
856
+ AW_BLEND = 0x0008_0000
857
+
858
+ attach_function :AnimateWindow, [
859
+ :pointer,
860
+ :ulong,
861
+ :ulong
862
+ ], :int
863
+
864
+ HWND_TOP = FFI::Pointer.new(0)
865
+ HWND_BOTTOM = FFI::Pointer.new(1)
866
+ HWND_TOPMOST = FFI::Pointer.new(-1)
867
+ HWND_NOTOPMOST = FFI::Pointer.new(-2)
868
+
869
+ SWP_FRAMECHANGED = 0x0020
870
+ SWP_NOACTIVATE = 0x0010
871
+ SWP_NOOWNERZORDER = 0x0200
872
+ SWP_NOZORDER = 0x0004
873
+ SWP_NOMOVE = 0x0002
874
+ SWP_NOSIZE = 0x0001
875
+ SWP_ASYNCWINDOWPOS = 0x4000
876
+
877
+ attach_function :SetWindowPos, [
878
+ :pointer,
879
+ :pointer,
880
+ :int,
881
+ :int,
882
+ :int,
883
+ :int,
884
+ :uint
885
+ ], :int
886
+
887
+ attach_function :BeginDeferWindowPos, [
888
+ :int
889
+ ], :pointer
890
+
891
+ attach_function :DeferWindowPos, [
892
+ :pointer,
893
+ :pointer,
894
+ :pointer,
895
+ :int,
896
+ :int,
897
+ :int,
898
+ :int,
899
+ :uint
900
+ ], :pointer
901
+
902
+ attach_function :EndDeferWindowPos, [
903
+ :pointer
904
+ ], :int
905
+
906
+ attach_function :MapDialogRect, [
907
+ :pointer,
908
+ RECT.by_ref
909
+ ], :int
910
+
911
+ SB_HORZ = 0
912
+ SB_VERT = 1
913
+ SB_BOTH = 3
914
+ SB_CTL = 2
915
+
916
+ SIF_RANGE = 0x0001
917
+ SIF_PAGE = 0x0002
918
+ SIF_POS = 0x0004
919
+ SIF_TRACKPOS = 0x0010
920
+ SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS
921
+ SIF_DISABLENOSCROLL = 0x0008
922
+
923
+ class SCROLLINFO < FFI::Struct
924
+ extend Util::ScopedStruct
925
+
926
+ layout \
927
+ :cbSize, :uint,
928
+ :fMask, :uint,
929
+ :nMin, :int,
930
+ :nMax, :int,
931
+ :nPage, :uint,
932
+ :nPos, :int,
933
+ :nTrackPos, :int
934
+ end
935
+
936
+ attach_function :SetScrollInfo, [
937
+ :pointer,
938
+ :int,
939
+ SCROLLINFO.by_ref(:in),
940
+ :int
941
+ ], :int
942
+
943
+ attach_function :GetScrollInfo, [
944
+ :pointer,
945
+ :int,
946
+ SCROLLINFO.by_ref
947
+ ], :int
948
+
949
+ ESB_DISABLE_LEFT = 0x0001
950
+ ESB_DISABLE_RIGHT = 0x0002
951
+ ESB_DISABLE_UP = 0x0001
952
+ ESB_DISABLE_DOWN = 0x0002
953
+
954
+ ESB_ENABLE_BOTH = 0x0000
955
+ ESB_DISABLE_BOTH = 0x0003
956
+
957
+ attach_function :EnableScrollBar, [
958
+ :pointer,
959
+ :uint,
960
+ :uint
961
+ ], :int
962
+
963
+ attach_function :ShowScrollBar, [
964
+ :pointer,
965
+ :int,
966
+ :int
967
+ ], :int
968
+
969
+ attach_function :ScrollDC, [
970
+ :pointer,
971
+ :int,
972
+ :int,
973
+ RECT.by_ref(:in),
974
+ RECT.by_ref(:in),
975
+ :pointer,
976
+ RECT.by_ref(:out)
977
+ ], :int
978
+
979
+ SW_INVALIDATE = 0x0002
980
+ SW_ERASE = 0x0004
981
+ SW_SCROLLCHILDREN = 0x0001
982
+ SW_SMOOTHSCROLL = 0x0010
983
+
984
+ attach_function :ScrollWindowEx, [
985
+ :pointer,
986
+ :int,
987
+ :int,
988
+ RECT.by_ref(:in),
989
+ RECT.by_ref(:in),
990
+ :pointer,
991
+ RECT.by_ref(:out),
992
+ :uint
993
+ ], :int
994
+
995
+ attach_function :GetWindowRect, [
996
+ :pointer,
997
+ RECT.by_ref(:out)
998
+ ], :int
999
+
1000
+ attach_function :GetClientRect, [
1001
+ :pointer,
1002
+ RECT.by_ref(:out)
1003
+ ], :int
1004
+
1005
+ attach_function :ScreenToClient, [
1006
+ :pointer,
1007
+ POINT.by_ref
1008
+ ], :int
1009
+
1010
+ attach_function :ClientToScreen, [
1011
+ :pointer,
1012
+ POINT.by_ref
1013
+ ], :int
1014
+
1015
+ attach_function :InvalidateRect, [
1016
+ :pointer,
1017
+ RECT.by_ref(:in),
1018
+ :int
1019
+ ], :int
1020
+
1021
+ attach_function :GetUpdateRect, [
1022
+ :pointer,
1023
+ RECT.by_ref(:out),
1024
+ :int
1025
+ ], :int
1026
+
1027
+ attach_function :UpdateWindow, [
1028
+ :pointer
1029
+ ], :int
1030
+
1031
+ class PAINTSTRUCT < FFI::Struct
1032
+ extend Util::ScopedStruct
1033
+
1034
+ layout \
1035
+ :hdc, :pointer,
1036
+ :fErase, :int,
1037
+ :rcPaint, RECT,
1038
+ :fRestore, :int,
1039
+ :fIncUpdate, :int,
1040
+ :rgbReserved, [:uchar, 32]
1041
+ end
1042
+
1043
+ attach_function :BeginPaint, [
1044
+ :pointer,
1045
+ PAINTSTRUCT.by_ref(:out)
1046
+ ], :pointer
1047
+
1048
+ attach_function :EndPaint, [
1049
+ :pointer,
1050
+ PAINTSTRUCT.by_ref(:in)
1051
+ ], :int
1052
+
1053
+ def DoPaint(hwnd)
1054
+ return unless GetUpdateRect(hwnd, nil, 0) != 0
1055
+
1056
+ PAINTSTRUCT.new { |ps|
1057
+ DetonateLastError(FFI::Pointer::NULL, :BeginPaint,
1058
+ hwnd, ps
1059
+ )
1060
+
1061
+ begin
1062
+ yield ps
1063
+ ensure
1064
+ EndPaint(hwnd, ps)
1065
+ end
1066
+ }
1067
+ end
1068
+
1069
+ def DoPrintClient(hwnd, wParam)
1070
+ PAINTSTRUCT.new { |ps|
1071
+ ps[:hdc] = FFI::Pointer.new(wParam)
1072
+ ps[:fErase] = 1
1073
+ GetClientRect(hwnd, ps[:rcPaint])
1074
+
1075
+ yield ps
1076
+ }
1077
+ end
1078
+
1079
+ module_function :DoPaint, :DoPrintClient
1080
+
1081
+ attach_function :SetCapture, [
1082
+ :pointer
1083
+ ], :pointer
1084
+
1085
+ attach_function :ReleaseCapture, [
1086
+
1087
+ ], :int
1088
+
1089
+ attach_function :GetCapture, [
1090
+
1091
+ ], :pointer
1092
+
1093
+ attach_function :SetKeyboardState, [
1094
+ :pointer
1095
+ ], :int
1096
+
1097
+ attach_function :GetKeyboardState, [
1098
+ :pointer
1099
+ ], :int
1100
+
1101
+ attach_function :GetKeyState, [
1102
+ :int
1103
+ ], :short
1104
+
1105
+ attach_function :GetAsyncKeyState, [
1106
+ :int
1107
+ ], :short
1108
+
1109
+ INPUT_MOUSE = 0
1110
+ INPUT_KEYBOARD = 1
1111
+ INPUT_HARDWARE = 2
1112
+
1113
+ MOUSEEVENTF_LEFTDOWN = 0x0002
1114
+ MOUSEEVENTF_LEFTUP = 0x0004
1115
+
1116
+ MOUSEEVENTF_RIGHTDOWN = 0x0008
1117
+ MOUSEEVENTF_RIGHTUP = 0x0010
1118
+
1119
+ MOUSEEVENTF_MIDDLEDOWN = 0x0020
1120
+ MOUSEEVENTF_MIDDLEUP = 0x0040
1121
+
1122
+ MOUSEEVENTF_XDOWN = 0x0080
1123
+ MOUSEEVENTF_XUP = 0x0100
1124
+
1125
+ MOUSEEVENTF_WHEEL = 0x0800
1126
+ if WINVER >= WINVISTA
1127
+ MOUSEEVENTF_HWHEEL = 0x1000
1128
+ end
1129
+
1130
+ MOUSEEVENTF_MOVE = 0x0001
1131
+ if WINVER >= WINVISTA
1132
+ MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000
1133
+ end
1134
+
1135
+ MOUSEEVENTF_ABSOLUTE = 0x8000
1136
+ MOUSEEVENTF_VIRTUALDESK = 0x4000
1137
+
1138
+ class MOUSEINPUT < FFI::Struct
1139
+ extend Util::ScopedStruct
1140
+
1141
+ layout \
1142
+ :dx, :long,
1143
+ :dy, :long,
1144
+ :mouseData, :ulong,
1145
+ :dwFlags, :ulong,
1146
+ :time, :ulong,
1147
+ :dwExtraInfo, :ulong
1148
+ end
1149
+
1150
+ KEYEVENTF_SCANCODE = 0x0008
1151
+ KEYEVENTF_EXTENDEDKEY = 0x0001
1152
+ KEYEVENTF_KEYUP = 0x0002
1153
+ KEYEVENTF_UNICODE = 0x0004
1154
+
1155
+ class KEYBDINPUT < FFI::Struct
1156
+ extend Util::ScopedStruct
1157
+
1158
+ layout \
1159
+ :wVk, :ushort,
1160
+ :wScan, :ushort,
1161
+ :dwFlags, :ulong,
1162
+ :time, :ulong,
1163
+ :dwExtraInfo, :ulong
1164
+ end
1165
+
1166
+ class HARDWAREINPUT < FFI::Struct
1167
+ extend Util::ScopedStruct
1168
+
1169
+ layout \
1170
+ :uMsg, :ulong,
1171
+ :wParamL, :ushort,
1172
+ :wParamH, :ushort
1173
+ end
1174
+
1175
+ class INPUT < FFI::Struct
1176
+ extend Util::ScopedStruct
1177
+
1178
+ layout \
1179
+ :type, :ulong,
1180
+
1181
+ :_, Class.new(FFI::Union) {
1182
+ layout \
1183
+ :mi, MOUSEINPUT,
1184
+ :ki, KEYBDINPUT,
1185
+ :hi, HARDWAREINPUT
1186
+ }
1187
+ end
1188
+
1189
+ attach_function :SendInput, [
1190
+ :uint,
1191
+ :pointer,
1192
+ :int
1193
+ ], :uint
1194
+
1195
+ attach_function :GetSystemMenu, [
1196
+ :pointer,
1197
+ :int
1198
+ ], :pointer
1199
+
1200
+ attach_function :SetMenu, [
1201
+ :pointer,
1202
+ :pointer
1203
+ ], :int
1204
+
1205
+ attach_function :GetMenu, [
1206
+ :pointer
1207
+ ], :pointer
1208
+
1209
+ attach_function :DrawMenuBar, [
1210
+ :pointer
1211
+ ], :int
1212
+
1213
+ attach_function :GetDlgItem, [
1214
+ :pointer,
1215
+ :int
1216
+ ], :pointer
1217
+
1218
+ attach_function :GetDlgCtrlID, [
1219
+ :pointer
1220
+ ], :int
1221
+
1222
+ attach_function :GetNextDlgGroupItem, [
1223
+ :pointer,
1224
+ :pointer,
1225
+ :int
1226
+ ], :pointer
1227
+
1228
+ attach_function :GetNextDlgTabItem, [
1229
+ :pointer,
1230
+ :pointer,
1231
+ :int
1232
+ ], :pointer
1233
+
1234
+ HWND_BROADCAST = FFI::Pointer.new(0xffff)
1235
+
1236
+ class CREATESTRUCT < FFI::Struct
1237
+ extend Util::ScopedStruct
1238
+
1239
+ layout \
1240
+ :lpCreateParams, :pointer,
1241
+ :hInstance, :pointer,
1242
+ :hMenu, :pointer,
1243
+ :hwndParent, :pointer,
1244
+ :cy, :int,
1245
+ :cx, :int,
1246
+ :y, :int,
1247
+ :x, :int,
1248
+ :style, :long,
1249
+ :lpszName, :pointer,
1250
+ :lpszClass, :pointer,
1251
+ :dwExStyle, :ulong
1252
+ end
1253
+
1254
+ WM_NCCREATE = 0x0081
1255
+ WM_CREATE = 0x0001
1256
+ WM_INITDIALOG = 0x0110
1257
+
1258
+ WM_CLOSE = 0x0010
1259
+
1260
+ WM_DESTROY = 0x0002
1261
+ WM_NCDESTROY = 0x0082
1262
+
1263
+ WM_QUIT = 0x0012
1264
+
1265
+ ENDSESSION_CLOSEAPP = 0x0000_0001
1266
+ ENDSESSION_CRITICAL = 0x4000_0000
1267
+ ENDSESSION_LOGOFF = 0x8000_0000
1268
+
1269
+ WM_QUERYENDSESSION = 0x0011
1270
+ WM_ENDSESSION = 0x0016
1271
+
1272
+ class STYLESTRUCT < FFI::Struct
1273
+ extend Util::ScopedStruct
1274
+
1275
+ layout \
1276
+ :styleOld, :ulong,
1277
+ :styleNew, :ulong
1278
+ end
1279
+
1280
+ WM_STYLECHANGING = 0x007c
1281
+ WM_STYLECHANGED = 0x007d
1282
+
1283
+ WM_ENABLE = 0x000a
1284
+
1285
+ WA_INACTIVE = 0
1286
+ WA_ACTIVE = 1
1287
+ WA_CLICKACTIVE = 2
1288
+
1289
+ WM_ACTIVATE = 0x0006
1290
+
1291
+ WM_SETFOCUS = 0x0007
1292
+ WM_KILLFOCUS = 0x0008
1293
+
1294
+ SW_PARENTOPENING = 3
1295
+ SW_PARENTCLOSING = 1
1296
+ SW_OTHERZOOM = 2
1297
+ SW_OTHERUNZOOM = 4
1298
+
1299
+ WM_SHOWWINDOW = 0x0018
1300
+
1301
+ class MINMAXINFO < FFI::Struct
1302
+ extend Util::ScopedStruct
1303
+
1304
+ layout \
1305
+ :ptReserved, POINT,
1306
+ :ptMaxSize, POINT,
1307
+ :ptMaxPosition, POINT,
1308
+ :ptMinTrackSize, POINT,
1309
+ :ptMaxTrackSize, POINT
1310
+ end
1311
+
1312
+ WM_GETMINMAXINFO = 0x0024
1313
+
1314
+ class WINDOWPOS < FFI::Struct
1315
+ extend Util::ScopedStruct
1316
+
1317
+ layout \
1318
+ :hwnd, :pointer,
1319
+ :hwndInsertAfter, :pointer,
1320
+ :x, :int,
1321
+ :y, :int,
1322
+ :cx, :int,
1323
+ :cy, :int,
1324
+ :flags, :int
1325
+ end
1326
+
1327
+ WM_WINDOWPOSCHANGING = 0x0046
1328
+ WM_WINDOWPOSCHANGED = 0x0047
1329
+
1330
+ WM_MOVING = 0x0216
1331
+ WM_MOVE = 0x0003
1332
+
1333
+ WMSZ_LEFT = 1
1334
+ WMSZ_TOP = 3
1335
+ WMSZ_RIGHT = 2
1336
+ WMSZ_BOTTOM = 6
1337
+ WMSZ_TOPLEFT = 4
1338
+ WMSZ_TOPRIGHT = 5
1339
+ WMSZ_BOTTOMLEFT = 7
1340
+ WMSZ_BOTTOMRIGHT = 8
1341
+
1342
+ WM_SIZING = 0x0214
1343
+
1344
+ SIZE_MINIMIZED = 1
1345
+ SIZE_MAXIMIZED = 2
1346
+ SIZE_RESTORED = 0
1347
+ SIZE_MAXHIDE = 4
1348
+ SIZE_MAXSHOW = 3
1349
+
1350
+ WM_SIZE = 0x0005
1351
+
1352
+ SB_LEFT = 6
1353
+ SB_TOP = 6
1354
+ SB_RIGHT = 7
1355
+ SB_BOTTOM = 7
1356
+
1357
+ SB_PAGELEFT = 2
1358
+ SB_PAGERIGHT = 3
1359
+ SB_PAGEUP = 2
1360
+ SB_PAGEDOWN = 3
1361
+
1362
+ SB_LINELEFT = 0
1363
+ SB_LINERIGHT = 1
1364
+ SB_LINEUP = 0
1365
+ SB_LINEDOWN = 1
1366
+
1367
+ SB_THUMBPOSITION = 4
1368
+ SB_THUMBTRACK = 5
1369
+
1370
+ SB_ENDSCROLL = 8
1371
+
1372
+ WM_HSCROLL = 0x0114
1373
+ WM_VSCROLL = 0x0115
1374
+
1375
+ ICON_SMALL = 0
1376
+ ICON_BIG = 1
1377
+ if WINVER >= WINXP
1378
+ ICON_SMALL2 = 2
1379
+ end
1380
+
1381
+ WM_SETICON = 0x0080
1382
+ WM_GETICON = 0x007f
1383
+
1384
+ WM_SETTEXT = 0x000c
1385
+ WM_GETTEXT = 0x000d
1386
+ WM_GETTEXTLENGTH = 0x000e
1387
+
1388
+ WM_SETFONT = 0x0030
1389
+ WM_GETFONT = 0x0031
1390
+
1391
+ WM_ERASEBKGND = 0x0014
1392
+
1393
+ WM_PAINT = 0x000f
1394
+
1395
+ PRF_CHECKVISIBLE = 0x0000_0001
1396
+ PRF_NONCLIENT = 0x0000_0002
1397
+ PRF_CLIENT = 0x0000_0004
1398
+ PRF_ERASEBKGND = 0x0000_0008
1399
+ PRF_CHILDREN = 0x0000_0010
1400
+ PRF_OWNED = 0x0000_0020
1401
+
1402
+ WM_PRINT = 0x0317
1403
+ WM_PRINTCLIENT = 0x0318
1404
+
1405
+ WM_CAPTURECHANGED = 0x0215
1406
+
1407
+ MK_LBUTTON = 0x0001
1408
+ MK_RBUTTON = 0x0002
1409
+ MK_MBUTTON = 0x0010
1410
+ MK_XBUTTON1 = 0x0020
1411
+ MK_XBUTTON2 = 0x0040
1412
+
1413
+ MK_CONTROL = 0x0008
1414
+ MK_SHIFT = 0x0004
1415
+
1416
+ WM_LBUTTONDOWN = 0x0201
1417
+ WM_LBUTTONUP = 0x0202
1418
+ WM_LBUTTONDBLCLK = 0x0203
1419
+
1420
+ WM_RBUTTONDOWN = 0x0204
1421
+ WM_RBUTTONUP = 0x0205
1422
+ WM_RBUTTONDBLCLK = 0x0206
1423
+
1424
+ WM_MBUTTONDOWN = 0x0207
1425
+ WM_MBUTTONUP = 0x0208
1426
+ WM_MBUTTONDBLCLK = 0x0209
1427
+
1428
+ XBUTTON1 = 0x0001
1429
+ XBUTTON2 = 0x0002
1430
+
1431
+ WM_XBUTTONDOWN = 0x020b
1432
+ WM_XBUTTONUP = 0x020c
1433
+ WM_XBUTTONDBLCLK = 0x020d
1434
+
1435
+ WHEEL_DELTA = 120
1436
+
1437
+ WM_MOUSEWHEEL = 0x020a
1438
+ if WINVER >= WINVISTA
1439
+ WM_MOUSEHWHEEL = 0x020e
1440
+ end
1441
+
1442
+ WM_MOUSEMOVE = 0x0200
1443
+
1444
+ WM_SYSKEYDOWN = 0x0104
1445
+ WM_SYSKEYUP = 0x0105
1446
+
1447
+ WM_SYSCHAR = 0x0106
1448
+ WM_SYSDEADCHAR = 0x0107
1449
+
1450
+ WM_KEYDOWN = 0x0100
1451
+ WM_KEYUP = 0x0101
1452
+
1453
+ WM_CHAR = 0x0102
1454
+ WM_DEADCHAR = 0x0103
1455
+
1456
+ WM_CONTEXTMENU = 0x007b
1457
+
1458
+ WM_INITMENU = 0x0116
1459
+ WM_INITMENUPOPUP = 0x0117
1460
+
1461
+ WM_USER = 0x0400
1462
+ WM_APP = 0x8000
1463
+
1464
+ SC_DEFAULT = 0xf160
1465
+
1466
+ SC_MOVE = 0xf010
1467
+ SC_SIZE = 0xf000
1468
+ SC_MINIMIZE = 0xf020
1469
+ SC_MAXIMIZE = 0xf030
1470
+ SC_RESTORE = 0xf120
1471
+ SC_CLOSE = 0xf060
1472
+
1473
+ SC_HSCROLL = 0xf080
1474
+ SC_VSCROLL = 0xf070
1475
+
1476
+ SC_NEXTWINDOW = 0xf040
1477
+ SC_PREVWINDOW = 0xf050
1478
+ SC_ARRANGE = 0xf110
1479
+
1480
+ SC_MOUSEMENU = 0xf090
1481
+ SC_KEYMENU = 0xf100
1482
+ SC_HOTKEY = 0xf150
1483
+
1484
+ SC_TASKLIST = 0xf130
1485
+ SC_SCREENSAVE = 0xf140
1486
+ SC_MONITORPOWER = 0xf170
1487
+
1488
+ SC_CONTEXTHELP = 0xf180
1489
+
1490
+ (SYSID = {}).
1491
+ instance_variable_set(:@last, 0xf00)
1492
+
1493
+ class << SYSID
1494
+ private :[]=, :store
1495
+
1496
+ def [](key)
1497
+ (id = fetch(key, nil)) ?
1498
+ id :
1499
+ self[key] = (@last -= 1) << 4
1500
+ end
1501
+ end
1502
+
1503
+ WM_SYSCOMMAND = 0x0112
1504
+
1505
+ (ID = {}).
1506
+ instance_variable_set(:@last, WM_APP)
1507
+
1508
+ class << ID
1509
+ private :[]=, :store
1510
+
1511
+ def [](key)
1512
+ (id = fetch(key, nil)) ?
1513
+ id :
1514
+ self[key] = @last += 1
1515
+ end
1516
+ end
1517
+
1518
+ WM_COMMAND = 0x0111
1519
+
1520
+ class NMHDR < FFI::Struct
1521
+ extend Util::ScopedStruct
1522
+
1523
+ layout \
1524
+ :hwndFrom, :pointer,
1525
+ :idFrom, :uint,
1526
+ :code, :uint
1527
+ end
1528
+
1529
+ WM_NOTIFY = 0x004e
1530
+
1531
+ WM_CTLCOLORBTN = 0x0135
1532
+
1533
+ WM_CTLCOLORSTATIC = 0x0138
1534
+
1535
+ WM_CTLCOLOREDIT = 0x0133
1536
+
1537
+ WM_CTLCOLORLISTBOX = 0x0134
1538
+
1539
+ WM_VKEYTOITEM = 0x002e
1540
+ WM_CHARTOITEM = 0x002f
1541
+
1542
+ class DELETEITEMSTRUCT < FFI::Struct
1543
+ extend Util::ScopedStruct
1544
+
1545
+ layout \
1546
+ :CtlType, :uint,
1547
+ :CtlID, :uint,
1548
+ :itemID, :uint,
1549
+ :hwndItem, :pointer,
1550
+ :itemData, :ulong
1551
+ end
1552
+
1553
+ WM_DELETEITEM = 0x002d
1554
+
1555
+ class COMPAREITEMSTRUCT < FFI::Struct
1556
+ extend Util::ScopedStruct
1557
+
1558
+ layout \
1559
+ :CtlType, :uint,
1560
+ :CtlID, :uint,
1561
+ :hwndItem, :pointer,
1562
+ :itemID1, :uint,
1563
+ :itemData1, :ulong,
1564
+ :itemID2, :uint,
1565
+ :itemData2, :ulong,
1566
+ :dwLocaleId, :ulong
1567
+ end
1568
+
1569
+ WM_COMPAREITEM = 0x0039
1570
+
1571
+ WM_CTLCOLORSCROLLBAR = 0x0137
1572
+
1573
+ ODT_MENU = 1
1574
+ ODT_BUTTON = 4
1575
+ ODT_STATIC = 5
1576
+ ODT_LISTBOX = 2
1577
+ ODT_COMBOBOX = 3
1578
+
1579
+ class MEASUREITEMSTRUCT < FFI::Struct
1580
+ extend Util::ScopedStruct
1581
+
1582
+ layout \
1583
+ :CtlType, :uint,
1584
+ :CtlID, :uint,
1585
+ :itemID, :uint,
1586
+ :itemWidth, :uint,
1587
+ :itemHeight, :uint,
1588
+ :itemData, :ulong
1589
+ end
1590
+
1591
+ WM_MEASUREITEM = 0x002c
1592
+
1593
+ ODA_DRAWENTIRE = 0x0001
1594
+ ODA_FOCUS = 0x0004
1595
+ ODA_SELECT = 0x0002
1596
+
1597
+ ODS_DEFAULT = 0x0020
1598
+ ODS_GRAYED = 0x0002
1599
+ ODS_SELECTED = 0x0001
1600
+ ODS_CHECKED = 0x0008
1601
+
1602
+ ODS_DISABLED = 0x0004
1603
+ ODS_INACTIVE = 0x0080
1604
+ ODS_FOCUS = 0x0010
1605
+ ODS_HOTLIGHT = 0x0040
1606
+
1607
+ ODS_NOFOCUSRECT = 0x0200
1608
+ ODS_NOACCEL = 0x0100
1609
+
1610
+ ODS_COMBOBOXEDIT = 0x1000
1611
+
1612
+ class DRAWITEMSTRUCT < FFI::Struct
1613
+ extend Util::ScopedStruct
1614
+
1615
+ layout \
1616
+ :CtlType, :uint,
1617
+ :CtlID, :uint,
1618
+ :itemID, :uint,
1619
+ :itemAction, :uint,
1620
+ :itemState, :uint,
1621
+ :hwndItem, :pointer,
1622
+ :hDC, :pointer,
1623
+ :rcItem, RECT,
1624
+ :itemData, :ulong
1625
+ end
1626
+
1627
+ WM_DRAWITEM = 0x002b
1628
+
1629
+ DLGC_WANTMESSAGE = 0x0004
1630
+ DLGC_WANTALLKEYS = 0x0004
1631
+ DLGC_WANTTAB = 0x0002
1632
+ DLGC_WANTARROWS = 0x0001
1633
+ DLGC_WANTCHARS = 0x0080
1634
+
1635
+ DLGC_BUTTON = 0x2000
1636
+ DLGC_DEFPUSHBUTTON = 0x0010
1637
+ DLGC_UNDEFPUSHBUTTON = 0x0020
1638
+ DLGC_RADIOBUTTON = 0x0040
1639
+ DLGC_STATIC = 0x0100
1640
+ DLGC_HASSETSEL = 0x0008
1641
+
1642
+ WM_GETDLGCODE = 0x0087
1643
+
1644
+ attach_function :RegisterWindowMessage, :RegisterWindowMessageW, [
1645
+ :buffer_in
1646
+ ], :uint
1647
+
1648
+ DM_REPOSITION = WM_USER + 2
1649
+
1650
+ DM_SETDEFID = WM_USER + 1
1651
+
1652
+ DC_HASDEFID = 0x534b
1653
+
1654
+ DM_GETDEFID = WM_USER + 0
1655
+
1656
+ attach_function :SendMessage, :SendMessageW, [
1657
+ :pointer,
1658
+ :uint,
1659
+ :uint,
1660
+ :long
1661
+ ], :long
1662
+
1663
+ attach_function :PostMessage, :PostMessageW, [
1664
+ :pointer,
1665
+ :uint,
1666
+ :uint,
1667
+ :long
1668
+ ], :int
1669
+
1670
+ attach_function :PostQuitMessage, [
1671
+ :int
1672
+ ], :void
1673
+
1674
+ class MSG < FFI::Struct
1675
+ extend Util::ScopedStruct
1676
+
1677
+ layout \
1678
+ :hwnd, :pointer,
1679
+ :message, :uint,
1680
+ :wParam, :uint,
1681
+ :lParam, :long,
1682
+ :time, :ulong,
1683
+ :pt, POINT
1684
+ end
1685
+
1686
+ PM_NOREMOVE = 0x0000
1687
+ PM_REMOVE = 0x0001
1688
+ PM_NOYIELD = 0x0002
1689
+
1690
+ attach_function :PeekMessage, :PeekMessageW, [
1691
+ MSG.by_ref(:out),
1692
+ :pointer,
1693
+ :uint,
1694
+ :uint,
1695
+ :uint
1696
+ ], :int
1697
+
1698
+ attach_function :GetMessage, :GetMessageW, [
1699
+ MSG.by_ref(:out),
1700
+ :pointer,
1701
+ :uint,
1702
+ :uint
1703
+ ], :int
1704
+
1705
+ attach_function :IsDialogMessage, [
1706
+ :pointer,
1707
+ MSG.by_ref(:in)
1708
+ ], :int
1709
+
1710
+ attach_function :TranslateAccelerator, :TranslateAcceleratorW, [
1711
+ :pointer,
1712
+ :pointer,
1713
+ MSG.by_ref(:in)
1714
+ ], :int
1715
+
1716
+ attach_function :TranslateMessage, [
1717
+ MSG.by_ref(:in)
1718
+ ], :int
1719
+
1720
+ attach_function :DispatchMessage, :DispatchMessageW, [
1721
+ MSG.by_ref(:in)
1722
+ ], :long
1723
+
1724
+ attach_function :CreateMenu, [
1725
+
1726
+ ], :pointer
1727
+
1728
+ attach_function :CreatePopupMenu, [
1729
+
1730
+ ], :pointer
1731
+
1732
+ attach_function :DestroyMenu, [
1733
+ :pointer
1734
+ ], :int
1735
+
1736
+ MF_BYCOMMAND = 0x0000_0000
1737
+ MF_BYPOSITION = 0x0000_0400
1738
+
1739
+ MF_POPUP = 0x0000_0010
1740
+ MF_STRING = 0x0000_0000
1741
+ MF_BITMAP = 0x0000_0004
1742
+ MF_OWNERDRAW = 0x0000_0100
1743
+ MF_SEPARATOR = 0x0000_0800
1744
+
1745
+ MF_MENUBARBREAK = 0x0000_0020
1746
+ MF_MENUBREAK = 0x0000_0040
1747
+ MF_RIGHTJUSTIFY = 0x0000_4000
1748
+
1749
+ MF_DEFAULT = 0x0000_1000
1750
+ MF_ENABLED = 0x0000_0000
1751
+ MF_DISABLED = 0x0000_0002
1752
+ MF_GRAYED = 0x0000_0001
1753
+ MF_CHECKED = 0x0000_0008
1754
+ MF_UNCHECKED = 0x0000_0000
1755
+ MF_HILITE = 0x0000_0080
1756
+ MF_UNHILITE = 0x0000_0000
1757
+
1758
+ MFT_RADIOCHECK = 0x0000_0200
1759
+
1760
+ MFS_GRAYED = 0x0000_0003
1761
+
1762
+ attach_function :AppendMenu, :AppendMenuW, [
1763
+ :pointer,
1764
+ :uint,
1765
+ :uint,
1766
+ :buffer_in
1767
+ ], :int
1768
+
1769
+ attach_function :InsertMenu, :InsertMenuW, [
1770
+ :pointer,
1771
+ :uint,
1772
+ :uint,
1773
+ :uint,
1774
+ :buffer_in
1775
+ ], :int
1776
+
1777
+ attach_function :ModifyMenu, :ModifyMenuW, [
1778
+ :pointer,
1779
+ :uint,
1780
+ :uint,
1781
+ :uint,
1782
+ :buffer_in
1783
+ ], :int
1784
+
1785
+ attach_function :GetMenuItemID, [
1786
+ :pointer,
1787
+ :int
1788
+ ], :uint
1789
+
1790
+ attach_function :GetSubMenu, [
1791
+ :pointer,
1792
+ :int
1793
+ ], :pointer
1794
+
1795
+ attach_function :RemoveMenu, [
1796
+ :pointer,
1797
+ :uint,
1798
+ :uint
1799
+ ], :int
1800
+
1801
+ attach_function :DeleteMenu, [
1802
+ :pointer,
1803
+ :uint,
1804
+ :uint
1805
+ ], :int
1806
+
1807
+ attach_function :SetMenuDefaultItem, [
1808
+ :pointer,
1809
+ :uint,
1810
+ :uint
1811
+ ], :int
1812
+
1813
+ GMDI_USEDISABLED = 0x0001
1814
+ GMDI_GOINTOPOPUPS = 0x0002
1815
+
1816
+ attach_function :GetMenuDefaultItem, [
1817
+ :pointer,
1818
+ :uint,
1819
+ :uint
1820
+ ], :uint
1821
+
1822
+ attach_function :EnableMenuItem, [
1823
+ :pointer,
1824
+ :uint,
1825
+ :uint
1826
+ ], :int
1827
+
1828
+ attach_function :CheckMenuItem, [
1829
+ :pointer,
1830
+ :uint,
1831
+ :uint
1832
+ ], :ulong
1833
+
1834
+ attach_function :CheckMenuRadioItem, [
1835
+ :pointer,
1836
+ :uint,
1837
+ :uint,
1838
+ :uint,
1839
+ :uint
1840
+ ], :int
1841
+
1842
+ attach_function :HiliteMenuItem, [
1843
+ :pointer,
1844
+ :pointer,
1845
+ :uint,
1846
+ :uint
1847
+ ], :int
1848
+
1849
+ attach_function :GetMenuState, [
1850
+ :pointer,
1851
+ :uint,
1852
+ :uint
1853
+ ], :uint
1854
+
1855
+ MIIM_FTYPE = 0x0000_0100
1856
+ MIIM_STATE = 0x0000_0001
1857
+ MIIM_ID = 0x0000_0002
1858
+ MIIM_SUBMENU = 0x0000_0004
1859
+ MIIM_CHECKMARKS = 0x0000_0008
1860
+ MIIM_DATA = 0x0000_0020
1861
+ MIIM_STRING = 0x0000_0040
1862
+ MIIM_BITMAP = 0x0000_0080
1863
+
1864
+ class MENUITEMINFO < FFI::Struct
1865
+ extend Util::ScopedStruct
1866
+
1867
+ layout \
1868
+ :cbSize, :uint,
1869
+ :fMask, :uint,
1870
+ :fType, :uint,
1871
+ :fState, :uint,
1872
+ :wID, :uint,
1873
+ :hSubMenu, :pointer,
1874
+ :hbmpChecked, :pointer,
1875
+ :hbmpUnchecked, :pointer,
1876
+ :dwItemData, :ulong,
1877
+ :dwTypeData, :pointer,
1878
+ :cch, :uint,
1879
+ :hbmpItem, :pointer
1880
+ end
1881
+
1882
+ attach_function :InsertMenuItem, :InsertMenuItemW, [
1883
+ :pointer,
1884
+ :uint,
1885
+ :int,
1886
+ MENUITEMINFO.by_ref(:in)
1887
+ ], :int
1888
+
1889
+ attach_function :SetMenuItemInfo, :SetMenuItemInfoW, [
1890
+ :pointer,
1891
+ :uint,
1892
+ :int,
1893
+ MENUITEMINFO.by_ref(:in)
1894
+ ], :int
1895
+
1896
+ attach_function :GetMenuItemInfo, :GetMenuItemInfoW, [
1897
+ :pointer,
1898
+ :uint,
1899
+ :int,
1900
+ MENUITEMINFO.by_ref
1901
+ ], :int
1902
+
1903
+ TPM_LEFTBUTTON = 0x0000
1904
+ TPM_RIGHTBUTTON = 0x0002
1905
+
1906
+ TPM_LEFTALIGN = 0x0000
1907
+ TPM_CENTERALIGN = 0x0004
1908
+ TPM_RIGHTALIGN = 0x0008
1909
+
1910
+ TPM_TOPALIGN = 0x0000
1911
+ TPM_VCENTERALIGN = 0x0010
1912
+ TPM_BOTTOMALIGN = 0x0020
1913
+
1914
+ TPM_HORIZONTAL = 0x0000
1915
+ TPM_VERTICAL = 0x0040
1916
+
1917
+ TPM_NONOTIFY = 0x0080
1918
+ TPM_RETURNCMD = 0x0100
1919
+
1920
+ TPM_RECURSE = 0x0001
1921
+
1922
+ attach_function :TrackPopupMenu, [
1923
+ :pointer,
1924
+ :uint,
1925
+ :int,
1926
+ :int,
1927
+ :int,
1928
+ :pointer,
1929
+ RECT.by_ref(:in)
1930
+ ], :int
1931
+
1932
+ attach_function :EndMenu, [
1933
+
1934
+ ], :int
1935
+
1936
+ FVIRTKEY = 1
1937
+ FCONTROL = 0x08
1938
+ FSHIFT = 0x04
1939
+ FALT = 0x10
1940
+
1941
+ VK_LBUTTON = 0x01
1942
+ VK_RBUTTON = 0x02
1943
+ VK_MBUTTON = 0x04
1944
+ VK_XBUTTON1 = 0x05
1945
+ VK_XBUTTON2 = 0x06
1946
+
1947
+ VK_CONTROL = 0x11
1948
+ VK_SHIFT = 0x10
1949
+ VK_MENU = 0x12
1950
+
1951
+ VK_LCONTROL = 0xa2
1952
+ VK_RCONTROL = 0xa3
1953
+ VK_LSHIFT = 0xa0
1954
+ VK_RSHIFT = 0xa1
1955
+ VK_LMENU = 0xa4
1956
+ VK_RMENU = 0xa5
1957
+ VK_LWIN = 0x5b
1958
+ VK_RWIN = 0x5c
1959
+
1960
+ VK_F1 = 0x70
1961
+ VK_F2 = 0x71
1962
+ VK_F3 = 0x72
1963
+ VK_F4 = 0x73
1964
+ VK_F5 = 0x74
1965
+ VK_F6 = 0x75
1966
+ VK_F7 = 0x76
1967
+ VK_F8 = 0x77
1968
+ VK_F9 = 0x78
1969
+ VK_F10 = 0x79
1970
+ VK_F11 = 0x7a
1971
+ VK_F12 = 0x7b
1972
+
1973
+ VK_SNAPSHOT = 0x2c
1974
+ VK_PAUSE = 0x13
1975
+ VK_CANCEL = 0x03
1976
+
1977
+ VK_CAPITAL = 0x14
1978
+ VK_NUMLOCK = 0x90
1979
+ VK_SCROLL = 0x91
1980
+
1981
+ VK_ESCAPE = 0x1b
1982
+ VK_RETURN = 0x0d
1983
+ VK_TAB = 0x09
1984
+ VK_SPACE = 0x20
1985
+
1986
+ VK_INSERT = 0x2d
1987
+ VK_DELETE = 0x2e
1988
+ VK_BACK = 0x08
1989
+
1990
+ VK_HOME = 0x24
1991
+ VK_END = 0x23
1992
+ VK_PRIOR = 0x21
1993
+ VK_NEXT = 0x22
1994
+ VK_LEFT = 0x25
1995
+ VK_RIGHT = 0x27
1996
+ VK_UP = 0x26
1997
+ VK_DOWN = 0x28
1998
+
1999
+ VK_NUMPAD0 = 0x60
2000
+ VK_NUMPAD1 = 0x61
2001
+ VK_NUMPAD2 = 0x62
2002
+ VK_NUMPAD3 = 0x63
2003
+ VK_NUMPAD4 = 0x64
2004
+ VK_NUMPAD5 = 0x65
2005
+ VK_NUMPAD6 = 0x66
2006
+ VK_NUMPAD7 = 0x67
2007
+ VK_NUMPAD8 = 0x68
2008
+ VK_NUMPAD9 = 0x69
2009
+ VK_DECIMAL = 0x6e
2010
+ VK_ADD = 0x6b
2011
+ VK_SUBTRACT = 0x6d
2012
+ VK_MULTIPLY = 0x6a
2013
+ VK_DIVIDE = 0x6f
2014
+
2015
+ VK_MEDIA_PLAY_PAUSE = 0xb3
2016
+ VK_MEDIA_STOP = 0xb2
2017
+ VK_MEDIA_NEXT_TRACK = 0xb0
2018
+ VK_MEDIA_PREV_TRACK = 0xb1
2019
+
2020
+ VK_VOLUME_MUTE = 0xad
2021
+ VK_VOLUME_UP = 0xaf
2022
+ VK_VOLUME_DOWN = 0xae
2023
+
2024
+ class ACCEL < FFI::Struct
2025
+ extend Util::ScopedStruct
2026
+
2027
+ layout \
2028
+ :fVirt, :uchar,
2029
+ :key, :ushort,
2030
+ :cmd, :ushort
2031
+ end
2032
+
2033
+ attach_function :CreateAcceleratorTable, :CreateAcceleratorTableW, [
2034
+ :pointer,
2035
+ :int
2036
+ ], :pointer
2037
+
2038
+ attach_function :DestroyAcceleratorTable, [
2039
+ :pointer
2040
+ ], :int
2041
+
2042
+ attach_function :CopyAcceleratorTable, :CopyAcceleratorTableW, [
2043
+ :pointer,
2044
+ :pointer,
2045
+ :int
2046
+ ], :int
2047
+
2048
+ BS_PUSHBUTTON = 0x0000_0000
2049
+ BS_DEFPUSHBUTTON = 0x0000_0001
2050
+
2051
+ BS_CHECKBOX = 0x0000_0002
2052
+ BS_AUTOCHECKBOX = 0x0000_0003
2053
+
2054
+ BS_3STATE = 0x0000_0005
2055
+ BS_AUTO3STATE = 0x0000_0006
2056
+
2057
+ BS_RADIOBUTTON = 0x0000_0004
2058
+ BS_AUTORADIOBUTTON = 0x0000_0009
2059
+
2060
+ BS_GROUPBOX = 0x0000_0007
2061
+
2062
+ BS_TEXT = 0x0000_0000
2063
+ BS_BITMAP = 0x0000_0080
2064
+ BS_ICON = 0x0000_0040
2065
+ BS_OWNERDRAW = 0x0000_000b
2066
+
2067
+ BS_LEFT = 0x0000_0100
2068
+ BS_CENTER = 0x0000_0300
2069
+ BS_RIGHT = 0x0000_0200
2070
+
2071
+ BS_TOP = 0x0000_0400
2072
+ BS_VCENTER = 0x0000_0c00
2073
+ BS_BOTTOM = 0x0000_0800
2074
+
2075
+ BS_MULTILINE = 0x0000_2000
2076
+
2077
+ BS_LEFTTEXT = 0x0000_0020
2078
+
2079
+ BS_FLAT = 0x0000_8000
2080
+ BS_PUSHLIKE = 0x0000_1000
2081
+
2082
+ BS_NOTIFY = 0x0000_4000
2083
+
2084
+ BM_SETSTYLE = 0x00f4
2085
+
2086
+ BM_SETIMAGE = 0x00f7
2087
+ BM_GETIMAGE = 0x00f6
2088
+
2089
+ BST_FOCUS = 0x0008
2090
+ BST_PUSHED = 0x0004
2091
+ BST_UNCHECKED = 0x0000
2092
+ BST_CHECKED = 0x0001
2093
+ BST_INDETERMINATE = 0x0002
2094
+
2095
+ BM_SETSTATE = 0x00f3
2096
+ BM_GETSTATE = 0x00f2
2097
+
2098
+ BM_SETCHECK = 0x00f1
2099
+ BM_GETCHECK = 0x00f0
2100
+
2101
+ BM_CLICK = 0x00f5
2102
+ if WINVER >= WINVISTA
2103
+ BM_SETDONTCLICK = 0x00f8
2104
+ end
2105
+
2106
+ BN_SETFOCUS = 6
2107
+ BN_KILLFOCUS = 7
2108
+
2109
+ BN_CLICKED = 0
2110
+ BN_DBLCLK = 5
2111
+
2112
+ SS_NOPREFIX = 0x0000_0080
2113
+ SS_ENDELLIPSIS = 0x0000_4000
2114
+ SS_PATHELLIPSIS = 0x0000_8000
2115
+ SS_WORDELLIPSIS = 0x0000_c000
2116
+ SS_EDITCONTROL = 0x0000_2000
2117
+
2118
+ SS_SIMPLE = 0x0000_000b
2119
+ SS_BITMAP = 0x0000_000e
2120
+ SS_ICON = 0x0000_0003
2121
+ SS_OWNERDRAW = 0x0000_000d
2122
+
2123
+ SS_LEFT = 0x0000_0000
2124
+ SS_LEFTNOWORDWRAP = 0x0000_000c
2125
+ SS_CENTER = 0x0000_0001
2126
+ SS_CENTERIMAGE = 0x0000_0200
2127
+ SS_RIGHT = 0x0000_0002
2128
+ SS_RIGHTJUST = 0x0000_0400
2129
+
2130
+ SS_SUNKEN = 0x0000_1000
2131
+
2132
+ SS_ETCHEDHORZ = 0x0000_0010
2133
+ SS_ETCHEDVERT = 0x0000_0011
2134
+ SS_ETCHEDFRAME = 0x0000_0012
2135
+
2136
+ SS_BLACKFRAME = 0x0000_0007
2137
+ SS_GRAYFRAME = 0x0000_0008
2138
+ SS_WHITEFRAME = 0x0000_0009
2139
+
2140
+ SS_BLACKRECT = 0x0000_0004
2141
+ SS_GRAYRECT = 0x0000_0005
2142
+ SS_WHITERECT = 0x0000_0006
2143
+
2144
+ if WINVER >= WINXP
2145
+ SS_REALSIZECONTROL = 0x0000_0040
2146
+ end
2147
+ SS_REALSIZEIMAGE = 0x0000_0800
2148
+
2149
+ SS_NOTIFY = 0x0000_0100
2150
+
2151
+ STM_SETIMAGE = 0x0172
2152
+ STM_GETIMAGE = 0x0173
2153
+
2154
+ STM_SETICON = 0x0170
2155
+ STM_GETICON = 0x0171
2156
+
2157
+ STN_ENABLE = 2
2158
+ STN_DISABLE = 3
2159
+
2160
+ STN_CLICKED = 0
2161
+ STN_DBLCLK = 1
2162
+
2163
+ ES_NUMBER = 0x2000
2164
+ ES_LOWERCASE = 0x0010
2165
+ ES_UPPERCASE = 0x0008
2166
+ ES_PASSWORD = 0x0020
2167
+ ES_MULTILINE = 0x0004
2168
+ ES_WANTRETURN = 0x1000
2169
+
2170
+ ES_LEFT = 0x0000
2171
+ ES_CENTER = 0x0001
2172
+ ES_RIGHT = 0x0002
2173
+
2174
+ ES_AUTOHSCROLL = 0x0080
2175
+ ES_AUTOVSCROLL = 0x0040
2176
+ ES_NOHIDESEL = 0x0100
2177
+ ES_READONLY = 0x0800
2178
+
2179
+ EM_SETLIMITTEXT = 0x00c5
2180
+ EM_GETLIMITTEXT = 0x00d5
2181
+
2182
+ EM_SETPASSWORDCHAR = 0x00cc
2183
+ EM_GETPASSWORDCHAR = 0x00d2
2184
+
2185
+ EM_SETTABSTOPS = 0x00cb
2186
+ EM_FMTLINES = 0x00c8
2187
+
2188
+ EM_SETSEL = 0x00b1
2189
+ EM_GETSEL = 0x00b0
2190
+
2191
+ EM_REPLACESEL = 0x00c2
2192
+
2193
+ EM_SETRECT = 0x00b3
2194
+ EM_SETRECTNP = 0x00b4
2195
+ EM_GETRECT = 0x00b2
2196
+
2197
+ EC_LEFTMARGIN = 0x0001
2198
+ EC_RIGHTMARGIN = 0x0002
2199
+ EC_USEFONTINFO = 0xffff
2200
+
2201
+ EM_SETMARGINS = 0x00d3
2202
+ EM_GETMARGINS = 0x00d4
2203
+
2204
+ EM_SETHANDLE = 0x00bc
2205
+ EM_GETHANDLE = 0x00bd
2206
+
2207
+ WB_LEFT = 0
2208
+ WB_RIGHT = 1
2209
+ WB_ISDELIMITER = 2
2210
+
2211
+ callback :EDITWORDBREAKPROC, [
2212
+ :buffer_in,
2213
+ :int,
2214
+ :int,
2215
+ :int
2216
+ ], :int
2217
+
2218
+ EM_SETWORDBREAKPROC = 0x00d0
2219
+ EM_GETWORDBREAKPROC = 0x00d1
2220
+
2221
+ EM_SETMODIFY = 0x00b9
2222
+ EM_GETMODIFY = 0x00b8
2223
+
2224
+ EM_CANUNDO = 0x00c6
2225
+ EM_UNDO = 0x00c7
2226
+ EM_EMPTYUNDOBUFFER = 0x00cd
2227
+
2228
+ EM_SCROLL = 0x00b5
2229
+ EM_LINESCROLL = 0x00b6
2230
+ EM_SCROLLCARET = 0x00b7
2231
+ EM_GETTHUMB = 0x00be
2232
+
2233
+ EM_GETLINECOUNT = 0x00ba
2234
+ EM_LINELENGTH = 0x00c1
2235
+ EM_GETLINE = 0x00c4
2236
+ EM_GETFIRSTVISIBLELINE = 0x00ce
2237
+ EM_LINEINDEX = 0x00bb
2238
+ EM_LINEFROMCHAR = 0x00c9
2239
+
2240
+ EM_POSFROMCHAR = 0x00d6
2241
+ EM_CHARFROMPOS = 0x00d7
2242
+
2243
+ EM_SETREADONLY = 0x00cf
2244
+
2245
+ EN_ERRSPACE = 0x0500
2246
+ EN_MAXTEXT = 0x0501
2247
+
2248
+ EN_SETFOCUS = 0x0100
2249
+ EN_KILLFOCUS = 0x0200
2250
+
2251
+ EN_UPDATE = 0x0400
2252
+ EN_CHANGE = 0x0300
2253
+
2254
+ EN_HSCROLL = 0x0601
2255
+ EN_VSCROLL = 0x0602
2256
+
2257
+ LBS_USETABSTOPS = 0x0080
2258
+ LBS_MULTICOLUMN = 0x0200
2259
+ LBS_MULTIPLESEL = 0x0008
2260
+ LBS_EXTENDEDSEL = 0x0800
2261
+ LBS_WANTKEYBOARDINPUT = 0x0400
2262
+ LBS_COMBOBOX = 0x8000
2263
+
2264
+ LBS_HASSTRINGS = 0x0040
2265
+ LBS_OWNERDRAWFIXED = 0x0010
2266
+ LBS_OWNERDRAWVARIABLE = 0x0020
2267
+
2268
+ LBS_SORT = 0x0002
2269
+
2270
+ LBS_DISABLENOSCROLL = 0x1000
2271
+ LBS_NOINTEGRALHEIGHT = 0x0100
2272
+ LBS_NODATA = 0x2000
2273
+ LBS_NOSEL = 0x4000
2274
+ LBS_NOREDRAW = 0x0004
2275
+
2276
+ LBS_NOTIFY = 0x0001
2277
+
2278
+ LBS_STANDARD = WS_BORDER | WS_VSCROLL | LBS_SORT | LBS_NOTIFY
2279
+
2280
+ attach_function :GetListBoxInfo, [
2281
+ :pointer
2282
+ ], :ulong
2283
+
2284
+ DDL_DRIVES = 0x4000
2285
+ DDL_DIRECTORY = 0x0010
2286
+ DDL_EXCLUSIVE = 0x8000
2287
+
2288
+ DDL_READWRITE = 0x0000
2289
+ DDL_READONLY = 0x0001
2290
+ DDL_HIDDEN = 0x0002
2291
+ DDL_SYSTEM = 0x0004
2292
+ DDL_ARCHIVE = 0x0020
2293
+
2294
+ DDL_POSTMSGS = 0x2000
2295
+
2296
+ attach_function :DlgDirList, :DlgDirListW, [
2297
+ :pointer,
2298
+ :buffer_inout,
2299
+ :int,
2300
+ :int,
2301
+ :uint
2302
+ ], :int
2303
+
2304
+ attach_function :DlgDirSelectEx, :DlgDirSelectExW, [
2305
+ :pointer,
2306
+ :buffer_out,
2307
+ :int,
2308
+ :int
2309
+ ], :int
2310
+
2311
+ LB_OKAY = 0
2312
+ LB_ERR = -1
2313
+ LB_ERRSPACE = -2
2314
+
2315
+ LB_INITSTORAGE = 0x01a8
2316
+
2317
+ LB_SETCOUNT = 0x01a7
2318
+ LB_GETCOUNT = 0x018b
2319
+
2320
+ LB_ADDSTRING = 0x0180
2321
+ LB_INSERTSTRING = 0x0181
2322
+ LB_DIR = 0x018d
2323
+ LB_ADDFILE = 0x0196
2324
+
2325
+ LB_DELETESTRING = 0x0182
2326
+ LB_RESETCONTENT = 0x0184
2327
+
2328
+ LB_SETCURSEL = 0x0186
2329
+ LB_GETCURSEL = 0x0188
2330
+
2331
+ LB_SELECTSTRING = 0x018c
2332
+
2333
+ LB_FINDSTRING = 0x018f
2334
+ LB_FINDSTRINGEXACT = 0x01a2
2335
+
2336
+ LB_GETTEXTLEN = 0x018a
2337
+ LB_GETTEXT = 0x0189
2338
+
2339
+ LB_SETITEMDATA = 0x019a
2340
+ LB_GETITEMDATA = 0x0199
2341
+
2342
+ LB_SETSEL = 0x0185
2343
+ LB_GETSEL = 0x0187
2344
+
2345
+ LB_GETSELCOUNT = 0x0190
2346
+ LB_GETSELITEMS = 0x0191
2347
+
2348
+ LB_SELITEMRANGEEX = 0x0183
2349
+
2350
+ LB_SETLOCALE = 0x01a5
2351
+ LB_GETLOCALE = 0x01a6
2352
+
2353
+ LB_SETTABSTOPS = 0x0192
2354
+ LB_SETCOLUMNWIDTH = 0x0195
2355
+ if WINVER >= WINXP
2356
+ LB_GETLISTBOXINFO = 0x01b2
2357
+ end
2358
+
2359
+ LB_SETHORIZONTALEXTENT = 0x0194
2360
+ LB_GETHORIZONTALEXTENT = 0x0193
2361
+
2362
+ LB_SETTOPINDEX = 0x0197
2363
+ LB_GETTOPINDEX = 0x018e
2364
+
2365
+ LB_SETANCHORINDEX = 0x019c
2366
+ LB_GETANCHORINDEX = 0x019d
2367
+
2368
+ LB_SETCARETINDEX = 0x019e
2369
+ LB_GETCARETINDEX = 0x019f
2370
+
2371
+ LB_SETITEMHEIGHT = 0x01a0
2372
+ LB_GETITEMHEIGHT = 0x01a1
2373
+
2374
+ LB_GETITEMRECT = 0x0198
2375
+ LB_ITEMFROMPOINT = 0x01a9
2376
+
2377
+ LBN_ERRSPACE = -2
2378
+
2379
+ LBN_SETFOCUS = 4
2380
+ LBN_KILLFOCUS = 5
2381
+
2382
+ LBN_SELCHANGE = 1
2383
+ LBN_SELCANCEL = 3
2384
+
2385
+ LBN_DBLCLK = 2
2386
+
2387
+ CBS_SIMPLE = 0x0001
2388
+ CBS_DROPDOWN = 0x0002
2389
+ CBS_DROPDOWNLIST = 0x0003
2390
+ CBS_LOWERCASE = 0x4000
2391
+ CBS_UPPERCASE = 0x2000
2392
+
2393
+ CBS_HASSTRINGS = 0x0200
2394
+ CBS_OWNERDRAWFIXED = 0x0010
2395
+ CBS_OWNERDRAWVARIABLE = 0x0020
2396
+
2397
+ CBS_SORT = 0x0100
2398
+
2399
+ CBS_AUTOHSCROLL = 0x0040
2400
+ CBS_DISABLENOSCROLL = 0x0800
2401
+ CBS_NOINTEGRALHEIGHT = 0x0400
2402
+
2403
+ class COMBOBOXINFO < FFI::Struct
2404
+ extend Util::ScopedStruct
2405
+
2406
+ layout \
2407
+ :cbSize, :ulong,
2408
+ :rcItem, RECT,
2409
+ :rcButton, RECT,
2410
+ :stateButton, :ulong,
2411
+ :hwndCombo, :pointer,
2412
+ :hwndItem, :pointer,
2413
+ :hwndList, :pointer
2414
+ end
2415
+
2416
+ attach_function :GetComboBoxInfo, [
2417
+ :pointer,
2418
+ COMBOBOXINFO.by_ref
2419
+ ], :int
2420
+
2421
+ attach_function :DlgDirListComboBox, :DlgDirListComboBoxW, [
2422
+ :pointer,
2423
+ :buffer_inout,
2424
+ :int,
2425
+ :int,
2426
+ :uint
2427
+ ], :int
2428
+
2429
+ attach_function :DlgDirSelectComboBoxEx, :DlgDirSelectComboBoxExW, [
2430
+ :pointer,
2431
+ :buffer_out,
2432
+ :int,
2433
+ :int
2434
+ ], :int
2435
+
2436
+ CB_OKAY = 0
2437
+ CB_ERR = -1
2438
+ CB_ERRSPACE = -2
2439
+
2440
+ CB_LIMITTEXT = 0x0141
2441
+
2442
+ CB_INITSTORAGE = 0x0161
2443
+
2444
+ CB_GETCOUNT = 0x0146
2445
+
2446
+ CB_ADDSTRING = 0x0143
2447
+ CB_INSERTSTRING = 0x014a
2448
+ CB_DIR = 0x0145
2449
+
2450
+ CB_DELETESTRING = 0x0144
2451
+ CB_RESETCONTENT = 0x014b
2452
+
2453
+ CB_SETCURSEL = 0x014e
2454
+ CB_GETCURSEL = 0x0147
2455
+
2456
+ CB_SELECTSTRING = 0x014d
2457
+
2458
+ CB_FINDSTRING = 0x014c
2459
+ CB_FINDSTRINGEXACT = 0x0158
2460
+
2461
+ CB_GETLBTEXTLEN = 0x0149
2462
+ CB_GETLBTEXT = 0x0148
2463
+
2464
+ CB_SETITEMDATA = 0x0151
2465
+ CB_GETITEMDATA = 0x0150
2466
+
2467
+ CB_SETEDITSEL = 0x0142
2468
+ CB_GETEDITSEL = 0x0140
2469
+
2470
+ CB_SETLOCALE = 0x0159
2471
+ CB_GETLOCALE = 0x015a
2472
+
2473
+ if WINVER >= WINXP
2474
+ CB_GETCOMBOBOXINFO = 0x0164
2475
+ end
2476
+
2477
+ CB_SETHORIZONTALEXTENT = 0x015e
2478
+ CB_GETHORIZONTALEXTENT = 0x015d
2479
+
2480
+ CB_SETTOPINDEX = 0x015c
2481
+ CB_GETTOPINDEX = 0x015b
2482
+
2483
+ CB_SETITEMHEIGHT = 0x0153
2484
+ CB_GETITEMHEIGHT = 0x0154
2485
+
2486
+ CB_SETDROPPEDWIDTH = 0x0160
2487
+ CB_GETDROPPEDWIDTH = 0x015f
2488
+
2489
+ CB_GETDROPPEDSTATE = 0x0157
2490
+ CB_GETDROPPEDCONTROLRECT = 0x0152
2491
+
2492
+ CB_SHOWDROPDOWN = 0x014f
2493
+
2494
+ CB_SETEXTENDEDUI = 0x0155
2495
+ CB_GETEXTENDEDUI = 0x0156
2496
+
2497
+ CBN_ERRSPACE = -1
2498
+
2499
+ CBN_SETFOCUS = 3
2500
+ CBN_KILLFOCUS = 4
2501
+
2502
+ CBN_EDITUPDATE = 6
2503
+ CBN_EDITCHANGE = 5
2504
+
2505
+ CBN_SELCHANGE = 1
2506
+ CBN_SELENDOK = 9
2507
+ CBN_SELENDCANCEL = 10
2508
+
2509
+ CBN_DBLCLK = 2
2510
+
2511
+ CBN_DROPDOWN = 7
2512
+ CBN_CLOSEUP = 8
2513
+
2514
+ SBS_HORZ = 0x0000
2515
+ SBS_VERT = 0x0001
2516
+
2517
+ SBS_TOPALIGN = 0x0002
2518
+ SBS_BOTTOMALIGN = 0x0004
2519
+ SBS_LEFTALIGN = 0x0002
2520
+ SBS_RIGHTALIGN = 0x0004
2521
+
2522
+ SBS_SIZEBOX = 0x0008
2523
+ SBS_SIZEGRIP = 0x0010
2524
+
2525
+ SBS_SIZEBOXTOPLEFTALIGN = 0x0002
2526
+ SBS_SIZEBOXBOTTOMRIGHTALIGN = 0x0004
2527
+
2528
+ OBJID_HSCROLL = 0xffff_fffa - 0x1_0000_0000
2529
+ OBJID_VSCROLL = 0xffff_fffb - 0x1_0000_0000
2530
+ OBJID_CLIENT = 0xffff_fffc - 0x1_0000_0000
2531
+
2532
+ class SCROLLBARINFO < FFI::Struct
2533
+ extend Util::ScopedStruct
2534
+
2535
+ layout \
2536
+ :cbSize, :ulong,
2537
+ :rcScrollBar, RECT,
2538
+ :dxyLineButton, :int,
2539
+ :xyThumbTop, :int,
2540
+ :xyThumbBottom, :int,
2541
+ :reserved, :int,
2542
+
2543
+ # 0 - scroll bar itself
2544
+ # 1 - top/right arrow button
2545
+ # 2 - page up/page right region
2546
+ # 3 - scroll box
2547
+ # 4 - page down/page left region
2548
+ # 5 - bottom/left arrow button
2549
+ :rgstate, [:ulong, 6]
2550
+ end
2551
+
2552
+ attach_function :GetScrollBarInfo, [
2553
+ :pointer,
2554
+ :long,
2555
+ SCROLLBARINFO.by_ref
2556
+ ], :int
2557
+
2558
+ SBM_ENABLE_ARROWS = 0x00e4
2559
+
2560
+ SBM_SETRANGE = 0x00e2
2561
+ SBM_SETRANGEREDRAW = 0x00e6
2562
+ SBM_GETRANGE = 0x00e3
2563
+
2564
+ SBM_SETPOS = 0x00e0
2565
+ SBM_GETPOS = 0x00e1
2566
+
2567
+ SBM_SETSCROLLINFO = 0x00e9
2568
+ SBM_GETSCROLLINFO = 0x00ea
2569
+
2570
+ if WINVER >= WINXP
2571
+ SBM_GETSCROLLBARINFO = 0x00eb
2572
+ end
2573
+ end