ffi-wingui-core 0.6.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 350e500580c8bd926466b10016b6cb7b4c353b2e
4
+ data.tar.gz: 84488d64a995b856f64196e3e21c99adce1100aa
5
+ SHA512:
6
+ metadata.gz: fd766f1fff480891c6de1dd17b4fbbbe5781306565f2e66377a53366422eae4400a3fefc72d6ecb7f4f5b79a8a06778fa7168bf15455b817719eb031d85652d7
7
+ data.tar.gz: efce385e13a9b23797787afb45f816b65571bbfcae5d399f991aaa434f86aa0b671d25c2e90db4906d0ac51ace297aab841b0424486357689319a76fec1d7e36
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2011 Radoslav Peev
3
+ Copyright (c) 2011-2013 Radoslav Peev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -29,7 +28,7 @@ def onCreate(hwnd,
29
28
  ]
30
29
 
31
30
  FFI::MemoryPointer.new(ACCEL, accels.count) { |paccels|
32
- accels.each.with_index { |data, i|
31
+ accels.each_with_index { |data, i|
33
32
  accel = ACCEL.new(paccels + i * ACCEL.size)
34
33
 
35
34
  accel[:fVirt], accel[:key], accel[:cmd] = data
@@ -162,7 +161,7 @@ begin
162
161
 
163
162
  when WM_ACTIVATE
164
163
  onActivate(hwnd,
165
- LOWORD(wParam), HIWORD(wParam) > 0,
164
+ LOWORD(wParam), HIWORD(wParam) != 0,
166
165
  FFI::Pointer.new(lParam)
167
166
  )
168
167
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -2,7 +2,6 @@ WINGUI_VISUAL_STYLES = false
2
2
  WINGUI_DPI_AWARE = false
3
3
 
4
4
  require 'ffi-wingui-core'
5
- require 'ffi-wingui-core/ocra'
6
5
 
7
6
  include WinGUI
8
7
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -0,0 +1,151 @@
1
+ require 'ffi-wingui-core'
2
+
3
+ include WinGUI
4
+
5
+ WndExtra = Struct.new(
6
+ :hfont
7
+ )
8
+
9
+ def onCreate(hwnd,
10
+ cs
11
+ )
12
+ xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
13
+
14
+ LOGFONT.new { |lf|
15
+ lf[:lfHeight] = DPIAwareFontHeight(24)
16
+ lf[:lfItalic] = 1
17
+ lf[:lfFaceName].to_ptr.put_bytes(0, L('Verdana'))
18
+
19
+ xtra[:hfont] = CreateFontIndirect(lf)
20
+ }
21
+
22
+ 0
23
+ end
24
+
25
+ def onDestroy(hwnd)
26
+ xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
27
+
28
+ DeleteObject(xtra[:hfont])
29
+
30
+ PostQuitMessage(0); 0
31
+ end
32
+
33
+ def onPaint(hwnd,
34
+ ps
35
+ )
36
+ xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
37
+
38
+ SetBkColor(ps[:hdc], RGB(255, 0, 0))
39
+ SetTextColor(ps[:hdc], RGB(255, 255, 255))
40
+
41
+ UseObjects(ps[:hdc], xtra[:hfont]) {
42
+ RECT.new { |rect|
43
+ GetClientRect(hwnd, rect)
44
+
45
+ DrawText(ps[:hdc],
46
+ L('The quick brown fox jumps over the lazy dog. 1234567890'), -1,
47
+ rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER
48
+ )
49
+ }
50
+ }
51
+
52
+ 0
53
+ end
54
+
55
+ WindowProc = FFI::Function.new(:long,
56
+ [:pointer, :uint, :uint, :long],
57
+ convention: :stdcall
58
+ ) { |hwnd, uMsg, wParam, lParam|
59
+ begin
60
+ result = case uMsg
61
+ when WM_NCCREATE
62
+ DefWindowProc(hwnd, uMsg, wParam, lParam)
63
+
64
+ SetWindowLong(hwnd,
65
+ GWL_USERDATA,
66
+ CREATESTRUCT.new(FFI::Pointer.new(lParam))[:lpCreateParams].to_i
67
+ )
68
+
69
+ 1
70
+ when WM_CREATE
71
+ onCreate(hwnd, CREATESTRUCT.new(FFI::Pointer.new(lParam)))
72
+ when WM_DESTROY
73
+ onDestroy(hwnd)
74
+
75
+ when WM_PAINT
76
+ DoPaint(hwnd) { |ps| result = onPaint(hwnd, ps) }
77
+ when WM_PRINTCLIENT
78
+ DoPrintClient(hwnd, wParam) { |ps| result = onPaint(hwnd, ps) }
79
+ end
80
+
81
+ result || DefWindowProc(hwnd, uMsg, wParam, lParam)
82
+ rescue SystemExit => ex
83
+ PostQuitMessage(ex.status)
84
+ rescue
85
+ case MessageBox(hwnd,
86
+ L(Util.FormatException($!)),
87
+ APPNAME,
88
+ MB_ABORTRETRYIGNORE | MB_ICONERROR
89
+ )
90
+ when IDABORT
91
+ PostQuitMessage(2)
92
+ when IDRETRY
93
+ retry
94
+ end
95
+ end
96
+ }
97
+
98
+ def main
99
+ Util.Id2RefTrack(xtra = WndExtra.new)
100
+
101
+ WNDCLASSEX.new { |wc|
102
+ wc[:cbSize] = wc.size
103
+ wc[:style] = CS_HREDRAW | CS_VREDRAW
104
+ wc[:lpfnWndProc] = WindowProc
105
+ wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
106
+ wc[:hInstance] = GetModuleHandle(nil)
107
+ wc[:hIcon] = LoadIcon(nil, IDI_APPLICATION)
108
+ wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
109
+ wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
110
+
111
+ PWSTR(APPNAME) { |className|
112
+ wc[:lpszClassName] = className
113
+
114
+ DetonateLastError(0, :RegisterClassEx,
115
+ wc
116
+ )
117
+ }
118
+ }
119
+
120
+ hwnd = CreateWindowEx(
121
+ WS_EX_CLIENTEDGE, APPNAME, APPNAME, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
122
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
123
+ nil, nil, GetModuleHandle(nil), FFI::Pointer.new(xtra.object_id)
124
+ )
125
+
126
+ raise "CreateWindowEx failed (last error: #{GetLastError()})" if
127
+ hwnd.null? && GetLastError() != 0
128
+
129
+ exit(0) if hwnd.null?
130
+
131
+ AnimateWindow(hwnd, 1000, AW_ACTIVATE | AW_BLEND)
132
+
133
+ MSG.new { |msg|
134
+ until DetonateLastError(-1, :GetMessage,
135
+ msg, nil, 0, 0
136
+ ) == 0
137
+ TranslateMessage(msg)
138
+ DispatchMessage(msg)
139
+ end
140
+
141
+ exit(msg[:wParam])
142
+ }
143
+ rescue
144
+ MessageBox(hwnd,
145
+ L(Util.FormatException($!)),
146
+ APPNAME,
147
+ MB_ICONERROR
148
+ ); exit(1)
149
+ end
150
+
151
+ main
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,11 +1,11 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
6
5
  WndExtra = Struct.new(
7
- :scribbles,
8
- :hpen
6
+ :hpen,
7
+ :curpos,
8
+ :scribbles
9
9
  )
10
10
 
11
11
  def onCreate(hwnd,
@@ -13,15 +13,15 @@ def onCreate(hwnd,
13
13
  )
14
14
  xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
15
15
 
16
- xtra[:scribbles] = []
17
-
18
16
  LOGPEN.new { |lp|
19
- lp[:lopnWidth][:x] = DPIAwareX(4)
17
+ lp[:lopnWidth][:x] = DPIAwareX(10)
20
18
  lp[:lopnColor] = RGB(255, 0, 0)
21
19
 
22
20
  xtra[:hpen] = CreatePenIndirect(lp)
23
21
  }
24
22
 
23
+ xtra[:scribbles] = []
24
+
25
25
  0
26
26
  end
27
27
 
@@ -38,36 +38,32 @@ def onPaint(hwnd,
38
38
  )
39
39
  xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
40
40
 
41
- hdefpen = SelectObject(ps[:hdc], xtra[:hpen])
42
-
43
- xtra[:scribbles].each { |scribble|
44
- MoveToEx(ps[:hdc], *scribble[0], nil)
41
+ UseObjects(ps[:hdc], xtra[:hpen]) {
42
+ xtra[:scribbles].each { |scribble|
43
+ MoveToEx(ps[:hdc], *scribble[0], nil)
45
44
 
46
- scribble.each { |x, y|
47
- LineTo(ps[:hdc], x, y)
45
+ scribble.each { |x, y|
46
+ LineTo(ps[:hdc], x, y)
47
+ }
48
48
  }
49
49
  }
50
50
 
51
51
  0
52
- ensure
53
- SelectObject(ps[:hdc], hdefpen)
54
52
  end
55
53
 
56
54
  def onLButtonDown(hwnd,
57
55
  x, y
58
56
  )
59
- xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
60
-
61
57
  SetCapture(hwnd)
62
58
 
63
- (xtra[:scribbles] << []).last << [x, y]
59
+ xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
60
+
61
+ xtra[:curpos] = [x, y]
62
+ xtra[:scribbles] << [[x, y]]
64
63
 
65
64
  RECT.new { |rect|
66
- rect[:left] = x - DPIAwareX(2)
67
- rect[:top] = y - DPIAwareY(2)
68
- rect[:right] = x + DPIAwareX(2)
69
- rect[:bottom] = y + DPIAwareY(2)
70
-
65
+ SetRect(rect, x, y, x, y)
66
+ InflateRect(rect, *DPIAwareXY(5, 5))
71
67
  InvalidateRect(hwnd, rect, 1)
72
68
  }
73
69
 
@@ -91,7 +87,14 @@ def onMouseMove(hwnd,
91
87
 
92
88
  xtra[:scribbles].last << [x, y]
93
89
 
94
- InvalidateRect(hwnd, nil, 0)
90
+ UseDC(hwnd) { |hdc|
91
+ UseObjects(hdc, xtra[:hpen]) {
92
+ MoveToEx(hdc, *xtra[:curpos], nil)
93
+ LineTo(hdc, x, y)
94
+
95
+ xtra[:curpos] = [x, y]
96
+ }
97
+ }
95
98
 
96
99
  0
97
100
  end
@@ -131,19 +134,7 @@ begin
131
134
  onDestroy(hwnd)
132
135
 
133
136
  when WM_PAINT
134
- r = nil
135
-
136
- if GetUpdateRect(hwnd, nil, 0) != 0
137
- PAINTSTRUCT.new { |ps|
138
- BeginPaint(hwnd, ps)
139
-
140
- begin
141
- r = onPaint(hwnd, ps)
142
- ensure
143
- EndPaint(hwnd, ps)
144
- end
145
- }
146
- end
137
+ DoPaint(hwnd) { |ps| result = onPaint(hwnd, ps) }
147
138
 
148
139
  when WM_LBUTTONDOWN
149
140
  onLButtonDown(hwnd, LOSHORT(lParam), HISHORT(lParam))
@@ -1,5 +1,4 @@
1
1
  require 'ffi-wingui-core'
2
- require 'ffi-wingui-core/ocra'
3
2
 
4
3
  include WinGUI
5
4
 
@@ -1,3396 +1,4 @@
1
- #tstart = Time.now
2
- require 'ffi'
3
- #tffi = Time.now
4
-
5
- #{ WINGUI_xxx
6
- WINGUI_VISUAL_STYLES = true unless defined?(WINGUI_VISUAL_STYLES)
7
- WINGUI_DPI_AWARE = true unless defined?(WINGUI_DPI_AWARE)
8
- #}
9
-
10
- module WinGUI
11
- extend FFI::Library
12
-
13
- #{ common
14
- module Util
15
- def FormatException(ex)
16
- str, trace = ex.to_s, ex.backtrace
17
-
18
- str << "\n\n-- backtrace --\n\n" << trace.join("\n") if trace
19
-
20
- str
21
- end
22
-
23
- module_function :FormatException
24
-
25
- Id2Ref = {}
26
-
27
- def Id2RefTrack(object)
28
- Id2Ref[object.object_id] = object
29
-
30
- ObjectSpace.define_finalizer(object, -> id {
31
- Id2Ref.delete(id)
32
- })
33
- end
34
-
35
- module_function :Id2RefTrack
36
-
37
- unless FFI::Struct.respond_to?(:by_ref)
38
- class << FFI::Struct
39
- def by_ref(*args)
40
- FFI::Type::Builtin::POINTER
41
- end
42
- end
43
- end
44
-
45
- module ScopedStruct
46
- def new(*args)
47
- raise ArgumentError, 'Cannot accept both arguments and a block' if
48
- args.length > 0 && block_given?
49
-
50
- struct = super
51
-
52
- return struct unless block_given?
53
-
54
- begin
55
- yield struct
56
- ensure
57
- struct.pointer.free
58
-
59
- p "Native memory for #{struct} freed" if $DEBUG
60
- end
61
-
62
- nil
63
- end
64
- end
65
- end
66
-
67
- #{ INVALID_xxx
68
- INVALID_HANDLE_VALUE = FFI::Pointer.new(-1)
69
- #}
70
-
71
- def MAKEWORD(lobyte, hibyte)
72
- (lobyte & 0xff) | ((hibyte & 0xff) << 8)
73
- end
74
-
75
- def LOBYTE(word)
76
- word & 0xff
77
- end
78
-
79
- def HIBYTE(word)
80
- (word >> 8) & 0xff
81
- end
82
-
83
- module_function :MAKEWORD, :LOBYTE, :HIBYTE
84
-
85
- def MAKELONG(loword, hiword)
86
- (loword & 0xffff) | ((hiword & 0xffff) << 16)
87
- end
88
-
89
- def LOWORD(long)
90
- long & 0xffff
91
- end
92
-
93
- def HIWORD(long)
94
- (long >> 16) & 0xffff
95
- end
96
-
97
- def LOSHORT(long)
98
- ((loshort = LOWORD(long)) > 0x7fff) ? loshort - 0x1_0000 : loshort
99
- end
100
-
101
- def HISHORT(long)
102
- ((hishort = HIWORD(long)) > 0x7fff) ? hishort - 0x1_0000 : hishort
103
- end
104
-
105
- module_function :MAKELONG, :LOWORD, :HIWORD, :LOSHORT, :HISHORT
106
-
107
- def L(str)
108
- (str << "\0").encode!('utf-16le')
109
- end
110
-
111
- def PWSTR(wstr)
112
- raise 'Invalid Unicode string' unless
113
- wstr.encoding == Encoding::UTF_16LE && wstr[-1] == L('')
114
-
115
- ptr = FFI::MemoryPointer.new(:ushort, wstr.length).
116
- put_bytes(0, wstr)
117
-
118
- return ptr unless block_given?
119
-
120
- begin
121
- yield ptr
122
- ensure
123
- ptr.free
124
-
125
- p "Native copy of '#{wstr[0...-1].encode($0.encoding)}' freed" if $DEBUG
126
- end
127
-
128
- nil
129
- end
130
-
131
- module_function :L, :PWSTR
132
-
133
- APPNAME = L(File.basename($0, '.rbw'))
134
-
135
- class POINT < FFI::Struct
136
- extend Util::ScopedStruct
137
-
138
- layout \
139
- :x, :long,
140
- :y, :long
141
- end
142
-
143
- class SIZE < FFI::Struct
144
- extend Util::ScopedStruct
145
-
146
- layout \
147
- :cx, :long,
148
- :cy, :long
149
- end
150
-
151
- class RECT < FFI::Struct
152
- extend Util::ScopedStruct
153
-
154
- layout \
155
- :left, :long,
156
- :top, :long,
157
- :right, :long,
158
- :bottom, :long
159
- end
160
- #}
161
-
162
- #{ kernel32
163
- ffi_lib 'kernel32'
164
- ffi_convention :stdcall
165
-
166
- attach_function :SetLastError, [
167
- :ulong
168
- ], :void
169
-
170
- attach_function :GetLastError, [
171
-
172
- ], :ulong
173
-
174
- def Detonate(on, name, *args)
175
- raise "#{name} failed" if
176
- (failed = [*on].include?(result = send(name, *args)))
177
-
178
- result
179
- ensure
180
- yield failed if block_given?
181
- end
182
-
183
- def DetonateLastError(on, name, *args)
184
- raise "#{name} failed (last error: #{GetLastError()})" if
185
- (failed = [*on].include?(result = send(name, *args)))
186
-
187
- result
188
- ensure
189
- yield failed if block_given?
190
- end
191
-
192
- module_function :Detonate, :DetonateLastError
193
-
194
- class OSVERSIONINFOEX < FFI::Struct
195
- extend Util::ScopedStruct
196
-
197
- layout \
198
- :dwOSVersionInfoSize, :ulong,
199
- :dwMajorVersion, :ulong,
200
- :dwMinorVersion, :ulong,
201
- :dwBuildNumber, :ulong,
202
- :dwPlatformId, :ulong,
203
- :szCSDVersion, [:ushort, 128],
204
- :wServicePackMajor, :ushort,
205
- :wServicePackMinor, :ushort,
206
- :wSuiteMask, :ushort,
207
- :wProductType, :uchar,
208
- :wReserved, :uchar
209
- end
210
-
211
- attach_function :GetVersionEx, :GetVersionExW, [
212
- OSVERSIONINFOEX.by_ref
213
- ], :int
214
-
215
- OSVERSION = OSVERSIONINFOEX.new.tap { |ovi|
216
- at_exit { OSVERSION.pointer.free }
217
-
218
- ovi[:dwOSVersionInfoSize] = ovi.size
219
-
220
- DetonateLastError(0, :GetVersionEx,
221
- ovi
222
- )
223
- }
224
-
225
- #{ NTDDI_xxx
226
- NTDDI_WIN2K = 0x05000000
227
-
228
- NTDDI_WIN2KSP1 = 0x05000100
229
- NTDDI_WIN2KSP2 = 0x05000200
230
- NTDDI_WIN2KSP3 = 0x05000300
231
- NTDDI_WIN2KSP4 = 0x05000400
232
-
233
- NTDDI_WINXP = 0x05010000
234
-
235
- NTDDI_WINXPSP1 = 0x05010100
236
- NTDDI_WINXPSP2 = 0x05010200
237
- NTDDI_WINXPSP3 = 0x05010300
238
- NTDDI_WINXPSP4 = 0x05010400
239
-
240
- NTDDI_WS03 = 0x05020000
241
-
242
- NTDDI_WS03SP1 = 0x05020100
243
- NTDDI_WS03SP2 = 0x05020200
244
- NTDDI_WS03SP3 = 0x05020300
245
- NTDDI_WS03SP4 = 0x05020400
246
-
247
- NTDDI_VISTA = 0x06000000
248
-
249
- NTDDI_VISTASP1 = 0x06000100
250
- NTDDI_VISTASP2 = 0x06000200
251
- NTDDI_VISTASP3 = 0x06000300
252
- NTDDI_VISTASP4 = 0x06000400
253
-
254
- NTDDI_WS08 = NTDDI_VISTASP1
255
-
256
- NTDDI_WS08SP2 = NTDDI_VISTASP2
257
- NTDDI_WS08SP3 = NTDDI_VISTASP3
258
- NTDDI_WS08SP4 = NTDDI_VISTASP4
259
-
260
- NTDDI_WIN7 = 0x06010000
261
- #}
262
-
263
- NTDDI_VERSION = MAKELONG(
264
- MAKEWORD(OSVERSION[:wServicePackMinor], OSVERSION[:wServicePackMajor]),
265
- MAKEWORD(OSVERSION[:dwMinorVersion], OSVERSION[:dwMajorVersion])
266
- )
267
-
268
- #{ WINxxx
269
- WIN2K = 0x0500
270
- WINXP = 0x0501
271
- WINVISTA = 0x0600
272
- WIN7 = 0x0601
273
- #}
274
-
275
- WINVER = HIWORD(NTDDI_VERSION)
276
-
277
- def TARGETVER(version, message)
278
- version = MAKELONG(0x0000, version) if version < 0xffff
279
-
280
- exit(-1) if NTDDI_VERSION < version &&
281
- MessageBox(nil,
282
- message,
283
- APPNAME,
284
- MB_YESNO | MB_ICONERROR | MB_DEFBUTTON2
285
- ) == IDNO
286
- end
287
-
288
- module_function :TARGETVER
289
-
290
- attach_function :GetModuleHandle, :GetModuleHandleW, [
291
- :buffer_in
292
- ], :pointer
293
-
294
- attach_function :LoadLibrary, :LoadLibraryW, [
295
- :buffer_in
296
- ], :pointer
297
-
298
- attach_function :FreeLibrary, [
299
- :pointer
300
- ], :int
301
-
302
- if WINVER >= WINXP # ACTCTX
303
- class ACTCTX < FFI::Struct
304
- extend Util::ScopedStruct
305
-
306
- layout \
307
- :cbSize, :ulong,
308
- :dwFlags, :ulong,
309
- :lpSource, :pointer,
310
- :wProcessorArchitecture, :ushort,
311
- :wLangId, :ushort,
312
- :lpAssemblyDirectory, :pointer,
313
- :lpResourceName, :pointer,
314
- :lpApplicationName, :pointer,
315
- :hModule, :pointer
316
- end
317
-
318
- attach_function :CreateActCtx, :CreateActCtxW, [
319
- ACTCTX.by_ref
320
- ], :pointer
321
-
322
- attach_function :ReleaseActCtx, [
323
- :pointer
324
- ], :void
325
-
326
- attach_function :ActivateActCtx, [
327
- :pointer,
328
- :pointer
329
- ], :int
330
-
331
- attach_function :DeactivateActCtx, [
332
- :ulong,
333
- :ulong
334
- ], :int
335
-
336
- COMMON_CONTROLS_ACTCTX = {
337
- handle: INVALID_HANDLE_VALUE,
338
- cookie: FFI::MemoryPointer.new(:ulong),
339
- activated: false
340
- }
341
-
342
- at_exit {
343
- DeactivateActCtx(0, COMMON_CONTROLS_ACTCTX[:cookie].get_ulong(0)) if
344
- COMMON_CONTROLS_ACTCTX[:activated]
345
-
346
- ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle]) unless
347
- COMMON_CONTROLS_ACTCTX[:handle] == INVALID_HANDLE_VALUE
348
-
349
- COMMON_CONTROLS_ACTCTX[:cookie].free
350
- }
351
- end
352
-
353
- def EnableVisualStyles
354
- return unless WINVER >= WINXP
355
-
356
- raise 'Visual styles already enabled' if
357
- COMMON_CONTROLS_ACTCTX[:activated]
358
-
359
- manifest = "#{ENV['TEMP']}/WinGUI.Common-Controls.manifest"
360
-
361
- File.open(manifest, 'w:utf-8') { |file|
362
- file << <<-XML
363
- <?xml version='1.0' encoding='utf-8' standalone='yes' ?>
364
- <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
365
- <dependency>
366
- <dependentAssembly>
367
- <assemblyIdentity
368
- type='Win32'
369
- name='Microsoft.Windows.Common-Controls'
370
- version='6.0.0.0'
371
- processorArchitecture='*'
372
- publicKeyToken='6595b64144ccf1df'
373
- language='*'
374
- />
375
- </dependentAssembly>
376
- </dependency>
377
- </assembly>
378
- XML
379
- }
380
-
381
- ACTCTX.new { |ac|
382
- ac[:cbSize] = ac.size
383
-
384
- PWSTR(L(manifest)) { |source|
385
- ac[:lpSource] = source
386
-
387
- COMMON_CONTROLS_ACTCTX[:handle] =
388
- DetonateLastError(INVALID_HANDLE_VALUE, :CreateActCtx,
389
- ac
390
- )
391
- }
392
- }
393
-
394
- DetonateLastError(0, :ActivateActCtx,
395
- COMMON_CONTROLS_ACTCTX[:handle], COMMON_CONTROLS_ACTCTX[:cookie]
396
- ) { |failed|
397
- next unless failed
398
-
399
- ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle])
400
- COMMON_CONTROLS_ACTCTX[:handle] = INVALID_HANDLE_VALUE
401
- }
402
-
403
- COMMON_CONTROLS_ACTCTX[:activated] = true
404
- end
405
-
406
- module_function :EnableVisualStyles
407
-
408
- EnableVisualStyles() if WINGUI_VISUAL_STYLES
409
-
410
- attach_function :MulDiv, [
411
- :int,
412
- :int,
413
- :int
414
- ], :int
415
- #}
416
-
417
- #{ gdi32
418
- ffi_lib 'gdi32'
419
- ffi_convention :stdcall
420
-
421
- def RGB(r, g, b)
422
- r | (g << 8) | (b << 16)
423
- end
424
-
425
- def GetRValue(rgb)
426
- LOBYTE(rgb)
427
- end
428
-
429
- def GetGValue(rgb)
430
- LOBYTE(rgb >> 8)
431
- end
432
-
433
- def GetBValue(rgb)
434
- LOBYTE(rgb >> 16)
435
- end
436
-
437
- module_function :RGB, :GetRValue, :GetGValue, :GetBValue
438
-
439
- attach_function :CreateCompatibleDC, [
440
- :pointer
441
- ], :pointer
442
-
443
- attach_function :DeleteDC, [
444
- :pointer
445
- ], :int
446
-
447
- #{ devCapIndex constants
448
- LOGPIXELSX = 88
449
- LOGPIXELSY = 90
450
- #}
451
-
452
- attach_function :GetDeviceCaps, [
453
- :pointer,
454
- :int # in devCapIndex
455
- ], :int
456
-
457
- attach_function :CreateCompatibleBitmap, [
458
- :pointer,
459
- :int,
460
- :int
461
- ], :pointer
462
-
463
- def DPIAwareFontHeight(pointSize)
464
- -MulDiv(pointSize, DPIY, 72)
465
- end
466
-
467
- module_function :DPIAwareFontHeight
468
-
469
- #{ FW_xxx
470
- FW_DONTCARE = 0
471
- FW_THIN = 100
472
- FW_EXTRALIGHT = 200
473
- FW_LIGHT = 300
474
- FW_NORMAL = 400
475
- FW_MEDIUM = 500
476
- FW_SEMIBOLD = 600
477
- FW_BOLD = 700
478
- FW_EXTRABOLD = 800
479
- FW_HEAVY = 900
480
- #}
481
-
482
- #{ xxx_CHARSET
483
- DEFAULT_CHARSET = 1
484
- ANSI_CHARSET = 0
485
- #}
486
-
487
- #{ OUT_xxx_PRECIS
488
- OUT_DEFAULT_PRECIS = 0
489
- OUT_DEVICE_PRECIS = 5
490
- OUT_RASTER_PRECIS = 6
491
- OUT_OUTLINE_PRECIS = 8
492
- OUT_SCREEN_OUTLINE_PRECIS = 9
493
- OUT_PS_ONLY_PRECIS = 10
494
- OUT_TT_PRECIS = 4
495
- OUT_TT_ONLY_PRECIS = 7
496
- #}
497
-
498
- #{ CLIP_xxx_PRECIS
499
- CLIP_DEFAULT_PRECIS = 0
500
- #}
501
-
502
- #{ xxx_QUALITY
503
- DEFAULT_QUALITY = 0
504
- DRAFT_QUALITY = 1
505
- PROOF_QUALITY = 2
506
- NONANTIALIASED_QUALITY = 3
507
- ANTIALIASED_QUALITY = 4
508
- if WINVER >= WINXP
509
- CLEARTYPE_QUALITY = 5
510
- CLEARTYPE_NATURAL_QUALITY = 6
511
- end
512
- #}
513
-
514
- #{ xxx_PITCH
515
- DEFAULT_PITCH = 0
516
- FIXED_PITCH = 1
517
- VARIABLE_PITCH = 2
518
- #}
519
-
520
- #{ FF_xxx
521
- FF_DONTCARE = 0 << 4
522
- FF_MODERN = 3 << 4
523
- FF_SWISS = 2 << 4
524
- FF_ROMAN = 1 << 4
525
- FF_SCRIPT = 4 << 4
526
- FF_DECORATIVE = 5 << 4
527
- #}
528
-
529
- class LOGFONT < FFI::Struct
530
- extend Util::ScopedStruct
531
-
532
- layout \
533
- :lfHeight, :long,
534
- :lfWidth, :long,
535
- :lfEscapement, :long,
536
- :lfOrientation, :long,
537
- :lfWeight, :long,
538
- :lfItalic, :uchar,
539
- :lfUnderline, :uchar,
540
- :lfStrikeOut, :uchar,
541
- :lfCharSet, :uchar,
542
- :lfOutPrecision, :uchar,
543
- :lfClipPrecision, :uchar,
544
- :lfQuality, :uchar,
545
- :lfPitchAndFamily, :uchar,
546
- :lfFaceName, [:ushort, 32]
547
- end
548
-
549
- attach_function :CreateFontIndirect, :CreateFontIndirectW, [
550
- LOGFONT.by_ref(:in)
551
- ], :pointer
552
-
553
- #{ BS_xxx
554
- BS_NULL = 1
555
- BS_SOLID = 0
556
- BS_HATCHED = 2
557
- BS_PATTERN = 3
558
- BS_DIBPATTERN = 5
559
- BS_DIBPATTERNPT = 6
560
- #}
561
-
562
- #{ DIB_xxx
563
- DIB_RGB_COLORS = 0
564
- DIB_PAL_COLORS = 1
565
- #}
566
-
567
- #{ HS_xxx
568
- HS_HORIZONTAL = 0
569
- HS_VERTICAL = 1
570
- HS_FDIAGONAL = 2
571
- HS_BDIAGONAL = 3
572
- HS_CROSS = 4
573
- HS_DIAGCROSS = 5
574
- #}
575
-
576
- class LOGBRUSH < FFI::Struct
577
- extend Util::ScopedStruct
578
-
579
- layout \
580
- :lbStyle, :uint,
581
- :lbColor, :ulong,
582
- :lbHatch, :ulong
583
- end
584
-
585
- attach_function :CreateBrushIndirect, [
586
- LOGBRUSH.by_ref(:in)
587
- ], :pointer
588
-
589
- #{ PS_xxx
590
- PS_COSMETIC = 0x00000000
591
- PS_GEOMETRIC = 0x00010000
592
-
593
- PS_NULL = 5
594
- PS_SOLID = 0
595
- PS_DASH = 1
596
- PS_DOT = 2
597
- PS_DASHDOT = 3
598
- PS_DASHDOTDOT = 4
599
- PS_ALTERNATE = 8
600
- PS_USERSTYLE = 7
601
- PS_INSIDEFRAME = 6
602
-
603
- PS_ENDCAP_FLAT = 0x00000200
604
- PS_ENDCAP_SQUARE = 0x00000100
605
- PS_ENDCAP_ROUND = 0x00000000
606
-
607
- PS_JOIN_BEVEL = 0x00001000
608
- PS_JOIN_MITER = 0x00002000
609
- PS_JOIN_ROUND = 0x00000000
610
- #}
611
-
612
- class LOGPEN < FFI::Struct
613
- extend Util::ScopedStruct
614
-
615
- layout \
616
- :lopnStyle, :uint,
617
- :lopnWidth, POINT,
618
- :lopnColor, :ulong
619
- end
620
-
621
- attach_function :CreatePenIndirect, [
622
- LOGPEN.by_ref(:in)
623
- ], :pointer
624
-
625
- attach_function :ExtCreatePen, [
626
- :ulong,
627
- :ulong,
628
- LOGBRUSH.by_ref(:in),
629
- :ulong,
630
- :pointer
631
- ], :pointer
632
-
633
- attach_function :CreateRectRgn, [
634
- :int,
635
- :int,
636
- :int,
637
- :int
638
- ], :pointer
639
-
640
- attach_function :CreateRoundRectRgn, [
641
- :int,
642
- :int,
643
- :int,
644
- :int,
645
- :int,
646
- :int
647
- ], :pointer
648
-
649
- attach_function :CreateEllipticRgn, [
650
- :int,
651
- :int,
652
- :int,
653
- :int
654
- ], :pointer
655
-
656
- #{ polyFillMode constants
657
- ALTERNATE = 1
658
- WINDING = 2
659
- #}
660
-
661
- attach_function :SetPolyFillMode, [
662
- :pointer,
663
- :int # in polyFillMode
664
- ], :int
665
-
666
- attach_function :GetPolyFillMode, [
667
- :pointer
668
- ], :int # polyFillMode
669
-
670
- attach_function :CreatePolygonRgn, [
671
- :pointer,
672
- :int,
673
- :int # in polyFillMode
674
- ], :pointer
675
-
676
- attach_function :CreatePolyPolygonRgn, [
677
- :pointer,
678
- :pointer,
679
- :int,
680
- :int # in polyFillMode
681
- ], :pointer
682
-
683
- attach_function :OffsetRgn, [
684
- :pointer,
685
- :int,
686
- :int
687
- ], :int
688
-
689
- #{ RGN_xxx
690
- RGN_COPY = 5
691
- RGN_DIFF = 4
692
- RGN_AND = 1
693
- RGN_OR = 2
694
- RGN_XOR = 3
695
- #}
696
-
697
- #{ rgnType constants
698
- ERROR = 0
699
- NULLREGION = 1
700
- SIMPLEREGION = 2
701
- COMPLEXREGION = 3
702
- #}
703
-
704
- attach_function :CombineRgn, [
705
- :pointer,
706
- :pointer,
707
- :pointer,
708
- :int
709
- ], :int # rgnType
710
-
711
- attach_function :GetRgnBox, [
712
- :pointer,
713
- RECT.by_ref(:out)
714
- ], :int
715
-
716
- attach_function :PtInRegion, [
717
- :pointer,
718
- :int,
719
- :int
720
- ], :int
721
-
722
- attach_function :RectInRegion, [
723
- :pointer,
724
- RECT.by_ref(:in)
725
- ], :int
726
-
727
- attach_function :EqualRgn, [
728
- :pointer,
729
- :pointer
730
- ], :int
731
-
732
- attach_function :FrameRgn, [
733
- :pointer,
734
- :pointer,
735
- :pointer,
736
- :int,
737
- :int
738
- ], :int
739
-
740
- attach_function :FillRgn, [
741
- :pointer,
742
- :pointer,
743
- :pointer
744
- ], :int
745
-
746
- attach_function :DeleteObject, [
747
- :pointer
748
- ], :int
749
-
750
- attach_function :GetObject, :GetObjectW, [
751
- :pointer,
752
- :int,
753
- :pointer
754
- ], :int
755
-
756
- #{ R2_xxx
757
- R2_BLACK = 1
758
- R2_WHITE = 16
759
-
760
- R2_NOP = 11
761
- R2_NOT = 6
762
- R2_COPYPEN = 13
763
- R2_NOTCOPYPEN = 4
764
-
765
- R2_MERGEPEN = 15
766
- R2_MERGENOTPEN = 12
767
- R2_MERGEPENNOT = 14
768
- R2_NOTMERGEPEN = 2
769
-
770
- R2_MASKPEN = 9
771
- R2_MASKNOTPEN = 3
772
- R2_MASKPENNOT = 5
773
- R2_NOTMASKPEN = 8
774
-
775
- R2_XORPEN = 7
776
- R2_NOTXORPEN = 10
777
- #}
778
-
779
- attach_function :SetROP2, [
780
- :pointer,
781
- :int
782
- ], :int
783
-
784
- attach_function :GetROP2, [
785
- :pointer
786
- ], :int
787
-
788
- attach_function :SetBkColor, [
789
- :pointer,
790
- :ulong
791
- ], :ulong
792
-
793
- attach_function :GetBkColor, [
794
- :pointer
795
- ], :ulong
796
-
797
- attach_function :SetTextColor, [
798
- :pointer,
799
- :ulong
800
- ], :ulong
801
-
802
- attach_function :GetTextColor, [
803
- :pointer
804
- ], :ulong
805
-
806
- attach_function :SelectObject, [
807
- :pointer,
808
- :pointer
809
- ], :pointer
810
-
811
- #{ AD_xxx
812
- AD_COUNTERCLOCKWISE = 1
813
- AD_CLOCKWISE = 2
814
- #}
815
-
816
- attach_function :SetArcDirection, [
817
- :pointer,
818
- :int
819
- ], :int
820
-
821
- attach_function :GetArcDirection, [
822
- :int
823
- ], :int
824
-
825
- attach_function :SaveDC, [
826
- :pointer
827
- ], :int
828
-
829
- attach_function :RestoreDC, [
830
- :pointer,
831
- :int
832
- ], :int
833
-
834
- attach_function :TextOut, :TextOutW, [
835
- :pointer,
836
- :int,
837
- :int,
838
- :buffer_in,
839
- :int
840
- ], :int
841
-
842
- attach_function :MoveToEx, [
843
- :pointer,
844
- :int,
845
- :int,
846
- POINT.by_ref(:out)
847
- ], :int
848
-
849
- attach_function :LineTo, [
850
- :pointer,
851
- :int,
852
- :int
853
- ], :int
854
-
855
- attach_function :Polyline, [
856
- :pointer,
857
- :pointer,
858
- :int
859
- ], :int
860
-
861
- attach_function :PolylineTo, [
862
- :pointer,
863
- :pointer,
864
- :ulong
865
- ], :int
866
-
867
- attach_function :PolyPolyline, [
868
- :pointer,
869
- :pointer,
870
- :pointer,
871
- :ulong
872
- ], :int
873
-
874
- attach_function :Arc, [
875
- :pointer,
876
- :int,
877
- :int,
878
- :int,
879
- :int,
880
- :int,
881
- :int,
882
- :int,
883
- :int,
884
- ], :int
885
-
886
- attach_function :ArcTo, [
887
- :pointer,
888
- :int,
889
- :int,
890
- :int,
891
- :int,
892
- :int,
893
- :int,
894
- :int,
895
- :int,
896
- ], :int
897
-
898
- attach_function :AngleArc, [
899
- :pointer,
900
- :int,
901
- :int,
902
- :ulong,
903
- :float,
904
- :float
905
- ], :int
906
-
907
- attach_function :PolyBezier, [
908
- :pointer,
909
- :pointer,
910
- :ulong
911
- ], :int
912
-
913
- attach_function :PolyBezierTo, [
914
- :pointer,
915
- :pointer,
916
- :ulong
917
- ], :int
918
-
919
- #{ PT_xxx
920
- PT_MOVETO = 0x06
921
- PT_LINETO = 0x02
922
- PT_BEZIERTO = 0x04
923
- PT_CLOSEFIGURE = 0x01
924
- #}
925
-
926
- attach_function :PolyDraw, [
927
- :pointer,
928
- :pointer,
929
- :pointer,
930
- :int
931
- ], :int
932
-
933
- attach_function :Rectangle, [
934
- :pointer,
935
- :int,
936
- :int,
937
- :int,
938
- :int
939
- ], :int
940
-
941
- attach_function :RoundRect, [
942
- :pointer,
943
- :int,
944
- :int,
945
- :int,
946
- :int,
947
- :int,
948
- :int
949
- ], :int
950
-
951
- attach_function :Ellipse, [
952
- :pointer,
953
- :int,
954
- :int,
955
- :int,
956
- :int
957
- ], :int
958
-
959
- attach_function :Pie, [
960
- :pointer,
961
- :int,
962
- :int,
963
- :int,
964
- :int,
965
- :int,
966
- :int,
967
- :int,
968
- :int
969
- ], :int
970
-
971
- attach_function :Chord, [
972
- :pointer,
973
- :int,
974
- :int,
975
- :int,
976
- :int,
977
- :int,
978
- :int,
979
- :int,
980
- :int
981
- ], :int
982
-
983
- attach_function :Polygon, [
984
- :pointer,
985
- :pointer,
986
- :int
987
- ], :int
988
-
989
- attach_function :PolyPolygon, [
990
- :pointer,
991
- :pointer,
992
- :pointer,
993
- :int
994
- ], :int
995
- #}
996
-
997
- #{ user32
998
- ffi_lib 'user32'
999
- ffi_convention :stdcall
1000
-
1001
- attach_function :SetRect, [
1002
- RECT.by_ref(:out),
1003
- :int,
1004
- :int,
1005
- :int,
1006
- :int
1007
- ], :int
1008
-
1009
- attach_function :CopyRect, [
1010
- RECT.by_ref(:out),
1011
- RECT.by_ref(:in)
1012
- ], :int
1013
-
1014
- attach_function :OffsetRect, [
1015
- RECT.by_ref,
1016
- :int,
1017
- :int
1018
- ], :int
1019
-
1020
- attach_function :InflateRect, [
1021
- RECT.by_ref,
1022
- :int,
1023
- :int
1024
- ], :int
1025
-
1026
- attach_function :SubtractRect, [
1027
- RECT.by_ref(:out),
1028
- RECT.by_ref(:in),
1029
- RECT.by_ref(:in)
1030
- ], :int
1031
-
1032
- attach_function :IntersectRect, [
1033
- RECT.by_ref(:out),
1034
- RECT.by_ref(:in),
1035
- RECT.by_ref(:in)
1036
- ], :int
1037
-
1038
- attach_function :UnionRect, [
1039
- RECT.by_ref(:out),
1040
- RECT.by_ref(:in),
1041
- RECT.by_ref(:in)
1042
- ], :int
1043
-
1044
- attach_function :IsRectEmpty, [
1045
- RECT.by_ref(:in)
1046
- ], :int
1047
-
1048
- attach_function :PtInRect, [
1049
- RECT.by_ref(:in),
1050
- POINT.by_value
1051
- ], :int
1052
-
1053
- attach_function :EqualRect, [
1054
- RECT.by_ref(:in),
1055
- RECT.by_ref(:in)
1056
- ], :int
1057
-
1058
- def NormalizeRect(rect)
1059
- rect[:left], rect[:right] = rect[:right], rect[:left] if
1060
- rect[:left] > rect[:right]
1061
- rect[:top], rect[:bottom] = rect[:bottom], rect[:top] if
1062
- rect[:top] > rect[:bottom]
1063
- end
1064
-
1065
- module_function :NormalizeRect
1066
-
1067
- attach_function :DrawFocusRect, [
1068
- :pointer,
1069
- RECT.by_ref(:in)
1070
- ], :int
1071
-
1072
- attach_function :FrameRect, [
1073
- :pointer,
1074
- RECT.by_ref(:in),
1075
- :pointer
1076
- ], :int
1077
-
1078
- attach_function :FillRect, [
1079
- :pointer,
1080
- RECT.by_ref(:in),
1081
- :pointer
1082
- ], :int
1083
-
1084
- if WINVER >= WINVISTA # SetProcessDPIAware
1085
- attach_function :SetProcessDPIAware, [
1086
-
1087
- ], :int
1088
-
1089
- Detonate(0, :SetProcessDPIAware) if WINGUI_DPI_AWARE
1090
- end
1091
-
1092
- attach_function :GetWindowDC, [
1093
- :pointer
1094
- ], :pointer
1095
-
1096
- attach_function :GetDC, [
1097
- :pointer
1098
- ], :pointer
1099
-
1100
- attach_function :ReleaseDC, [
1101
- :pointer,
1102
- :pointer
1103
- ], :int
1104
-
1105
- Detonate(FFI::Pointer::NULL, :GetDC, # DPIxxx
1106
- nil
1107
- ).tap { |hdc|
1108
- DPIX = GetDeviceCaps(hdc, LOGPIXELSX)
1109
- DPIY = GetDeviceCaps(hdc, LOGPIXELSY)
1110
-
1111
- ReleaseDC(nil, hdc)
1112
- }
1113
-
1114
- def DPIAwareX(x)
1115
- MulDiv(x, DPIX, 96)
1116
- end
1117
-
1118
- def DPIAwareY(y)
1119
- MulDiv(y, DPIY, 96)
1120
- end
1121
-
1122
- def DPIAwareXY(*args)
1123
- raise ArgumentError, 'Expected two or more, even count arguments' if
1124
- args.length < 2 || args.length.odd?
1125
-
1126
- args.each_with_index { |arg, i|
1127
- args[i] = (i.even?) ? DPIAwareX(arg) : DPIAwareY(arg)
1128
- }
1129
- end
1130
-
1131
- module_function :DPIAwareX, :DPIAwareY, :DPIAwareXY
1132
-
1133
- #{ SM_xxx
1134
- SM_CXSCREEN = 0
1135
- SM_CYSCREEN = 1
1136
- #}
1137
-
1138
- attach_function :GetSystemMetrics, [
1139
- :int
1140
- ], :int
1141
-
1142
- #{ SPI_xxx
1143
- class NONCLIENTMETRICS < FFI::Struct
1144
- extend Util::ScopedStruct
1145
-
1146
- layout *[
1147
- :cbSize, :uint,
1148
- :iBorderWidth, :int,
1149
- :iScrollWidth, :int,
1150
- :iScrollHeight, :int,
1151
- :iCaptionWidth, :int,
1152
- :iCaptionHeight, :int,
1153
- :lfCaptionFont, LOGFONT,
1154
- :iSmCaptionWidth, :int,
1155
- :iSmCaptionHeight, :int,
1156
- :lfSmCaptionFont, LOGFONT,
1157
- :iMenuWidth, :int,
1158
- :iMenuHeight, :int,
1159
- :lfMenuFont, LOGFONT,
1160
- :lfStatusFont, LOGFONT,
1161
- :lfMessageFont, LOGFONT,
1162
- (WINVER >= WINVISTA) ? [:iPaddedBorderWidth, :int] : nil
1163
- ].tap { |layout|
1164
- layout.flatten!
1165
- layout.compact!
1166
- }
1167
- end
1168
-
1169
- SPI_SETNONCLIENTMETRICS = 0x002a
1170
- SPI_GETNONCLIENTMETRICS = 0x0029
1171
- #}
1172
-
1173
- attach_function :SystemParametersInfo, :SystemParametersInfoW, [
1174
- :uint,
1175
- :uint,
1176
- :pointer,
1177
- :uint
1178
- ], :int
1179
-
1180
- #{ MB_xxx
1181
- MB_OK = 0x00000000
1182
- MB_OKCANCEL = 0x00000001
1183
- MB_YESNO = 0x00000004
1184
- MB_YESNOCANCEL = 0x00000003
1185
- MB_RETRYCANCEL = 0x00000005
1186
- MB_ABORTRETRYIGNORE = 0x00000002
1187
- MB_CANCELTRYCONTINUE = 0x00000006
1188
- MB_HELP = 0x00004000
1189
-
1190
- MB_ICONINFORMATION = 0x00000040
1191
- MB_ICONWARNING = 0x00000030
1192
- MB_ICONERROR = 0x00000010
1193
- MB_ICONQUESTION = 0x00000020
1194
-
1195
- MB_DEFBUTTON1 = 0x00000000
1196
- MB_DEFBUTTON2 = 0x00000100
1197
- MB_DEFBUTTON3 = 0x00000200
1198
- MB_DEFBUTTON4 = 0x00000300
1199
-
1200
- MB_APPLMODAL = 0x00000000
1201
- MB_TASKMODAL = 0x00002000
1202
- MB_SYSTEMMODAL = 0x00001000
1203
- #}
1204
-
1205
- #{ IDxxx
1206
- IDOK = 1
1207
- IDCANCEL = 2
1208
- IDYES = 6
1209
- IDNO = 7
1210
- IDABORT = 3
1211
- IDRETRY = 4
1212
- IDIGNORE = 5
1213
- IDTRYAGAIN = 10
1214
- IDCONTINUE = 11
1215
- if WINVER >= WINXP
1216
- IDTIMEOUT = 32000
1217
- end
1218
- #}
1219
-
1220
- attach_function :MessageBox, :MessageBoxW, [
1221
- :pointer,
1222
- :buffer_in,
1223
- :buffer_in,
1224
- :uint
1225
- ], :int
1226
-
1227
- if WINVER >= WINXP # MessageBoxTimeout
1228
- begin
1229
- attach_function :MessageBoxTimeout, :MessageBoxTimeoutW, [
1230
- :pointer,
1231
- :buffer_in,
1232
- :buffer_in,
1233
- :uint,
1234
- :ushort,
1235
- :ulong
1236
- ], :int
1237
- rescue FFI::NotFoundError # MessageBoxTimeout is undocumented
1238
-
1239
- end
1240
- end
1241
-
1242
- #{ CS_xxx
1243
- CS_DBLCLKS = 0x0008
1244
- CS_HREDRAW = 0x0002
1245
- CS_VREDRAW = 0x0001
1246
- CS_PARENTDC = 0x0080
1247
- CS_CLASSDC = 0x0040
1248
- CS_OWNDC = 0x0020
1249
- CS_SAVEBITS = 0x0800
1250
- CS_NOCLOSE = 0x0200
1251
- if WINVER >= WINXP
1252
- CS_DROPSHADOW = 0x00020000
1253
- end
1254
- #}
1255
-
1256
- callback :WNDPROC, [
1257
- :pointer,
1258
- :uint,
1259
- :uint,
1260
- :long
1261
- ], :long
1262
-
1263
- attach_function :DefWindowProc, :DefWindowProcW, [
1264
- :pointer,
1265
- :uint,
1266
- :uint,
1267
- :long
1268
- ], :long
1269
-
1270
- #{ IMAGE_xxx
1271
- IMAGE_BITMAP = 0
1272
- IMAGE_ICON = 1
1273
- IMAGE_CURSOR = 2
1274
- #}
1275
-
1276
- #{ LR_xxx
1277
- LR_SHARED = 0x00008000
1278
- LR_LOADFROMFILE = 0x00000010
1279
- LR_CREATEDIBSECTION = 0x00002000
1280
- LR_LOADTRANSPARENT = 0x00000020
1281
- LR_LOADMAP3DCOLORS = 0x00001000
1282
- LR_DEFAULTSIZE = 0x00000040
1283
- #}
1284
-
1285
- attach_function :LoadImage, :LoadImageW, [
1286
- :pointer,
1287
- :buffer_in,
1288
- :uint,
1289
- :int,
1290
- :int,
1291
- :uint
1292
- ], :pointer
1293
-
1294
- #{ IDI_xxx
1295
- IDI_WINLOGO = FFI::Pointer.new(32517)
1296
- IDI_APPLICATION = FFI::Pointer.new(32512)
1297
- if WINVER >= WINVISTA
1298
- IDI_SHIELD = FFI::Pointer.new(32518)
1299
- end
1300
-
1301
- IDI_INFORMATION = FFI::Pointer.new(32516)
1302
- IDI_WARNING = FFI::Pointer.new(32515)
1303
- IDI_ERROR = FFI::Pointer.new(32513)
1304
- IDI_QUESTION = FFI::Pointer.new(32514)
1305
- #}
1306
-
1307
- attach_function :LoadIcon, :LoadIconW, [
1308
- :pointer,
1309
- :buffer_in
1310
- ], :pointer
1311
-
1312
- attach_function :DestroyIcon, [
1313
- :pointer
1314
- ], :int
1315
-
1316
- begin # PrivateExtractIcons
1317
- attach_function :PrivateExtractIcons, :PrivateExtractIconsW, [
1318
- :buffer_in,
1319
- :int,
1320
- :int,
1321
- :int,
1322
- :pointer,
1323
- :pointer,
1324
- :uint,
1325
- :uint
1326
- ], :uint
1327
- rescue FFI::NotFoundError # PrivateExtractIcons is not intended for general use
1328
-
1329
- end
1330
-
1331
- #{ IDC_xxx
1332
- IDC_WAIT = FFI::Pointer.new(32514)
1333
- IDC_APPSTARTING = FFI::Pointer.new(32650)
1334
-
1335
- IDC_ARROW = FFI::Pointer.new(32512)
1336
- IDC_HAND = FFI::Pointer.new(32649)
1337
- IDC_IBEAM = FFI::Pointer.new(32513)
1338
- IDC_CROSS = FFI::Pointer.new(32515)
1339
- IDC_HELP = FFI::Pointer.new(32651)
1340
- IDC_NO = FFI::Pointer.new(32648)
1341
-
1342
- IDC_SIZEALL = FFI::Pointer.new(32646)
1343
- IDC_SIZENS = FFI::Pointer.new(32645)
1344
- IDC_SIZEWE = FFI::Pointer.new(32644)
1345
- IDC_SIZENWSE = FFI::Pointer.new(32642)
1346
- IDC_SIZENESW = FFI::Pointer.new(32643)
1347
- #}
1348
-
1349
- attach_function :LoadCursor, :LoadCursorW, [
1350
- :pointer,
1351
- :buffer_in
1352
- ], :pointer
1353
-
1354
- attach_function :DestroyCursor, [
1355
- :pointer
1356
- ], :int
1357
-
1358
- attach_function :SetCursor, [
1359
- :pointer
1360
- ], :pointer
1361
-
1362
- attach_function :GetCursor, [
1363
-
1364
- ], :pointer
1365
-
1366
- attach_function :SetCursorPos, [
1367
- :int,
1368
- :int
1369
- ], :int
1370
-
1371
- attach_function :GetCursorPos, [
1372
- POINT.by_ref(:out)
1373
- ], :int
1374
-
1375
- attach_function :ShowCursor, [
1376
- :int
1377
- ], :int
1378
-
1379
- #{ COLOR_xxx
1380
- COLOR_DESKTOP = 1
1381
- COLOR_APPWORKSPACE = 12
1382
- COLOR_WINDOW = 5
1383
- if WINVER >= WINXP
1384
- COLOR_MENUBAR = 30
1385
- end
1386
- COLOR_MENU = 4
1387
- #}
1388
-
1389
- class WNDCLASSEX < FFI::Struct
1390
- extend Util::ScopedStruct
1391
-
1392
- layout \
1393
- :cbSize, :uint,
1394
- :style, :uint,
1395
- :lpfnWndProc, :WNDPROC,
1396
- :cbClsExtra, :int,
1397
- :cbWndExtra, :int,
1398
- :hInstance, :pointer,
1399
- :hIcon, :pointer,
1400
- :hCursor, :pointer,
1401
- :hbrBackground, :pointer,
1402
- :lpszMenuName, :pointer,
1403
- :lpszClassName, :pointer,
1404
- :hIconSm, :pointer
1405
- end
1406
-
1407
- attach_function :RegisterClassEx, :RegisterClassExW, [
1408
- WNDCLASSEX.by_ref(:in)
1409
- ], :ushort
1410
-
1411
- attach_function :UnregisterClass, :UnregisterClassW, [
1412
- :buffer_in,
1413
- :pointer
1414
- ], :int
1415
-
1416
- attach_function :GetClassInfoEx, :GetClassInfoExW, [
1417
- :pointer,
1418
- :buffer_in,
1419
- WNDCLASSEX.by_ref(:out)
1420
- ], :int
1421
-
1422
- attach_function :FindWindow, :FindWindowW, [
1423
- :buffer_in,
1424
- :buffer_in
1425
- ], :pointer
1426
-
1427
- callback :WNDENUMPROC, [
1428
- :pointer,
1429
- :long
1430
- ], :int
1431
-
1432
- attach_function :EnumChildWindows, [
1433
- :pointer,
1434
- :WNDENUMPROC,
1435
- :long
1436
- ], :int
1437
-
1438
- attach_function :GetDesktopWindow, [
1439
-
1440
- ], :pointer
1441
-
1442
- #{ GW_xxx
1443
- GW_HWNDFIRST = 0
1444
- GW_HWNDLAST = 1
1445
- GW_HWNDNEXT = 2
1446
- GW_HWNDPREV = 3
1447
- GW_OWNER = 4
1448
- GW_ENABLEDPOPUP = 6
1449
- GW_CHILD = 5
1450
- #}
1451
-
1452
- attach_function :GetWindow, [
1453
- :pointer,
1454
- :uint
1455
- ], :pointer
1456
-
1457
- #{ GA_xxx
1458
- GA_PARENT = 1
1459
- GA_ROOT = 2
1460
- GA_ROOTOWNER = 3
1461
- #}
1462
-
1463
- attach_function :GetAncestor, [
1464
- :pointer,
1465
- :uint
1466
- ], :pointer
1467
-
1468
- attach_function :SetParent, [
1469
- :pointer,
1470
- :pointer
1471
- ], :pointer
1472
-
1473
- attach_function :GetParent, [
1474
- :pointer
1475
- ], :pointer
1476
-
1477
- #{ WS_EX_xxx
1478
- WS_EX_WINDOWEDGE = 0x00000100
1479
- WS_EX_CLIENTEDGE = 0x00000200
1480
- WS_EX_STATICEDGE = 0x00020000
1481
- WS_EX_DLGMODALFRAME = 0x00000001
1482
- WS_EX_CONTEXTHELP = 0x00000400
1483
- WS_EX_ACCEPTFILES = 0x00000010
1484
-
1485
- WS_EX_TOPMOST = 0x00000008
1486
- WS_EX_LAYERED = 0x00080000
1487
- if WINVER >= WINXP
1488
- WS_EX_COMPOSITED = 0x02000000
1489
- end
1490
- WS_EX_TRANSPARENT = 0x00000020
1491
-
1492
- WS_EX_NOPARENTNOTIFY = 0x00000004
1493
-
1494
- WS_EX_APPWINDOW = 0x00040000
1495
- WS_EX_OVERLAPPEDWINDOW = \
1496
- WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE
1497
- WS_EX_TOOLWINDOW = 0x00000080
1498
- WS_EX_PALETTEWINDOW = WS_EX_TOOLWINDOW |
1499
- WS_EX_WINDOWEDGE | WS_EX_TOPMOST
1500
- WS_EX_CONTROLPARENT = 0x00010000
1501
- #}
1502
-
1503
- #{ WS_xxx
1504
- WS_BORDER = 0x00800000
1505
- WS_DLGFRAME = 0x00400000
1506
- WS_CAPTION = 0x00C00000
1507
- WS_SYSMENU = 0x00080000
1508
- WS_THICKFRAME = 0x00040000
1509
- WS_MINIMIZEBOX = 0x00020000
1510
- WS_MAXIMIZEBOX = 0x00010000
1511
- WS_HSCROLL = 0x00100000
1512
- WS_VSCROLL = 0x00200000
1513
-
1514
- WS_DISABLED = 0x08000000
1515
- WS_VISIBLE = 0x10000000
1516
- WS_MINIMIZE = 0x20000000
1517
- WS_MAXIMIZE = 0x01000000
1518
- WS_CLIPCHILDREN = 0x02000000
1519
-
1520
- WS_GROUP = 0x00020000
1521
- WS_TABSTOP = 0x00010000
1522
- WS_CLIPSIBLINGS = 0x04000000
1523
-
1524
- WS_OVERLAPPED = 0x00000000
1525
- WS_OVERLAPPEDWINDOW = WS_OVERLAPPED |
1526
- WS_CAPTION | WS_SYSMENU |
1527
- WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
1528
- WS_POPUP = 0x80000000
1529
- WS_POPUPWINDOW = WS_POPUP |
1530
- WS_BORDER | WS_SYSMENU
1531
- WS_CHILD = 0x40000000
1532
- WS_CHILDWINDOW = WS_CHILD
1533
- #}
1534
-
1535
- #{ CW_xxx
1536
- CW_USEDEFAULT = -0x80000000
1537
- #}
1538
-
1539
- #{ HWND_xxx
1540
- HWND_DESKTOP = FFI::Pointer.new(0)
1541
- HWND_MESSAGE = FFI::Pointer.new(-3)
1542
- #}
1543
-
1544
- attach_function :CreateWindowEx, :CreateWindowExW, [
1545
- :ulong,
1546
- :buffer_in,
1547
- :buffer_in,
1548
- :ulong,
1549
- :int,
1550
- :int,
1551
- :int,
1552
- :int,
1553
- :pointer,
1554
- :pointer,
1555
- :pointer,
1556
- :pointer
1557
- ], :pointer
1558
-
1559
- attach_function :DestroyWindow, [
1560
- :pointer
1561
- ], :int
1562
-
1563
- #{ GCL/GCW_xxx
1564
- GCL_STYLE = -26
1565
- GCL_WNDPROC = -24
1566
- GCL_CBCLSEXTRA = -20
1567
- GCL_CBWNDEXTRA = -18
1568
- GCL_HMODULE = -16
1569
- GCL_HICON = -14
1570
- GCL_HCURSOR = -12
1571
- GCL_HBRBACKGROUND = -10
1572
- GCL_MENUNAME = -8
1573
- GCL_HICONSM = -34
1574
- GCW_ATOM = -32
1575
- #}
1576
-
1577
- attach_function :SetClassLong, :SetClassLongW, [
1578
- :pointer,
1579
- :int,
1580
- :long
1581
- ], :ulong
1582
-
1583
- attach_function :GetClassLong, :GetClassLongW, [
1584
- :pointer,
1585
- :int
1586
- ], :ulong
1587
-
1588
- attach_function :GetClassName, :GetClassNameW, [
1589
- :pointer,
1590
- :buffer_out,
1591
- :int
1592
- ], :int
1593
-
1594
- #{ GWL_xxx
1595
- GWL_WNDPROC = -4
1596
- GWL_EXSTYLE = -20
1597
- GWL_STYLE = -16
1598
- GWL_HWNDPARENT = -8
1599
- GWL_ID = -12
1600
- GWL_HINSTANCE = -6
1601
- GWL_USERDATA = -21
1602
- #}
1603
-
1604
- attach_function :SetWindowLong, :SetWindowLongW, [
1605
- :pointer,
1606
- :int,
1607
- :long
1608
- ], :long
1609
-
1610
- attach_function :GetWindowLong, :GetWindowLongW, [
1611
- :pointer,
1612
- :int
1613
- ], :long
1614
-
1615
- #{ LWA_xxx
1616
- LWA_COLORKEY = 0x00000001
1617
- LWA_ALPHA = 0x00000002
1618
- #}
1619
-
1620
- attach_function :SetLayeredWindowAttributes, [
1621
- :pointer,
1622
- :ulong,
1623
- :uchar,
1624
- :ulong
1625
- ], :int
1626
-
1627
- if WINVER >= WINXP # GetLayeredWindowAttributes
1628
- attach_function :GetLayeredWindowAttributes, [
1629
- :pointer,
1630
- :pointer,
1631
- :pointer,
1632
- :pointer
1633
- ], :int
1634
- end
1635
-
1636
- attach_function :SetWindowRgn, [
1637
- :pointer,
1638
- :pointer,
1639
- :int
1640
- ], :int
1641
-
1642
- attach_function :GetWindowRgn, [
1643
- :pointer,
1644
- :pointer
1645
- ], :int
1646
-
1647
- attach_function :IsWindowEnabled, [
1648
- :pointer
1649
- ], :int
1650
-
1651
- attach_function :EnableWindow, [
1652
- :pointer,
1653
- :int
1654
- ], :int
1655
-
1656
- attach_function :SetActiveWindow, [
1657
- :pointer
1658
- ], :pointer
1659
-
1660
- attach_function :GetActiveWindow, [
1661
-
1662
- ], :pointer
1663
-
1664
- attach_function :SetForegroundWindow, [
1665
- :pointer
1666
- ], :int
1667
-
1668
- attach_function :GetForegroundWindow, [
1669
-
1670
- ], :pointer
1671
-
1672
- attach_function :SetFocus, [
1673
- :pointer
1674
- ], :pointer
1675
-
1676
- attach_function :GetFocus, [
1677
-
1678
- ], :pointer
1679
-
1680
- attach_function :IsWindowVisible, [
1681
- :pointer
1682
- ], :int
1683
-
1684
- attach_function :IsIconic, [
1685
- :pointer
1686
- ], :int
1687
-
1688
- attach_function :IsZoomed, [
1689
- :pointer
1690
- ], :int
1691
-
1692
- #{ SW_xxx
1693
- SW_SHOWDEFAULT = 10
1694
- SW_HIDE = 0
1695
- SW_SHOW = 5
1696
- SW_SHOWNA = 8
1697
- SW_SHOWNORMAL = 1
1698
- SW_SHOWNOACTIVATE = 4
1699
- SW_SHOWMINIMIZED = 2
1700
- SW_SHOWMINNOACTIVE = 7
1701
- SW_MINIMIZE = 6
1702
- SW_FORCEMINIMIZE = 11
1703
- SW_SHOWMAXIMIZED = 3
1704
- SW_MAXIMIZE = 3
1705
- SW_RESTORE = 9
1706
- #}
1707
-
1708
- attach_function :ShowWindow, [
1709
- :pointer,
1710
- :int
1711
- ], :int
1712
-
1713
- attach_function :ShowWindowAsync, [
1714
- :pointer,
1715
- :int
1716
- ], :int
1717
-
1718
- #{ AW_xxx
1719
- AW_HIDE = 0x00010000
1720
- AW_ACTIVATE = 0x00020000
1721
- AW_CENTER = 0x00000010
1722
- AW_SLIDE = 0x00040000
1723
- AW_HOR_POSITIVE = 0x00000001
1724
- AW_HOR_NEGATIVE = 0x00000002
1725
- AW_VER_POSITIVE = 0x00000004
1726
- AW_VER_NEGATIVE = 0x00000008
1727
- AW_BLEND = 0x00080000
1728
- #}
1729
-
1730
- attach_function :AnimateWindow, [
1731
- :pointer,
1732
- :ulong,
1733
- :ulong
1734
- ], :int
1735
-
1736
- #{ HWND_xxx
1737
- HWND_TOP = FFI::Pointer.new(0)
1738
- HWND_BOTTOM = FFI::Pointer.new(1)
1739
- HWND_TOPMOST = FFI::Pointer.new(-1)
1740
- HWND_NOTOPMOST = FFI::Pointer.new(-2)
1741
- #}
1742
-
1743
- #{ SWP_xxx
1744
- SWP_FRAMECHANGED = 0x0020
1745
- SWP_NOACTIVATE = 0x0010
1746
- SWP_NOOWNERZORDER = 0x0200
1747
- SWP_NOZORDER = 0x0004
1748
- SWP_NOMOVE = 0x0002
1749
- SWP_NOSIZE = 0x0001
1750
- SWP_ASYNCWINDOWPOS = 0x4000
1751
- #}
1752
-
1753
- attach_function :SetWindowPos, [
1754
- :pointer,
1755
- :pointer,
1756
- :int,
1757
- :int,
1758
- :int,
1759
- :int,
1760
- :uint
1761
- ], :int
1762
-
1763
- attach_function :BeginDeferWindowPos, [
1764
- :int
1765
- ], :pointer
1766
-
1767
- attach_function :DeferWindowPos, [
1768
- :pointer,
1769
- :pointer,
1770
- :pointer,
1771
- :int,
1772
- :int,
1773
- :int,
1774
- :int,
1775
- :uint
1776
- ], :pointer
1777
-
1778
- attach_function :EndDeferWindowPos, [
1779
- :pointer
1780
- ], :int
1781
-
1782
- #{ SB_xxx
1783
- SB_HORZ = 0
1784
- SB_VERT = 1
1785
- SB_BOTH = 3
1786
- SB_CTL = 2
1787
- #}
1788
-
1789
- #{ SIF_xxx
1790
- SIF_RANGE = 0x0001
1791
- SIF_PAGE = 0x0002
1792
- SIF_POS = 0x0004
1793
- SIF_TRACKPOS = 0x0010
1794
- SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS
1795
- SIF_DISABLENOSCROLL = 0x0008
1796
- #}
1797
-
1798
- class SCROLLINFO < FFI::Struct
1799
- extend Util::ScopedStruct
1800
-
1801
- layout \
1802
- :cbSize, :uint,
1803
- :fMask, :uint,
1804
- :nMin, :int,
1805
- :nMax, :int,
1806
- :nPage, :uint,
1807
- :nPos, :int,
1808
- :nTrackPos, :int
1809
- end
1810
-
1811
- attach_function :SetScrollInfo, [
1812
- :pointer,
1813
- :int,
1814
- SCROLLINFO.by_ref(:in),
1815
- :int
1816
- ], :int
1817
-
1818
- attach_function :GetScrollInfo, [
1819
- :pointer,
1820
- :int,
1821
- SCROLLINFO.by_ref
1822
- ], :int
1823
-
1824
- #{ ESB_xxx
1825
- ESB_DISABLE_LEFT = 0x0001
1826
- ESB_DISABLE_RIGHT = 0x0002
1827
- ESB_DISABLE_UP = 0x0001
1828
- ESB_DISABLE_DOWN = 0x0002
1829
-
1830
- ESB_ENABLE_BOTH = 0x0000
1831
- ESB_DISABLE_BOTH = 0x0003
1832
- #}
1833
-
1834
- attach_function :EnableScrollBar, [
1835
- :pointer,
1836
- :uint,
1837
- :uint
1838
- ], :int
1839
-
1840
- attach_function :ShowScrollBar, [
1841
- :pointer,
1842
- :int,
1843
- :int
1844
- ], :int
1845
-
1846
- attach_function :ScrollDC, [
1847
- :pointer,
1848
- :int,
1849
- :int,
1850
- RECT.by_ref(:in),
1851
- RECT.by_ref(:in),
1852
- :pointer,
1853
- RECT.by_ref(:out)
1854
- ], :int
1855
-
1856
- #{ SW_xxx
1857
- SW_INVALIDATE = 0x0002
1858
- SW_ERASE = 0x0004
1859
- SW_SCROLLCHILDREN = 0x0001
1860
- SW_SMOOTHSCROLL = 0x0010
1861
- #}
1862
-
1863
- attach_function :ScrollWindowEx, [
1864
- :pointer,
1865
- :int,
1866
- :int,
1867
- RECT.by_ref(:in),
1868
- RECT.by_ref(:in),
1869
- :pointer,
1870
- RECT.by_ref(:out),
1871
- :uint
1872
- ], :int
1873
-
1874
- attach_function :GetWindowRect, [
1875
- :pointer,
1876
- RECT.by_ref(:out)
1877
- ], :int
1878
-
1879
- attach_function :GetClientRect, [
1880
- :pointer,
1881
- RECT.by_ref(:out)
1882
- ], :int
1883
-
1884
- attach_function :ScreenToClient, [
1885
- :pointer,
1886
- POINT.by_ref
1887
- ], :int
1888
-
1889
- attach_function :ClientToScreen, [
1890
- :pointer,
1891
- POINT.by_ref
1892
- ], :int
1893
-
1894
- attach_function :InvalidateRect, [
1895
- :pointer,
1896
- RECT.by_ref(:in),
1897
- :int
1898
- ], :int
1899
-
1900
- attach_function :GetUpdateRect, [
1901
- :pointer,
1902
- RECT.by_ref(:out),
1903
- :int
1904
- ], :int
1905
-
1906
- attach_function :UpdateWindow, [
1907
- :pointer
1908
- ], :int
1909
-
1910
- class PAINTSTRUCT < FFI::Struct
1911
- extend Util::ScopedStruct
1912
-
1913
- layout \
1914
- :hdc, :pointer,
1915
- :fErase, :int,
1916
- :rcPaint, RECT,
1917
- :fRestore, :int,
1918
- :fIncUpdate, :int,
1919
- :rgbReserved, [:uchar, 32]
1920
- end
1921
-
1922
- attach_function :BeginPaint, [
1923
- :pointer,
1924
- PAINTSTRUCT.by_ref(:out)
1925
- ], :pointer
1926
-
1927
- attach_function :EndPaint, [
1928
- :pointer,
1929
- PAINTSTRUCT.by_ref(:in)
1930
- ], :int
1931
-
1932
- attach_function :SetCapture, [
1933
- :pointer
1934
- ], :pointer
1935
-
1936
- attach_function :ReleaseCapture, [
1937
-
1938
- ], :int
1939
-
1940
- attach_function :GetCapture, [
1941
-
1942
- ], :pointer
1943
-
1944
- attach_function :SetKeyboardState, [
1945
- :pointer
1946
- ], :int
1947
-
1948
- attach_function :GetKeyboardState, [
1949
- :pointer
1950
- ], :int
1951
-
1952
- attach_function :GetKeyState, [
1953
- :int
1954
- ], :short
1955
-
1956
- attach_function :GetAsyncKeyState, [
1957
- :int
1958
- ], :short
1959
-
1960
- #{ INPUT_xxx
1961
- INPUT_MOUSE = 0
1962
- INPUT_KEYBOARD = 1
1963
- INPUT_HARDWARE = 2
1964
- #}
1965
-
1966
- #{ MOUSEEVENTF_xxx
1967
- MOUSEEVENTF_LEFTDOWN = 0x0002
1968
- MOUSEEVENTF_LEFTUP = 0x0004
1969
-
1970
- MOUSEEVENTF_RIGHTDOWN = 0x0008
1971
- MOUSEEVENTF_RIGHTUP = 0x0010
1972
-
1973
- MOUSEEVENTF_MIDDLEDOWN = 0x0020
1974
- MOUSEEVENTF_MIDDLEUP = 0x0040
1975
-
1976
- MOUSEEVENTF_XDOWN = 0x0080
1977
- MOUSEEVENTF_XUP = 0x0100
1978
-
1979
- MOUSEEVENTF_WHEEL = 0x0800
1980
- if WINVER >= WINVISTA
1981
- MOUSEEVENTF_HWHEEL = 0x01000
1982
- end
1983
-
1984
- MOUSEEVENTF_MOVE = 0x0001
1985
- if WINVER >= WINVISTA
1986
- MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000
1987
- end
1988
-
1989
- MOUSEEVENTF_ABSOLUTE = 0x8000
1990
- MOUSEEVENTF_VIRTUALDESK = 0x4000
1991
- #}
1992
-
1993
- class MOUSEINPUT < FFI::Struct
1994
- extend Util::ScopedStruct
1995
-
1996
- layout \
1997
- :dx, :long,
1998
- :dy, :long,
1999
- :mouseData, :ulong,
2000
- :dwFlags, :ulong,
2001
- :time, :ulong,
2002
- :dwExtraInfo, :ulong
2003
- end
2004
-
2005
- #{ KEYEVENTF_xxx
2006
- KEYEVENTF_SCANCODE = 0x0008
2007
- KEYEVENTF_EXTENDEDKEY = 0x0001
2008
- KEYEVENTF_KEYUP = 0x0002
2009
- KEYEVENTF_UNICODE = 0x0004
2010
- #}
2011
-
2012
- class KEYBDINPUT < FFI::Struct
2013
- extend Util::ScopedStruct
2014
-
2015
- layout \
2016
- :wVk, :ushort,
2017
- :wScan, :ushort,
2018
- :dwFlags, :ulong,
2019
- :time, :ulong,
2020
- :dwExtraInfo, :ulong
2021
- end
2022
-
2023
- class HARDWAREINPUT < FFI::Struct
2024
- extend Util::ScopedStruct
2025
-
2026
- layout \
2027
- :uMsg, :ulong,
2028
- :wParamL, :ushort,
2029
- :wParamH, :ushort
2030
- end
2031
-
2032
- class INPUT < FFI::Struct
2033
- extend Util::ScopedStruct
2034
-
2035
- layout \
2036
- :type, :ulong,
2037
-
2038
- :_, Class.new(FFI::Union) {
2039
- layout \
2040
- :mi, MOUSEINPUT,
2041
- :ki, KEYBDINPUT,
2042
- :hi, HARDWAREINPUT
2043
- }
2044
- end
2045
-
2046
- attach_function :SendInput, [
2047
- :uint,
2048
- :pointer,
2049
- :int
2050
- ], :uint
2051
-
2052
- attach_function :GetSystemMenu, [
2053
- :pointer,
2054
- :int
2055
- ], :pointer
2056
-
2057
- attach_function :SetMenu, [
2058
- :pointer,
2059
- :pointer
2060
- ], :int
2061
-
2062
- attach_function :GetMenu, [
2063
- :pointer
2064
- ], :pointer
2065
-
2066
- attach_function :DrawMenuBar, [
2067
- :pointer
2068
- ], :int
2069
-
2070
- attach_function :GetDlgItem, [
2071
- :pointer,
2072
- :int
2073
- ], :pointer
2074
-
2075
- attach_function :GetDlgCtrlID, [
2076
- :pointer
2077
- ], :int
2078
-
2079
- #{ HWND_xxx
2080
- HWND_BROADCAST = FFI::Pointer.new(0xffff)
2081
- #}
2082
-
2083
- #{ WM_xxx
2084
- class CREATESTRUCT < FFI::Struct
2085
- extend Util::ScopedStruct
2086
-
2087
- layout \
2088
- :lpCreateParams, :pointer,
2089
- :hInstance, :pointer,
2090
- :hMenu, :pointer,
2091
- :hwndParent, :pointer,
2092
- :cy, :int,
2093
- :cx, :int,
2094
- :y, :int,
2095
- :x, :int,
2096
- :style, :long,
2097
- :lpszName, :pointer,
2098
- :lpszClass, :pointer,
2099
- :dwExStyle, :ulong
2100
- end
2101
-
2102
- WM_NCCREATE = 0x0081
2103
- WM_CREATE = 0x0001
2104
-
2105
- WM_CLOSE = 0x0010
2106
-
2107
- WM_DESTROY = 0x0002
2108
- WM_NCDESTROY = 0x0082
2109
-
2110
- WM_QUIT = 0x0012
2111
-
2112
- #{ ENDSESSION_xxx
2113
- ENDSESSION_CLOSEAPP = 0x00000001
2114
- ENDSESSION_CRITICAL = 0x40000000
2115
- ENDSESSION_LOGOFF = 0x80000000
2116
- #}
2117
-
2118
- WM_QUERYENDSESSION = 0x0011
2119
- WM_ENDSESSION = 0x0016
2120
-
2121
- class STYLESTRUCT < FFI::Struct
2122
- extend Util::ScopedStruct
2123
-
2124
- layout \
2125
- :styleOld, :ulong,
2126
- :styleNew, :ulong
2127
- end
2128
-
2129
- WM_STYLECHANGING = 0x007c
2130
- WM_STYLECHANGED = 0x007d
2131
-
2132
- WM_ENABLE = 0x000a
2133
-
2134
- #{ WA_xxx
2135
- WA_INACTIVE = 0
2136
- WA_ACTIVE = 1
2137
- WA_CLICKACTIVE = 2
2138
- #}
2139
-
2140
- WM_ACTIVATE = 0x0006
2141
-
2142
- WM_SETFOCUS = 0x0007
2143
- WM_KILLFOCUS = 0x0008
2144
-
2145
- #{ SW_xxx
2146
- SW_PARENTOPENING = 3
2147
- SW_PARENTCLOSING = 1
2148
- SW_OTHERZOOM = 2
2149
- SW_OTHERUNZOOM = 4
2150
- #}
2151
-
2152
- WM_SHOWWINDOW = 0x0018
2153
-
2154
- class MINMAXINFO < FFI::Struct
2155
- extend Util::ScopedStruct
2156
-
2157
- layout \
2158
- :ptReserved, POINT,
2159
- :ptMaxSize, POINT,
2160
- :ptMaxPosition, POINT,
2161
- :ptMinTrackSize, POINT,
2162
- :ptMaxTrackSize, POINT
2163
- end
2164
-
2165
- WM_GETMINMAXINFO = 0x0024
2166
-
2167
- class WINDOWPOS < FFI::Struct
2168
- extend Util::ScopedStruct
2169
-
2170
- layout \
2171
- :hwnd, :pointer,
2172
- :hwndInsertAfter, :pointer,
2173
- :x, :int,
2174
- :y, :int,
2175
- :cx, :int,
2176
- :cy, :int,
2177
- :flags, :int
2178
- end
2179
-
2180
- WM_WINDOWPOSCHANGING = 0x0046
2181
- WM_WINDOWPOSCHANGED = 0x0047
2182
-
2183
- WM_MOVING = 0x0216
2184
- WM_MOVE = 0x0003
2185
-
2186
- #{ WMSZ_xxx
2187
- WMSZ_LEFT = 1
2188
- WMSZ_TOP = 3
2189
- WMSZ_RIGHT = 2
2190
- WMSZ_BOTTOM = 6
2191
- WMSZ_TOPLEFT = 4
2192
- WMSZ_TOPRIGHT = 5
2193
- WMSZ_BOTTOMLEFT = 7
2194
- WMSZ_BOTTOMRIGHT = 8
2195
- #}
2196
-
2197
- WM_SIZING = 0x0214
2198
-
2199
- #{ SIZE_xxx
2200
- SIZE_MINIMIZED = 1
2201
- SIZE_MAXIMIZED = 2
2202
- SIZE_RESTORED = 0
2203
- SIZE_MAXHIDE = 4
2204
- SIZE_MAXSHOW = 3
2205
- #}
2206
-
2207
- WM_SIZE = 0x0005
2208
-
2209
- #{ SB_xxx
2210
- SB_LEFT = 6
2211
- SB_TOP = 6
2212
- SB_RIGHT = 7
2213
- SB_BOTTOM = 7
2214
-
2215
- SB_PAGELEFT = 2
2216
- SB_PAGERIGHT = 3
2217
- SB_PAGEUP = 2
2218
- SB_PAGEDOWN = 3
2219
-
2220
- SB_LINELEFT = 0
2221
- SB_LINERIGHT = 1
2222
- SB_LINEUP = 0
2223
- SB_LINEDOWN = 1
2224
-
2225
- SB_THUMBPOSITION = 4
2226
- SB_THUMBTRACK = 5
2227
-
2228
- SB_ENDSCROLL = 8
2229
- #}
2230
-
2231
- WM_HSCROLL = 0x0114
2232
- WM_VSCROLL = 0x0115
2233
-
2234
- #{ ICON_xxx
2235
- ICON_SMALL = 0
2236
- ICON_BIG = 1
2237
- if WINVER >= WINXP
2238
- ICON_SMALL2 = 2
2239
- end
2240
- #}
2241
-
2242
- WM_SETICON = 0x0080
2243
- WM_GETICON = 0x007f
2244
-
2245
- WM_SETTEXT = 0x000c
2246
- WM_GETTEXT = 0x000d
2247
- WM_GETTEXTLENGTH = 0x000e
2248
-
2249
- WM_SETFONT = 0x0030
2250
- WM_GETFONT = 0x0031
2251
-
2252
- WM_ERASEBKGND = 0x0014
2253
-
2254
- WM_PAINT = 0x000f
2255
-
2256
- #{ PRF_xxx
2257
- PRF_CHECKVISIBLE = 0x00000001
2258
- PRF_NONCLIENT = 0x00000002
2259
- PRF_CLIENT = 0x00000004
2260
- PRF_ERASEBKGND = 0x00000008
2261
- PRF_CHILDREN = 0x00000010
2262
- PRF_OWNED = 0x00000020
2263
- #}
2264
-
2265
- WM_PRINT = 0x0317
2266
- WM_PRINTCLIENT = 0x0318
2267
-
2268
- WM_CAPTURECHANGED = 0x0215
2269
-
2270
- #{ MK_xxx
2271
- MK_LBUTTON = 0x0001
2272
- MK_RBUTTON = 0x0002
2273
- MK_MBUTTON = 0x0010
2274
- MK_XBUTTON1 = 0x0020
2275
- MK_XBUTTON2 = 0x0040
2276
-
2277
- MK_CONTROL = 0x0008
2278
- MK_SHIFT = 0x0004
2279
- #}
2280
-
2281
- WM_LBUTTONDOWN = 0x0201
2282
- WM_LBUTTONUP = 0x0202
2283
- WM_LBUTTONDBLCLK = 0x0203
2284
-
2285
- WM_RBUTTONDOWN = 0x0204
2286
- WM_RBUTTONUP = 0x0205
2287
- WM_RBUTTONDBLCLK = 0x0206
2288
-
2289
- WM_MBUTTONDOWN = 0x0207
2290
- WM_MBUTTONUP = 0x0208
2291
- WM_MBUTTONDBLCLK = 0x0209
2292
-
2293
- #{ XBUTTONxxx
2294
- XBUTTON1 = 0x0001
2295
- XBUTTON2 = 0x0002
2296
- #}
2297
-
2298
- WM_XBUTTONDOWN = 0x020b
2299
- WM_XBUTTONUP = 0x020c
2300
- WM_XBUTTONDBLCLK = 0x020d
2301
-
2302
- #{ WHEEL_xxx
2303
- WHEEL_DELTA = 120
2304
- #}
2305
-
2306
- WM_MOUSEWHEEL = 0x020a
2307
- if WINVER >= WINVISTA # WM_MOUSEHWHEEL
2308
- WM_MOUSEHWHEEL = 0x020e
2309
- end
2310
-
2311
- WM_MOUSEMOVE = 0x0200
2312
-
2313
- WM_SYSKEYDOWN = 0x0104
2314
- WM_SYSKEYUP = 0x0105
2315
-
2316
- WM_SYSCHAR = 0x0106
2317
- WM_SYSDEADCHAR = 0x0107
2318
-
2319
- WM_KEYDOWN = 0x0100
2320
- WM_KEYUP = 0x0101
2321
-
2322
- WM_CHAR = 0x0102
2323
- WM_DEADCHAR = 0x0103
2324
-
2325
- WM_CONTEXTMENU = 0x007b
2326
-
2327
- WM_INITMENU = 0x0116
2328
- WM_INITMENUPOPUP = 0x0117
2329
-
2330
- WM_USER = 0x0400
2331
- WM_APP = 0x8000
2332
-
2333
- #{ SC_xxx
2334
- SC_DEFAULT = 0xf160
2335
-
2336
- SC_MOVE = 0xf010
2337
- SC_SIZE = 0xf000
2338
- SC_MINIMIZE = 0xf020
2339
- SC_MAXIMIZE = 0xf030
2340
- SC_RESTORE = 0xf120
2341
- SC_CLOSE = 0xf060
2342
-
2343
- SC_HSCROLL = 0xf080
2344
- SC_VSCROLL = 0xf070
2345
-
2346
- SC_NEXTWINDOW = 0xf040
2347
- SC_PREVWINDOW = 0xf050
2348
- SC_ARRANGE = 0xf110
2349
-
2350
- SC_MOUSEMENU = 0xf090
2351
- SC_KEYMENU = 0xf100
2352
- SC_HOTKEY = 0xf150
2353
-
2354
- SC_TASKLIST = 0xf130
2355
- SC_SCREENSAVE = 0xf140
2356
- SC_MONITORPOWER = 0xf170
2357
-
2358
- SC_CONTEXTHELP = 0xf180
2359
- #}
2360
-
2361
- (SYSID = {}).
2362
- instance_variable_set(:@last, 0xf00)
2363
-
2364
- class << SYSID
2365
- private :[]=, :store
2366
-
2367
- def [](key)
2368
- (id = fetch(key, nil)) ?
2369
- id :
2370
- self[key] = (@last -= 1) << 4
2371
- end
2372
- end
2373
-
2374
- WM_SYSCOMMAND = 0x0112
2375
-
2376
- (ID = {}).
2377
- instance_variable_set(:@last, WM_APP)
2378
-
2379
- class << ID
2380
- private :[]=, :store
2381
-
2382
- def [](key)
2383
- (id = fetch(key, nil)) ?
2384
- id :
2385
- self[key] = @last += 1
2386
- end
2387
- end
2388
-
2389
- WM_COMMAND = 0x0111
2390
-
2391
- class NMHDR < FFI::Struct
2392
- extend Util::ScopedStruct
2393
-
2394
- layout \
2395
- :hwndFrom, :pointer,
2396
- :idFrom, :uint,
2397
- :code, :uint
2398
- end
2399
-
2400
- WM_NOTIFY = 0x004e
2401
-
2402
- WM_CTLCOLORBTN = 0x0135
2403
- WM_CTLCOLORSTATIC = 0x0138
2404
- WM_CTLCOLOREDIT = 0x0133
2405
- WM_CTLCOLORLISTBOX = 0x0134
2406
- WM_CTLCOLORSCROLLBAR = 0x0137
2407
-
2408
- attach_function :RegisterWindowMessage, :RegisterWindowMessageW, [
2409
- :buffer_in
2410
- ], :uint
2411
- #}
2412
-
2413
- attach_function :SendMessage, :SendMessageW, [
2414
- :pointer,
2415
- :uint,
2416
- :uint,
2417
- :long
2418
- ], :long
2419
-
2420
- attach_function :PostMessage, :PostMessageW, [
2421
- :pointer,
2422
- :uint,
2423
- :uint,
2424
- :long
2425
- ], :int
2426
-
2427
- attach_function :PostQuitMessage, [
2428
- :int
2429
- ], :void
2430
-
2431
- class MSG < FFI::Struct
2432
- extend Util::ScopedStruct
2433
-
2434
- layout \
2435
- :hwnd, :pointer,
2436
- :message, :uint,
2437
- :wParam, :uint,
2438
- :lParam, :long,
2439
- :time, :ulong,
2440
- :pt, POINT
2441
- end
2442
-
2443
- #{ PM_xxx
2444
- PM_NOREMOVE = 0x0000
2445
- PM_REMOVE = 0x0001
2446
- PM_NOYIELD = 0x0002
2447
- #}
2448
-
2449
- attach_function :PeekMessage, :PeekMessageW, [
2450
- MSG.by_ref(:out),
2451
- :pointer,
2452
- :uint,
2453
- :uint,
2454
- :uint
2455
- ], :int
2456
-
2457
- attach_function :GetMessage, :GetMessageW, [
2458
- MSG.by_ref(:out),
2459
- :pointer,
2460
- :uint,
2461
- :uint
2462
- ], :int
2463
-
2464
- attach_function :IsDialogMessage, [
2465
- :pointer,
2466
- MSG.by_ref(:in)
2467
- ], :int
2468
-
2469
- attach_function :TranslateAccelerator, :TranslateAcceleratorW, [
2470
- :pointer,
2471
- :pointer,
2472
- MSG.by_ref(:in)
2473
- ], :int
2474
-
2475
- attach_function :TranslateMessage, [
2476
- MSG.by_ref(:in)
2477
- ], :int
2478
-
2479
- attach_function :DispatchMessage, :DispatchMessageW, [
2480
- MSG.by_ref(:in)
2481
- ], :long
2482
-
2483
- attach_function :CreateMenu, [
2484
-
2485
- ], :pointer
2486
-
2487
- attach_function :CreatePopupMenu, [
2488
-
2489
- ], :pointer
2490
-
2491
- attach_function :DestroyMenu, [
2492
- :pointer
2493
- ], :int
2494
-
2495
- #{ MF_xxx
2496
- MF_BYCOMMAND = 0x00000000
2497
- MF_BYPOSITION = 0x00000400
2498
-
2499
- MF_POPUP = 0x00000010
2500
- MF_STRING = 0x00000000
2501
- MF_BITMAP = 0x00000004
2502
- MF_OWNERDRAW = 0x00000100
2503
- MF_SEPARATOR = 0x00000800
2504
-
2505
- MF_MENUBARBREAK = 0x00000020
2506
- MF_MENUBREAK = 0x00000040
2507
- MF_RIGHTJUSTIFY = 0x00004000
2508
-
2509
- MF_DEFAULT = 0x00001000
2510
- MF_ENABLED = 0x00000000
2511
- MF_DISABLED = 0x00000002
2512
- MF_GRAYED = 0x00000001
2513
- MF_CHECKED = 0x00000008
2514
- MF_UNCHECKED = 0x00000000
2515
- MF_HILITE = 0x00000080
2516
- MF_UNHILITE = 0x00000000
2517
- #}
2518
-
2519
- #{ MFT_xxx
2520
- MFT_RADIOCHECK = 0x00000200
2521
- #}
2522
-
2523
- #{ MFS_xxx
2524
- MFS_GRAYED = 0x00000003
2525
- #}
2526
-
2527
- attach_function :AppendMenu, :AppendMenuW, [
2528
- :pointer,
2529
- :uint,
2530
- :uint,
2531
- :buffer_in
2532
- ], :int
2533
-
2534
- attach_function :InsertMenu, :InsertMenuW, [
2535
- :pointer,
2536
- :uint,
2537
- :uint,
2538
- :uint,
2539
- :buffer_in
2540
- ], :int
2541
-
2542
- attach_function :ModifyMenu, :ModifyMenuW, [
2543
- :pointer,
2544
- :uint,
2545
- :uint,
2546
- :uint,
2547
- :buffer_in
2548
- ], :int
2549
-
2550
- attach_function :GetMenuItemID, [
2551
- :pointer,
2552
- :int
2553
- ], :uint
2554
-
2555
- attach_function :GetSubMenu, [
2556
- :pointer,
2557
- :int
2558
- ], :pointer
2559
-
2560
- attach_function :RemoveMenu, [
2561
- :pointer,
2562
- :uint,
2563
- :uint
2564
- ], :int
2565
-
2566
- attach_function :DeleteMenu, [
2567
- :pointer,
2568
- :uint,
2569
- :uint
2570
- ], :int
2571
-
2572
- attach_function :SetMenuDefaultItem, [
2573
- :pointer,
2574
- :uint,
2575
- :uint
2576
- ], :int
2577
-
2578
- #{ GMDI_xxx
2579
- GMDI_USEDISABLED = 0x0001
2580
- GMDI_GOINTOPOPUPS = 0x0002
2581
- #}
2582
-
2583
- attach_function :GetMenuDefaultItem, [
2584
- :pointer,
2585
- :uint,
2586
- :uint
2587
- ], :uint
2588
-
2589
- attach_function :EnableMenuItem, [
2590
- :pointer,
2591
- :uint,
2592
- :uint
2593
- ], :int
2594
-
2595
- attach_function :CheckMenuItem, [
2596
- :pointer,
2597
- :uint,
2598
- :uint
2599
- ], :ulong
2600
-
2601
- attach_function :CheckMenuRadioItem, [
2602
- :pointer,
2603
- :uint,
2604
- :uint,
2605
- :uint,
2606
- :uint
2607
- ], :int
2608
-
2609
- attach_function :HiliteMenuItem, [
2610
- :pointer,
2611
- :pointer,
2612
- :uint,
2613
- :uint
2614
- ], :int
2615
-
2616
- attach_function :GetMenuState, [
2617
- :pointer,
2618
- :uint,
2619
- :uint
2620
- ], :uint
2621
-
2622
- #{ MIIM_xxx
2623
- MIIM_FTYPE = 0x00000100
2624
- MIIM_STATE = 0x00000001
2625
- MIIM_ID = 0x00000002
2626
- MIIM_SUBMENU = 0x00000004
2627
- MIIM_CHECKMARKS = 0x00000008
2628
- MIIM_DATA = 0x00000020
2629
- MIIM_STRING = 0x00000040
2630
- MIIM_BITMAP = 0x00000080
2631
- #}
2632
-
2633
- class MENUITEMINFO < FFI::Struct
2634
- extend Util::ScopedStruct
2635
-
2636
- layout \
2637
- :cbSize, :uint,
2638
- :fMask, :uint,
2639
- :fType, :uint,
2640
- :fState, :uint,
2641
- :wID, :uint,
2642
- :hSubMenu, :pointer,
2643
- :hbmpChecked, :pointer,
2644
- :hbmpUnchecked, :pointer,
2645
- :dwItemData, :ulong,
2646
- :dwTypeData, :pointer,
2647
- :cch, :uint,
2648
- :hbmpItem, :pointer
2649
- end
2650
-
2651
- attach_function :InsertMenuItem, :InsertMenuItemW, [
2652
- :pointer,
2653
- :uint,
2654
- :int,
2655
- MENUITEMINFO.by_ref(:in)
2656
- ], :int
2657
-
2658
- attach_function :SetMenuItemInfo, :SetMenuItemInfoW, [
2659
- :pointer,
2660
- :uint,
2661
- :int,
2662
- MENUITEMINFO.by_ref(:in)
2663
- ], :int
2664
-
2665
- attach_function :GetMenuItemInfo, :GetMenuItemInfoW, [
2666
- :pointer,
2667
- :uint,
2668
- :int,
2669
- MENUITEMINFO.by_ref
2670
- ], :int
2671
-
2672
- #{ TPM_xxx
2673
- TPM_LEFTBUTTON = 0x0000
2674
- TPM_RIGHTBUTTON = 0x0002
2675
-
2676
- TPM_LEFTALIGN = 0x0000
2677
- TPM_CENTERALIGN = 0x0004
2678
- TPM_RIGHTALIGN = 0x0008
2679
-
2680
- TPM_TOPALIGN = 0x0000
2681
- TPM_VCENTERALIGN = 0x0010
2682
- TPM_BOTTOMALIGN = 0x0020
2683
-
2684
- TPM_HORIZONTAL = 0x0000
2685
- TPM_VERTICAL = 0x0040
2686
-
2687
- TPM_NONOTIFY = 0x0080
2688
- TPM_RETURNCMD = 0x0100
2689
-
2690
- TPM_RECURSE = 0x0001
2691
- #}
2692
-
2693
- attach_function :TrackPopupMenu, [
2694
- :pointer,
2695
- :uint,
2696
- :int,
2697
- :int,
2698
- :int,
2699
- :pointer,
2700
- RECT.by_ref(:in)
2701
- ], :int
2702
-
2703
- attach_function :EndMenu, [
2704
-
2705
- ], :int
2706
-
2707
- #{ Fxxx
2708
- FVIRTKEY = 1
2709
- FCONTROL = 0x08
2710
- FSHIFT = 0x04
2711
- FALT = 0x10
2712
- #}
2713
-
2714
- #{ VK_xxx
2715
- VK_LBUTTON = 0x01
2716
- VK_RBUTTON = 0x02
2717
- VK_MBUTTON = 0x04
2718
- VK_XBUTTON1 = 0x05
2719
- VK_XBUTTON2 = 0x06
2720
-
2721
- VK_CONTROL = 0x11
2722
- VK_SHIFT = 0x10
2723
- VK_MENU = 0x12
2724
-
2725
- VK_LCONTROL = 0xa2
2726
- VK_RCONTROL = 0xa3
2727
- VK_LSHIFT = 0xa0
2728
- VK_RSHIFT = 0xa1
2729
- VK_LMENU = 0xa4
2730
- VK_RMENU = 0xa5
2731
- VK_LWIN = 0x5b
2732
- VK_RWIN = 0x5c
2733
-
2734
- VK_F1 = 0x70
2735
- VK_F2 = 0x71
2736
- VK_F3 = 0x72
2737
- VK_F4 = 0x73
2738
- VK_F5 = 0x74
2739
- VK_F6 = 0x75
2740
- VK_F7 = 0x76
2741
- VK_F8 = 0x77
2742
- VK_F9 = 0x78
2743
- VK_F10 = 0x79
2744
- VK_F11 = 0x7a
2745
- VK_F12 = 0x7b
2746
-
2747
- VK_SNAPSHOT = 0x2c
2748
- VK_PAUSE = 0x13
2749
- VK_CANCEL = 0x03
2750
-
2751
- VK_CAPITAL = 0x14
2752
- VK_NUMLOCK = 0x90
2753
- VK_SCROLL = 0x91
2754
-
2755
- VK_ESCAPE = 0x1b
2756
- VK_RETURN = 0x0d
2757
- VK_TAB = 0x09
2758
- VK_SPACE = 0x20
2759
-
2760
- VK_INSERT = 0x2d
2761
- VK_DELETE = 0x2e
2762
- VK_BACK = 0x08
2763
-
2764
- VK_HOME = 0x24
2765
- VK_END = 0x23
2766
- VK_PRIOR = 0x21
2767
- VK_NEXT = 0x22
2768
- VK_LEFT = 0x25
2769
- VK_RIGHT = 0x27
2770
- VK_UP = 0x26
2771
- VK_DOWN = 0x28
2772
-
2773
- VK_NUMPAD0 = 0x60
2774
- VK_NUMPAD1 = 0x61
2775
- VK_NUMPAD2 = 0x62
2776
- VK_NUMPAD3 = 0x63
2777
- VK_NUMPAD4 = 0x64
2778
- VK_NUMPAD5 = 0x65
2779
- VK_NUMPAD6 = 0x66
2780
- VK_NUMPAD7 = 0x67
2781
- VK_NUMPAD8 = 0x68
2782
- VK_NUMPAD9 = 0x69
2783
- VK_DECIMAL = 0x6e
2784
- VK_ADD = 0x6b
2785
- VK_SUBTRACT = 0x6d
2786
- VK_MULTIPLY = 0x6a
2787
- VK_DIVIDE = 0x6f
2788
-
2789
- VK_MEDIA_PLAY_PAUSE = 0xb3
2790
- VK_MEDIA_STOP = 0xb2
2791
- VK_MEDIA_NEXT_TRACK = 0xb0
2792
- VK_MEDIA_PREV_TRACK = 0xb1
2793
-
2794
- VK_VOLUME_MUTE = 0xad
2795
- VK_VOLUME_UP = 0xaf
2796
- VK_VOLUME_DOWN = 0xae
2797
- #}
2798
-
2799
- class ACCEL < FFI::Struct
2800
- extend Util::ScopedStruct
2801
-
2802
- layout \
2803
- :fVirt, :uchar,
2804
- :key, :ushort,
2805
- :cmd, :ushort
2806
- end
2807
-
2808
- attach_function :CreateAcceleratorTable, :CreateAcceleratorTableW, [
2809
- :pointer,
2810
- :int
2811
- ], :pointer
2812
-
2813
- attach_function :DestroyAcceleratorTable, [
2814
- :pointer
2815
- ], :int
2816
-
2817
- attach_function :CopyAcceleratorTable, :CopyAcceleratorTableW, [
2818
- :pointer,
2819
- :pointer,
2820
- :int
2821
- ], :int
2822
-
2823
- #{ BS_xxx
2824
- BS_PUSHBUTTON = 0x00000000
2825
- BS_DEFPUSHBUTTON = 0x00000001
2826
-
2827
- BS_CHECKBOX = 0x00000002
2828
- BS_AUTOCHECKBOX = 0x00000003
2829
-
2830
- BS_3STATE = 0x00000005
2831
- BS_AUTO3STATE = 0x00000006
2832
-
2833
- BS_RADIOBUTTON = 0x00000004
2834
- BS_AUTORADIOBUTTON = 0x00000009
2835
-
2836
- BS_GROUPBOX = 0x00000007
2837
-
2838
- BS_TEXT = 0x00000000
2839
- BS_BITMAP = 0x00000080
2840
- BS_ICON = 0x00000040
2841
- BS_OWNERDRAW = 0x0000000b
2842
-
2843
- BS_LEFT = 0x00000100
2844
- BS_CENTER = 0x00000300
2845
- BS_RIGHT = 0x00000200
2846
-
2847
- BS_TOP = 0x00000400
2848
- BS_VCENTER = 0x00000c00
2849
- BS_BOTTOM = 0x00000800
2850
-
2851
- BS_MULTILINE = 0x00002000
2852
-
2853
- BS_LEFTTEXT = 0x00000020
2854
-
2855
- BS_FLAT = 0x00008000
2856
- BS_PUSHLIKE = 0x00001000
2857
-
2858
- BS_NOTIFY = 0x00004000
2859
- #}
2860
-
2861
- #{ BM_xxx
2862
- BM_SETSTYLE = 0x00f4
2863
-
2864
- BM_SETIMAGE = 0x00f7
2865
- BM_GETIMAGE = 0x00f6
2866
-
2867
- #{ BST_xxx
2868
- BST_FOCUS = 0x0008
2869
- BST_PUSHED = 0x0004
2870
- BST_UNCHECKED = 0x0000
2871
- BST_CHECKED = 0x0001
2872
- BST_INDETERMINATE = 0x0002
2873
- #}
2874
-
2875
- BM_SETSTATE = 0x00f3
2876
- BM_GETSTATE = 0x00f2
2877
-
2878
- BM_SETCHECK = 0x00f1
2879
- BM_GETCHECK = 0x00f0
2880
-
2881
- BM_CLICK = 0x00f5
2882
- if WINVER >= WINVISTA
2883
- BM_SETDONTCLICK = 0x00f8
2884
- end
2885
- #}
2886
-
2887
- #{ BN_xxx
2888
- BN_SETFOCUS = 6
2889
- BN_KILLFOCUS = 7
2890
-
2891
- BN_CLICKED = 0
2892
- BN_DBLCLK = 5
2893
- #}
2894
-
2895
- #{ SS_xxx
2896
- SS_NOPREFIX = 0x00000080
2897
- SS_ENDELLIPSIS = 0x00004000
2898
- SS_WORDELLIPSIS = 0x0000c000
2899
- SS_PATHELLIPSIS = 0x00008000
2900
- SS_EDITCONTROL = 0x00002000
2901
-
2902
- SS_SIMPLE = 0x0000000b
2903
- SS_BITMAP = 0x0000000e
2904
- SS_ICON = 0x00000003
2905
- SS_OWNERDRAW = 0x0000000d
2906
-
2907
- SS_LEFT = 0x00000000
2908
- SS_LEFTNOWORDWRAP = 0x0000000c
2909
- SS_CENTER = 0x00000001
2910
- SS_CENTERIMAGE = 0x00000200
2911
- SS_RIGHT = 0x00000002
2912
- SS_RIGHTJUST = 0x00000400
2913
-
2914
- SS_SUNKEN = 0x00001000
2915
-
2916
- SS_ETCHEDHORZ = 0x00000010
2917
- SS_ETCHEDVERT = 0x00000011
2918
- SS_ETCHEDFRAME = 0x00000012
2919
-
2920
- SS_BLACKFRAME = 0x00000007
2921
- SS_GRAYFRAME = 0x00000008
2922
- SS_WHITEFRAME = 0x00000009
2923
-
2924
- SS_BLACKRECT = 0x00000004
2925
- SS_GRAYRECT = 0x00000005
2926
- SS_WHITERECT = 0x00000006
2927
-
2928
- if WINVER >= WINXP
2929
- SS_REALSIZECONTROL = 0x00000040
2930
- end
2931
- SS_REALSIZEIMAGE = 0x00000800
2932
-
2933
- SS_NOTIFY = 0x00000100
2934
- #}
2935
-
2936
- #{ STM_xxx
2937
- STM_SETIMAGE = 0x0172
2938
- STM_GETIMAGE = 0x0173
2939
-
2940
- STM_SETICON = 0x0170
2941
- STM_GETICON = 0x0171
2942
- #}
2943
-
2944
- #{ STN_xxx
2945
- STN_ENABLE = 2
2946
- STN_DISABLE = 3
2947
-
2948
- STN_CLICKED = 0
2949
- STN_DBLCLK = 1
2950
- #}
2951
-
2952
- #{ ES_xxx
2953
- ES_NUMBER = 0x2000
2954
- ES_LOWERCASE = 0x0010
2955
- ES_UPPERCASE = 0x0008
2956
- ES_PASSWORD = 0x0020
2957
- ES_MULTILINE = 0x0004
2958
- ES_WANTRETURN = 0x1000
2959
-
2960
- ES_LEFT = 0x0000
2961
- ES_CENTER = 0x0001
2962
- ES_RIGHT = 0x0002
2963
-
2964
- ES_AUTOHSCROLL = 0x0080
2965
- ES_AUTOVSCROLL = 0x0040
2966
- ES_NOHIDESEL = 0x0100
2967
- ES_READONLY = 0x0800
2968
- #}
2969
-
2970
- #{ EM_xxx
2971
- EM_SETLIMITTEXT = 0x00c5
2972
- EM_GETLIMITTEXT = 0x00d5
2973
-
2974
- EM_SETPASSWORDCHAR = 0x00cc
2975
- EM_GETPASSWORDCHAR = 0x00d2
2976
-
2977
- EM_SETTABSTOPS = 0x00cb
2978
- EM_FMTLINES = 0x00c8
2979
-
2980
- EM_SETSEL = 0x00b1
2981
- EM_GETSEL = 0x00b0
2982
-
2983
- EM_REPLACESEL = 0x00c2
2984
-
2985
- EM_SETRECT = 0x00b3
2986
- EM_SETRECTNP = 0x00b4
2987
- EM_GETRECT = 0x00b2
2988
-
2989
- #{ EC_xxx
2990
- EC_LEFTMARGIN = 0x0001
2991
- EC_RIGHTMARGIN = 0x0002
2992
- EC_USEFONTINFO = 0xffff
2993
- #}
2994
-
2995
- EM_SETMARGINS = 0x00d3
2996
- EM_GETMARGINS = 0x00d4
2997
-
2998
- EM_SETHANDLE = 0x00bc
2999
- EM_GETHANDLE = 0x00bd
3000
-
3001
- #{ WB_xxx
3002
- WB_LEFT = 0
3003
- WB_RIGHT = 1
3004
- WB_ISDELIMITER = 2
3005
- #}
3006
-
3007
- callback :EDITWORDBREAKPROC, [
3008
- :buffer_in,
3009
- :int,
3010
- :int,
3011
- :int
3012
- ], :int
3013
-
3014
- EM_SETWORDBREAKPROC = 0x00d0
3015
- EM_GETWORDBREAKPROC = 0x00d1
3016
-
3017
- EM_SETMODIFY = 0x00b9
3018
- EM_GETMODIFY = 0x00b8
3019
-
3020
- EM_CANUNDO = 0x00c6
3021
- EM_UNDO = 0x00c7
3022
- EM_EMPTYUNDOBUFFER = 0x00cd
3023
-
3024
- EM_SCROLL = 0x00b5
3025
- EM_LINESCROLL = 0x00b6
3026
- EM_SCROLLCARET = 0x00b7
3027
- EM_GETTHUMB = 0x00be
3028
-
3029
- EM_GETLINECOUNT = 0x00ba
3030
- EM_LINELENGTH = 0x00c1
3031
- EM_GETLINE = 0x00c4
3032
- EM_GETFIRSTVISIBLELINE = 0x00ce
3033
- EM_LINEINDEX = 0x00bb
3034
- EM_LINEFROMCHAR = 0x00c9
3035
-
3036
- EM_POSFROMCHAR = 0x00d6
3037
- EM_CHARFROMPOS = 0x00d7
3038
-
3039
- EM_SETREADONLY = 0x00cf
3040
- #}
3041
-
3042
- #{ EN_xxx
3043
- EN_ERRSPACE = 0x0500
3044
- EN_MAXTEXT = 0x0501
3045
-
3046
- EN_SETFOCUS = 0x0100
3047
- EN_KILLFOCUS = 0x0200
3048
-
3049
- EN_UPDATE = 0x0400
3050
- EN_CHANGE = 0x0300
3051
-
3052
- EN_HSCROLL = 0x0601
3053
- EN_VSCROLL = 0x0602
3054
- #}
3055
-
3056
- #{ LBS_xxx
3057
- LBS_USETABSTOPS = 0x0080
3058
- LBS_MULTICOLUMN = 0x0200
3059
- LBS_MULTIPLESEL = 0x0008
3060
- LBS_EXTENDEDSEL = 0x0800
3061
- LBS_WANTKEYBOARDINPUT = 0x0400
3062
- LBS_COMBOBOX = 0x8000
3063
-
3064
- LBS_HASSTRINGS = 0x0040
3065
- LBS_OWNERDRAWFIXED = 0x0010
3066
- LBS_OWNERDRAWVARIABLE = 0x0020
3067
-
3068
- LBS_SORT = 0x0002
3069
-
3070
- LBS_DISABLENOSCROLL = 0x1000
3071
- LBS_NOINTEGRALHEIGHT = 0x0100
3072
- LBS_NODATA = 0x2000
3073
- LBS_NOSEL = 0x4000
3074
- LBS_NOREDRAW = 0x0004
3075
-
3076
- LBS_NOTIFY = 0x0001
3077
-
3078
- LBS_STANDARD = WS_BORDER | WS_VSCROLL | LBS_SORT | LBS_NOTIFY
3079
- #}
3080
-
3081
- attach_function :GetListBoxInfo, [
3082
- :pointer
3083
- ], :ulong
3084
-
3085
- #{ DDL_xxx
3086
- DDL_DRIVES = 0x4000
3087
- DDL_DIRECTORY = 0x0010
3088
- DDL_EXCLUSIVE = 0x8000
3089
-
3090
- DDL_READWRITE = 0x0000
3091
- DDL_READONLY = 0x0001
3092
- DDL_HIDDEN = 0x0002
3093
- DDL_SYSTEM = 0x0004
3094
- DDL_ARCHIVE = 0x0020
3095
-
3096
- DDL_POSTMSGS = 0x2000
3097
- #}
3098
-
3099
- attach_function :DlgDirList, :DlgDirListW, [
3100
- :pointer,
3101
- :buffer_inout,
3102
- :int,
3103
- :int,
3104
- :uint
3105
- ], :int
3106
-
3107
- attach_function :DlgDirSelectEx, :DlgDirSelectExW, [
3108
- :pointer,
3109
- :buffer_out,
3110
- :int,
3111
- :int
3112
- ], :int
3113
-
3114
- #{ LB_xxx
3115
- LB_OKAY = 0
3116
- LB_ERR = -1
3117
- LB_ERRSPACE = -2
3118
-
3119
- LB_INITSTORAGE = 0x01a8
3120
-
3121
- LB_SETCOUNT = 0x01a7
3122
- LB_GETCOUNT = 0x018b
3123
-
3124
- LB_ADDSTRING = 0x0180
3125
- LB_INSERTSTRING = 0x0181
3126
- LB_DIR = 0x018d
3127
- LB_ADDFILE = 0x0196
3128
-
3129
- LB_DELETESTRING = 0x0182
3130
- LB_RESETCONTENT = 0x0184
3131
-
3132
- LB_SETCURSEL = 0x0186
3133
- LB_GETCURSEL = 0x0188
3134
-
3135
- LB_SELECTSTRING = 0x018c
3136
-
3137
- LB_FINDSTRING = 0x018f
3138
- LB_FINDSTRINGEXACT = 0x01a2
3139
-
3140
- LB_GETTEXTLEN = 0x018a
3141
- LB_GETTEXT = 0x0189
3142
-
3143
- LB_SETITEMDATA = 0x019a
3144
- LB_GETITEMDATA = 0x0199
3145
-
3146
- LB_SETSEL = 0x0185
3147
- LB_GETSEL = 0x0187
3148
-
3149
- LB_GETSELCOUNT = 0x0190
3150
- LB_GETSELITEMS = 0x0191
3151
-
3152
- LB_SELITEMRANGEEX = 0x0183
3153
-
3154
- LB_SETLOCALE = 0x01a5
3155
- LB_GETLOCALE = 0x01a6
3156
-
3157
- LB_SETTABSTOPS = 0x0192
3158
- LB_SETCOLUMNWIDTH = 0x0195
3159
- if WINVER >= WINXP
3160
- LB_GETLISTBOXINFO = 0x01b2
3161
- end
3162
-
3163
- LB_SETHORIZONTALEXTENT = 0x0194
3164
- LB_GETHORIZONTALEXTENT = 0x0193
3165
-
3166
- LB_SETTOPINDEX = 0x0197
3167
- LB_GETTOPINDEX = 0x018e
3168
-
3169
- LB_SETANCHORINDEX = 0x019c
3170
- LB_GETANCHORINDEX = 0x019d
3171
-
3172
- LB_SETCARETINDEX = 0x019e
3173
- LB_GETCARETINDEX = 0x019f
3174
-
3175
- LB_SETITEMHEIGHT = 0x01a0
3176
- LB_GETITEMHEIGHT = 0x01a1
3177
-
3178
- LB_GETITEMRECT = 0x0198
3179
- LB_ITEMFROMPOINT = 0x01a9
3180
- #}
3181
-
3182
- #{ LBN_xxx
3183
- LBN_ERRSPACE = -2
3184
-
3185
- LBN_SETFOCUS = 4
3186
- LBN_KILLFOCUS = 5
3187
-
3188
- LBN_SELCHANGE = 1
3189
- LBN_SELCANCEL = 3
3190
-
3191
- LBN_DBLCLK = 2
3192
- #}
3193
-
3194
- #{ CBS_xxx
3195
- CBS_SIMPLE = 0x0001
3196
- CBS_DROPDOWN = 0x0002
3197
- CBS_DROPDOWNLIST = 0x0003
3198
- CBS_LOWERCASE = 0x4000
3199
- CBS_UPPERCASE = 0x2000
3200
-
3201
- CBS_HASSTRINGS = 0x0200
3202
- CBS_OWNERDRAWFIXED = 0x0010
3203
- CBS_OWNERDRAWVARIABLE = 0x0020
3204
-
3205
- CBS_SORT = 0x0100
3206
-
3207
- CBS_AUTOHSCROLL = 0x0040
3208
- CBS_DISABLENOSCROLL = 0x0800
3209
- CBS_NOINTEGRALHEIGHT = 0x0400
3210
- #}
3211
-
3212
- class COMBOBOXINFO < FFI::Struct
3213
- extend Util::ScopedStruct
3214
-
3215
- layout \
3216
- :cbSize, :ulong,
3217
- :rcItem, RECT,
3218
- :rcButton, RECT,
3219
- :stateButton, :ulong,
3220
- :hwndCombo, :pointer,
3221
- :hwndItem, :pointer,
3222
- :hwndList, :pointer
3223
- end
3224
-
3225
- attach_function :GetComboBoxInfo, [
3226
- :pointer,
3227
- COMBOBOXINFO.by_ref
3228
- ], :int
3229
-
3230
- attach_function :DlgDirListComboBox, :DlgDirListComboBoxW, [
3231
- :pointer,
3232
- :buffer_inout,
3233
- :int,
3234
- :int,
3235
- :uint
3236
- ], :int
3237
-
3238
- attach_function :DlgDirSelectComboBoxEx, :DlgDirSelectComboBoxExW, [
3239
- :pointer,
3240
- :buffer_out,
3241
- :int,
3242
- :int
3243
- ], :int
3244
-
3245
- #{ CB_xxx
3246
- CB_OKAY = 0
3247
- CB_ERR = -1
3248
- CB_ERRSPACE = -2
3249
-
3250
- CB_LIMITTEXT = 0x0141
3251
-
3252
- CB_INITSTORAGE = 0x0161
3253
-
3254
- CB_GETCOUNT = 0x0146
3255
-
3256
- CB_ADDSTRING = 0x0143
3257
- CB_INSERTSTRING = 0x014a
3258
- CB_DIR = 0x0145
3259
-
3260
- CB_DELETESTRING = 0x0144
3261
- CB_RESETCONTENT = 0x014b
3262
-
3263
- CB_SETCURSEL = 0x014e
3264
- CB_GETCURSEL = 0x0147
3265
-
3266
- CB_SELECTSTRING = 0x014d
3267
-
3268
- CB_FINDSTRING = 0x014c
3269
- CB_FINDSTRINGEXACT = 0x0158
3270
-
3271
- CB_GETLBTEXTLEN = 0x0149
3272
- CB_GETLBTEXT = 0x0148
3273
-
3274
- CB_SETITEMDATA = 0x0151
3275
- CB_GETITEMDATA = 0x0150
3276
-
3277
- CB_SETEDITSEL = 0x0142
3278
- CB_GETEDITSEL = 0x0140
3279
-
3280
- CB_SETLOCALE = 0x0159
3281
- CB_GETLOCALE = 0x015a
3282
-
3283
- if WINVER >= WINXP
3284
- CB_GETCOMBOBOXINFO = 0x0164
3285
- end
3286
-
3287
- CB_SETHORIZONTALEXTENT = 0x015e
3288
- CB_GETHORIZONTALEXTENT = 0x015d
3289
-
3290
- CB_SETTOPINDEX = 0x015c
3291
- CB_GETTOPINDEX = 0x015b
3292
-
3293
- CB_SETITEMHEIGHT = 0x0153
3294
- CB_GETITEMHEIGHT = 0x0154
3295
-
3296
- CB_SETDROPPEDWIDTH = 0x0160
3297
- CB_GETDROPPEDWIDTH = 0x015f
3298
-
3299
- CB_GETDROPPEDSTATE = 0x0157
3300
- CB_GETDROPPEDCONTROLRECT = 0x0152
3301
-
3302
- CB_SHOWDROPDOWN = 0x014f
3303
-
3304
- CB_SETEXTENDEDUI = 0x0155
3305
- CB_GETEXTENDEDUI = 0x0156
3306
- #}
3307
-
3308
- #{ CBN_xxx
3309
- CBN_ERRSPACE = -1
3310
-
3311
- CBN_SETFOCUS = 3
3312
- CBN_KILLFOCUS = 4
3313
-
3314
- CBN_EDITUPDATE = 6
3315
- CBN_EDITCHANGE = 5
3316
-
3317
- CBN_SELCHANGE = 1
3318
- CBN_SELENDOK = 9
3319
- CBN_SELENDCANCEL = 10
3320
-
3321
- CBN_DBLCLK = 2
3322
-
3323
- CBN_DROPDOWN = 7
3324
- CBN_CLOSEUP = 8
3325
- #}
3326
-
3327
- #{ SBS_xxx
3328
- SBS_HORZ = 0x0000
3329
- SBS_VERT = 0x0001
3330
-
3331
- SBS_TOPALIGN = 0x0002
3332
- SBS_BOTTOMALIGN = 0x0004
3333
- SBS_LEFTALIGN = 0x0002
3334
- SBS_RIGHTALIGN = 0x0004
3335
-
3336
- SBS_SIZEBOX = 0x0008
3337
- SBS_SIZEGRIP = 0x0010
3338
-
3339
- SBS_SIZEBOXTOPLEFTALIGN = 0x0002
3340
- SBS_SIZEBOXBOTTOMRIGHTALIGN = 0x0004
3341
- #}
3342
-
3343
- #{ OBJID_xxx
3344
- OBJID_HSCROLL = 0xffff_fffa - 0x1_0000_0000
3345
- OBJID_VSCROLL = 0xffff_fffb - 0x1_0000_0000
3346
- OBJID_CLIENT = 0xffff_fffc - 0x1_0000_0000
3347
- #}
3348
-
3349
- class SCROLLBARINFO < FFI::Struct
3350
- extend Util::ScopedStruct
3351
-
3352
- layout \
3353
- :cbSize, :ulong,
3354
- :rcScrollBar, RECT,
3355
- :dxyLineButton, :int,
3356
- :xyThumbTop, :int,
3357
- :xyThumbBottom, :int,
3358
- :reserved, :int,
3359
-
3360
- # 0 - scroll bar itself
3361
- # 1 - top/right arrow button
3362
- # 2 - page up/page right region
3363
- # 3 - scroll box
3364
- # 4 - page down/page left region
3365
- # 5 - bottom/left arrow button
3366
- :rgstate, [:ulong, 6]
3367
- end
3368
-
3369
- attach_function :GetScrollBarInfo, [
3370
- :pointer,
3371
- :long,
3372
- SCROLLBARINFO.by_ref
3373
- ], :int
3374
-
3375
- #{ SBM_xxx
3376
- SBM_ENABLE_ARROWS = 0x00e4
3377
-
3378
- SBM_SETRANGE = 0x00e2
3379
- SBM_SETRANGEREDRAW = 0x00e6
3380
- SBM_GETRANGE = 0x00e3
3381
-
3382
- SBM_SETPOS = 0x00e0
3383
- SBM_GETPOS = 0x00e1
3384
-
3385
- SBM_SETSCROLLINFO = 0x00e9
3386
- SBM_GETSCROLLINFO = 0x00ea
3387
-
3388
- if WINVER >= WINXP
3389
- SBM_GETSCROLLBARINFO = 0x00eb
3390
- end
3391
- #}
3392
- #}
3393
- end
3394
-
3395
- #tend = Time.now
3396
- #p "ffi: #{tffi - tstart}, rest: #{tend - tffi}, total: #{tend - tstart}"
1
+ require_relative 'ffi-wingui-core/libc'
2
+ require_relative 'ffi-wingui-core/kernel32'
3
+ require_relative 'ffi-wingui-core/gdi32'
4
+ require_relative 'ffi-wingui-core/user32'