windows_gui 3.0.2 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95dd7c7c9ab71ebfc897b76fb2baa67be52d3f84
4
- data.tar.gz: efff862e7a92f2d33ff138fdda7bd9ce760516f2
3
+ metadata.gz: d19698398bf2d86bdc449cf6e5874003e960081a
4
+ data.tar.gz: b45e14d18728307fff6a1019ef7099b2c08a0eb8
5
5
  SHA512:
6
- metadata.gz: 1c4e85ee289451dd7e4aece5b74fe8aae151d7308064b932daa9b91d97790b9ae6b87a8277f387d04bc11602db72455fe69e4d820259e9749bd4348cd0c818ff
7
- data.tar.gz: 13884d853f9d90a5a465f59d9e07e794286aba16989e680746dc86a96ecae0bcdfdfd55f2624917d71b91dc089f4668a55c68942a8452c64c7b91d77541dc529
6
+ metadata.gz: 0f0f8387b811b38de7ca7981985bd6e8aa66d717c2e1fc7d4dd3b955c7b20b77a90b83fb996c2d0ebab96a160f795ef16728e89aad912a9a35b7a2422053fd26
7
+ data.tar.gz: 9c99e81ab2b5b1fc96db84e85fa6e7ac821eb99d9dcc0870356ecb48a40f45f7053d2174a9de54c401df48f3276ba923112de90aa77e8269b65340894b2c3bca
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2017 Radoslav Peev
3
+ Copyright (c) 2017 Radoslav Peev <rpeev@ymail.com>
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
data/RELNOTES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release Notes
2
2
 
3
+ ## 4.0.0
4
+
5
+ Improve code (move additional functionality from FFI bindings to external functions)
6
+
3
7
  ## 3.0.2
4
8
 
5
9
  Add recent Windows version info
data/examples/Command.rbw CHANGED
@@ -37,7 +37,7 @@ def OnCreate(hwnd,
37
37
  xtra[:haccel] = CreateAcceleratorTable(paccels, accels.count)
38
38
  }
39
39
 
40
- NONCLIENTMETRICS.new { |ncm|
40
+ UsingFFIStructs(NONCLIENTMETRICS.new) { |ncm|
41
41
  ncm[:cbSize] = ncm.size
42
42
 
43
43
  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.size, ncm, 0);
@@ -204,7 +204,7 @@ end
204
204
  def WinMain
205
205
  Id2RefTrack(xtra = WndExtra.new)
206
206
 
207
- WNDCLASSEX.new { |wc|
207
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
208
208
  wc[:cbSize] = wc.size
209
209
  wc[:lpfnWndProc] = WindowProc
210
210
  wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
@@ -213,7 +213,7 @@ def WinMain
213
213
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
214
214
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
215
215
 
216
- PWSTR(APPNAME) { |className|
216
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
217
217
  wc[:lpszClassName] = className
218
218
 
219
219
  DetonateLastError(0, :RegisterClassEx,
@@ -236,7 +236,7 @@ def WinMain
236
236
  ShowWindow(hwnd, SW_SHOWNORMAL)
237
237
  UpdateWindow(hwnd)
238
238
 
239
- MSG.new { |msg|
239
+ UsingFFIStructs(MSG.new) { |msg|
240
240
  until DetonateLastError(-1, :GetMessage,
241
241
  msg, nil, 0, 0
242
242
  ) == 0
@@ -0,0 +1,11 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'windows_gui'
4
+
5
+ include WindowsGUI
6
+
7
+ MessageBox(nil,
8
+ L('Здрасти, свят!'),
9
+ L('Здрасти'),
10
+ MB_ICONINFORMATION
11
+ )
data/examples/Layered.rbw CHANGED
@@ -44,7 +44,7 @@ end
44
44
  }
45
45
 
46
46
  def WinMain
47
- WNDCLASSEX.new { |wc|
47
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
48
48
  wc[:cbSize] = wc.size
49
49
  wc[:lpfnWndProc] = WindowProc
50
50
  wc[:hInstance] = GetModuleHandle(nil)
@@ -52,7 +52,7 @@ def WinMain
52
52
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
53
53
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
54
54
 
55
- PWSTR(APPNAME) { |className|
55
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
56
56
  wc[:lpszClassName] = className
57
57
 
58
58
  DetonateLastError(0, :RegisterClassEx,
@@ -75,7 +75,7 @@ def WinMain
75
75
  ShowWindow(hwnd, SW_SHOWNORMAL)
76
76
  UpdateWindow(hwnd)
77
77
 
78
- MSG.new { |msg|
78
+ UsingFFIStructs(MSG.new) { |msg|
79
79
  until DetonateLastError(-1, :GetMessage,
80
80
  msg, nil, 0, 0
81
81
  ) == 0
@@ -71,7 +71,7 @@ end
71
71
  }
72
72
 
73
73
  def WinMain
74
- WNDCLASSEX.new { |wc|
74
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
75
75
  wc[:cbSize] = wc.size
76
76
  wc[:lpfnWndProc] = WindowProc
77
77
  wc[:hInstance] = GetModuleHandle(nil)
@@ -79,7 +79,7 @@ def WinMain
79
79
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
80
80
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
81
81
 
82
- PWSTR(APPNAME) { |className|
82
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
83
83
  wc[:lpszClassName] = className
84
84
 
85
85
  DetonateLastError(0, :RegisterClassEx,
@@ -102,7 +102,7 @@ def WinMain
102
102
  ShowWindow(hwnd, SW_SHOWNORMAL)
103
103
  UpdateWindow(hwnd)
104
104
 
105
- MSG.new { |msg|
105
+ UsingFFIStructs(MSG.new) { |msg|
106
106
  until DetonateLastError(-1, :GetMessage,
107
107
  msg, nil, 0, 0
108
108
  ) == 0
@@ -101,7 +101,7 @@ end
101
101
  }
102
102
 
103
103
  def WinMain
104
- WNDCLASSEX.new { |wc|
104
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
105
105
  wc[:cbSize] = wc.size
106
106
  wc[:lpfnWndProc] = WindowProc
107
107
  wc[:hInstance] = GetModuleHandle(nil)
@@ -109,7 +109,7 @@ def WinMain
109
109
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
110
110
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
111
111
 
112
- PWSTR(APPNAME) { |className|
112
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
113
113
  wc[:lpszClassName] = className
114
114
 
115
115
  DetonateLastError(0, :RegisterClassEx,
@@ -132,7 +132,7 @@ def WinMain
132
132
  ShowWindow(hwnd, SW_SHOWNORMAL)
133
133
  UpdateWindow(hwnd)
134
134
 
135
- MSG.new { |msg|
135
+ UsingFFIStructs(MSG.new) { |msg|
136
136
  until DetonateLastError(-1, :GetMessage,
137
137
  msg, nil, 0, 0
138
138
  ) == 0
data/examples/Menu.rbw CHANGED
@@ -221,7 +221,7 @@ end
221
221
  def WinMain
222
222
  Id2RefTrack(xtra = WndExtra.new)
223
223
 
224
- WNDCLASSEX.new { |wc|
224
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
225
225
  wc[:cbSize] = wc.size
226
226
  wc[:lpfnWndProc] = WindowProc
227
227
  wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
@@ -230,7 +230,7 @@ def WinMain
230
230
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
231
231
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
232
232
 
233
- PWSTR(APPNAME) { |className|
233
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
234
234
  wc[:lpszClassName] = className
235
235
 
236
236
  DetonateLastError(0, :RegisterClassEx,
@@ -253,7 +253,7 @@ def WinMain
253
253
  ShowWindow(hwnd, SW_SHOWNORMAL)
254
254
  UpdateWindow(hwnd)
255
255
 
256
- MSG.new { |msg|
256
+ UsingFFIStructs(MSG.new) { |msg|
257
257
  until DetonateLastError(-1, :GetMessage,
258
258
  msg, nil, 0, 0
259
259
  ) == 0
@@ -105,7 +105,7 @@ end
105
105
  def WinMain
106
106
  Id2RefTrack(xtra = WndExtra.new)
107
107
 
108
- WNDCLASSEX.new { |wc|
108
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
109
109
  wc[:cbSize] = wc.size
110
110
  wc[:lpfnWndProc] = WindowProc
111
111
  wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
@@ -114,7 +114,7 @@ def WinMain
114
114
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
115
115
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
116
116
 
117
- PWSTR(APPNAME) { |className|
117
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
118
118
  wc[:lpszClassName] = className
119
119
 
120
120
  DetonateLastError(0, :RegisterClassEx,
@@ -137,7 +137,7 @@ def WinMain
137
137
  ShowWindow(hwnd, SW_SHOWNORMAL)
138
138
  UpdateWindow(hwnd)
139
139
 
140
- MSG.new { |msg|
140
+ UsingFFIStructs(MSG.new) { |msg|
141
141
  until DetonateLastError(-1, :GetMessage,
142
142
  msg, nil, 0, 0
143
143
  ) == 0
@@ -22,58 +22,56 @@ def OnCreate(hwnd,
22
22
  LR_LOADFROMFILE | LR_CREATEDIBSECTION
23
23
  )
24
24
 
25
- info = MENUITEMINFO.new
25
+ UsingFFIStructs(MENUITEMINFO.new) { |mii|
26
+ mii[:cbSize] = mii.size
27
+ mii[:fMask] = MIIM_BITMAP
28
+ mii[:hbmpItem] = xtra[:hbmp]
26
29
 
27
- info[:cbSize] = info.size
28
- info[:fMask] = MIIM_BITMAP
29
- info[:hbmpItem] = xtra[:hbmp]
30
+ hbar = CreateMenu()
31
+ hmenu1 = CreatePopupMenu()
32
+ AppendMenu(hmenu1, MF_STRING, CMD[:ITEM1], L('Item&1'))
33
+ SetMenuDefaultItem(hmenu1, CMD[:ITEM1], 0)
34
+ SetMenuItemInfo(hmenu1, CMD[:ITEM1], 0, mii)
30
35
 
31
- hbar = CreateMenu()
32
- hmenu1 = CreatePopupMenu()
33
- AppendMenu(hmenu1, MF_STRING, CMD[:ITEM1], L('Item&1'))
34
- SetMenuDefaultItem(hmenu1, CMD[:ITEM1], 0)
35
- SetMenuItemInfo(hmenu1, CMD[:ITEM1], 0, info)
36
+ AppendMenu(hmenu1, MF_STRING | MF_GRAYED, CMD[:ITEM2], L('Item&2'))
37
+ SetMenuItemInfo(hmenu1, CMD[:ITEM2], 0, mii)
36
38
 
37
- AppendMenu(hmenu1, MF_STRING | MF_GRAYED, CMD[:ITEM2], L('Item&2'))
38
- SetMenuItemInfo(hmenu1, CMD[:ITEM2], 0, info)
39
+ AppendMenu(hmenu1, MF_STRING | MF_CHECKED, CMD[:ITEM3], L('Item&3'))
40
+ SetMenuItemInfo(hmenu1, CMD[:ITEM3], 0, mii)
39
41
 
40
- AppendMenu(hmenu1, MF_STRING | MF_CHECKED, CMD[:ITEM3], L('Item&3'))
41
- SetMenuItemInfo(hmenu1, CMD[:ITEM3], 0, info)
42
+ AppendMenu(hmenu1, MF_SEPARATOR, 0, nil)
42
43
 
43
- AppendMenu(hmenu1, MF_SEPARATOR, 0, nil)
44
+ AppendMenu(hmenu1, MF_STRING | MF_CHECKED | MFT_RADIOCHECK,
45
+ CMD[:ITEM4], L('Item&4'))
46
+ SetMenuItemInfo(hmenu1, CMD[:ITEM4], 0, mii)
44
47
 
45
- AppendMenu(hmenu1, MF_STRING | MF_CHECKED | MFT_RADIOCHECK,
46
- CMD[:ITEM4], L('Item&4'))
47
- SetMenuItemInfo(hmenu1, CMD[:ITEM4], 0, info)
48
+ AppendMenu(hmenu1, MF_STRING, CMD[:ITEM5], L('Item&5'))
49
+ SetMenuItemInfo(hmenu1, CMD[:ITEM5], 0, mii)
48
50
 
49
- AppendMenu(hmenu1, MF_STRING, CMD[:ITEM5], L('Item&5'))
50
- SetMenuItemInfo(hmenu1, CMD[:ITEM5], 0, info)
51
+ AppendMenu(hmenu1, MF_SEPARATOR, 0, nil)
51
52
 
52
- AppendMenu(hmenu1, MF_SEPARATOR, 0, nil)
53
+ hmenu2 = CreatePopupMenu()
54
+ AppendMenu(hmenu2, MF_STRING | MF_CHECKED | MFT_RADIOCHECK,
55
+ CMD[:ITEM6], L('Item&6'))
56
+ SetMenuItemInfo(hmenu2, CMD[:ITEM6], 0, mii)
53
57
 
54
- hmenu2 = CreatePopupMenu()
55
- AppendMenu(hmenu2, MF_STRING | MF_CHECKED | MFT_RADIOCHECK,
56
- CMD[:ITEM6], L('Item&6'))
57
- SetMenuItemInfo(hmenu2, CMD[:ITEM6], 0, info)
58
+ AppendMenu(hmenu2, MF_STRING, CMD[:ITEM7], L('Item&7'))
59
+ SetMenuItemInfo(hmenu2, CMD[:ITEM7], 0, mii)
60
+ AppendMenu(hmenu1, MF_POPUP, hmenu2.to_i, L('Menu&2'))
61
+ SetMenuItemInfo(hmenu1, 7, MF_BYPOSITION, mii)
62
+ AppendMenu(hbar, MF_POPUP, hmenu1.to_i, L('Menu&1'))
63
+ SetMenuItemInfo(hbar, 0, MF_BYPOSITION, mii)
58
64
 
59
- AppendMenu(hmenu2, MF_STRING, CMD[:ITEM7], L('Item&7'))
60
- SetMenuItemInfo(hmenu2, CMD[:ITEM7], 0, info)
61
- AppendMenu(hmenu1, MF_POPUP, hmenu2.to_i, L('Menu&2'))
62
- SetMenuItemInfo(hmenu1, 7, MF_BYPOSITION, info)
63
- AppendMenu(hbar, MF_POPUP, hmenu1.to_i, L('Menu&1'))
64
- SetMenuItemInfo(hbar, 0, MF_BYPOSITION, info)
65
+ AppendMenu(hbar, MF_STRING, CMD[:ITEM8], L('Item&8!'))
66
+ SetMenuItemInfo(hbar, CMD[:ITEM8], 0, mii)
65
67
 
66
- AppendMenu(hbar, MF_STRING, CMD[:ITEM8], L('Item&8!'))
67
- SetMenuItemInfo(hbar, CMD[:ITEM8], 0, info)
68
-
69
- hmenu3 = CreatePopupMenu()
70
- AppendMenu(hmenu3, MF_BITMAP, CMD[:ITEM9], xtra[:hbmp])
71
- AppendMenu(hbar, MF_POPUP | MF_BITMAP | MF_RIGHTJUSTIFY, hmenu3.to_i, xtra[:hbmp])
72
- SetMenu(hwnd, hbar)
68
+ hmenu3 = CreatePopupMenu()
69
+ AppendMenu(hmenu3, MF_BITMAP, CMD[:ITEM9], xtra[:hbmp])
70
+ AppendMenu(hbar, MF_POPUP | MF_BITMAP | MF_RIGHTJUSTIFY, hmenu3.to_i, xtra[:hbmp])
71
+ SetMenu(hwnd, hbar)
72
+ }
73
73
 
74
74
  0
75
- ensure
76
- info.pointer.free if info
77
75
  end
78
76
 
79
77
  def OnDestroy(hwnd)
@@ -255,7 +253,7 @@ end
255
253
  def WinMain
256
254
  Id2RefTrack(xtra = WndExtra.new)
257
255
 
258
- WNDCLASSEX.new { |wc|
256
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
259
257
  wc[:cbSize] = wc.size
260
258
  wc[:lpfnWndProc] = WindowProc
261
259
  wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
@@ -264,7 +262,7 @@ def WinMain
264
262
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
265
263
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
266
264
 
267
- PWSTR(APPNAME) { |className|
265
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
268
266
  wc[:lpszClassName] = className
269
267
 
270
268
  DetonateLastError(0, :RegisterClassEx,
@@ -287,7 +285,7 @@ def WinMain
287
285
  ShowWindow(hwnd, SW_SHOWNORMAL)
288
286
  UpdateWindow(hwnd)
289
287
 
290
- MSG.new { |msg|
288
+ UsingFFIStructs(MSG.new) { |msg|
291
289
  until DetonateLastError(-1, :GetMessage,
292
290
  msg, nil, 0, 0
293
291
  ) == 0
data/examples/MinMax.rbw CHANGED
@@ -46,7 +46,7 @@ end
46
46
  }
47
47
 
48
48
  def WinMain
49
- WNDCLASSEX.new { |wc|
49
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
50
50
  wc[:cbSize] = wc.size
51
51
  wc[:lpfnWndProc] = WindowProc
52
52
  wc[:hInstance] = GetModuleHandle(nil)
@@ -54,7 +54,7 @@ def WinMain
54
54
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
55
55
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
56
56
 
57
- PWSTR(APPNAME) { |className|
57
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
58
58
  wc[:lpszClassName] = className
59
59
 
60
60
  DetonateLastError(0, :RegisterClassEx,
@@ -77,7 +77,7 @@ def WinMain
77
77
  ShowWindow(hwnd, SW_SHOWNORMAL)
78
78
  UpdateWindow(hwnd)
79
79
 
80
- MSG.new { |msg|
80
+ UsingFFIStructs(MSG.new) { |msg|
81
81
  until DetonateLastError(-1, :GetMessage,
82
82
  msg, nil, 0, 0
83
83
  ) == 0
data/examples/Minimal.rbw CHANGED
@@ -34,7 +34,7 @@ end
34
34
  }
35
35
 
36
36
  def WinMain
37
- WNDCLASSEX.new { |wc|
37
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
38
38
  wc[:cbSize] = wc.size
39
39
  wc[:lpfnWndProc] = WindowProc
40
40
  wc[:hInstance] = GetModuleHandle(nil)
@@ -42,7 +42,7 @@ def WinMain
42
42
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
43
43
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
44
44
 
45
- PWSTR(APPNAME) { |className|
45
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
46
46
  wc[:lpszClassName] = className
47
47
 
48
48
  DetonateLastError(0, :RegisterClassEx,
@@ -65,7 +65,7 @@ def WinMain
65
65
  ShowWindow(hwnd, SW_SHOWNORMAL)
66
66
  UpdateWindow(hwnd)
67
67
 
68
- MSG.new { |msg|
68
+ UsingFFIStructs(MSG.new) { |msg|
69
69
  until DetonateLastError(-1, :GetMessage,
70
70
  msg, nil, 0, 0
71
71
  ) == 0
data/examples/Paint.rbw CHANGED
@@ -11,7 +11,7 @@ def OnCreate(hwnd,
11
11
  )
12
12
  xtra = Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
13
13
 
14
- LOGFONT.new { |lf|
14
+ UsingFFIStructs(LOGFONT.new) { |lf|
15
15
  lf[:lfHeight] = DPIAwareFontHeight(16)
16
16
  lf[:lfItalic] = 1
17
17
  lf[:lfFaceName].to_ptr.put_bytes(0, L('Verdana'))
@@ -38,8 +38,8 @@ def OnPaint(hwnd,
38
38
  SetBkColor(ps[:hdc], RGB(255, 0, 0))
39
39
  SetTextColor(ps[:hdc], RGB(255, 255, 255))
40
40
 
41
- UseObjects(ps[:hdc], xtra[:hfont]) {
42
- RECT.new { |rect|
41
+ UsingGDIObjects(ps[:hdc], xtra[:hfont]) {
42
+ UsingFFIStructs(RECT.new) { |rect|
43
43
  GetClientRect(hwnd, rect)
44
44
 
45
45
  DrawText(ps[:hdc],
@@ -98,7 +98,7 @@ end
98
98
  def WinMain
99
99
  Id2RefTrack(xtra = WndExtra.new)
100
100
 
101
- WNDCLASSEX.new { |wc|
101
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
102
102
  wc[:cbSize] = wc.size
103
103
  wc[:style] = CS_HREDRAW | CS_VREDRAW
104
104
  wc[:lpfnWndProc] = WindowProc
@@ -108,7 +108,7 @@ def WinMain
108
108
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
109
109
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
110
110
 
111
- PWSTR(APPNAME) { |className|
111
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
112
112
  wc[:lpszClassName] = className
113
113
 
114
114
  DetonateLastError(0, :RegisterClassEx,
@@ -130,7 +130,7 @@ def WinMain
130
130
 
131
131
  AnimateWindow(hwnd, 1000, AW_ACTIVATE | AW_BLEND)
132
132
 
133
- MSG.new { |msg|
133
+ UsingFFIStructs(MSG.new) { |msg|
134
134
  until DetonateLastError(-1, :GetMessage,
135
135
  msg, nil, 0, 0
136
136
  ) == 0
data/examples/Region.rbw CHANGED
@@ -47,7 +47,7 @@ end
47
47
  }
48
48
 
49
49
  def WinMain
50
- WNDCLASSEX.new { |wc|
50
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
51
51
  wc[:cbSize] = wc.size
52
52
  wc[:lpfnWndProc] = WindowProc
53
53
  wc[:hInstance] = GetModuleHandle(nil)
@@ -55,7 +55,7 @@ def WinMain
55
55
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
56
56
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_APPWORKSPACE + 1)
57
57
 
58
- PWSTR(APPNAME) { |className|
58
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
59
59
  wc[:lpszClassName] = className
60
60
 
61
61
  DetonateLastError(0, :RegisterClassEx,
@@ -78,7 +78,7 @@ def WinMain
78
78
  ShowWindow(hwnd, SW_SHOWNORMAL)
79
79
  UpdateWindow(hwnd)
80
80
 
81
- MSG.new { |msg|
81
+ UsingFFIStructs(MSG.new) { |msg|
82
82
  until DetonateLastError(-1, :GetMessage,
83
83
  msg, nil, 0, 0
84
84
  ) == 0
@@ -69,7 +69,7 @@ end
69
69
  def WinMain
70
70
  Id2RefTrack(xtra = WndExtra.new)
71
71
 
72
- WNDCLASSEX.new { |wc|
72
+ UsingFFIStructs(WNDCLASSEX.new) { |wc|
73
73
  wc[:cbSize] = wc.size
74
74
  wc[:lpfnWndProc] = WindowProc
75
75
  wc[:cbWndExtra] = FFI::Type::Builtin::POINTER.size
@@ -78,7 +78,7 @@ def WinMain
78
78
  wc[:hCursor] = LoadCursor(nil, IDC_ARROW)
79
79
  wc[:hbrBackground] = FFI::Pointer.new(COLOR_WINDOW + 1)
80
80
 
81
- PWSTR(APPNAME) { |className|
81
+ UsingFFIMemoryPointers(PWSTR(APPNAME)) { |className|
82
82
  wc[:lpszClassName] = className
83
83
 
84
84
  DetonateLastError(0, :RegisterClassEx,
@@ -101,7 +101,7 @@ def WinMain
101
101
  ShowWindow(hwnd, SW_SHOWNORMAL)
102
102
  UpdateWindow(hwnd)
103
103
 
104
- MSG.new { |msg|
104
+ UsingFFIStructs(MSG.new) { |msg|
105
105
  until DetonateLastError(-1, :GetMessage,
106
106
  msg, nil, 0, 0
107
107
  ) == 0
data/lib/windows_gui.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require_relative 'windows_gui/common'
1
2
  require_relative 'windows_gui/libc'
2
3
  require_relative 'windows_gui/kernel'
3
4
  require_relative 'windows_gui/gdi'
@@ -1,7 +1,7 @@
1
1
  require 'weakref'
2
2
  require 'ffi'
3
3
 
4
- WINDOWS_GUI_VERSION = '3.0.2'
4
+ WINDOWS_GUI_VERSION = '4.0.0'
5
5
 
6
6
  WINDOWS_GUI_VISUAL_STYLES = true unless defined?(WINDOWS_GUI_VISUAL_STYLES)
7
7
  WINDOWS_GUI_DPI_AWARE = true unless defined?(WINDOWS_GUI_DPI_AWARE)
@@ -17,45 +17,73 @@ module WindowsGUI
17
17
  str
18
18
  end
19
19
 
20
- module_function :FormatException
21
-
22
20
  Id2Ref = {}
23
21
 
24
- def Id2RefTrack(object)
25
- Id2Ref[object.object_id] = WeakRef.new(object)
22
+ def Id2RefTrack(obj)
23
+ Id2Ref[oid = obj.object_id] = WeakRef.new(obj)
26
24
 
27
- p "Object id #{object.object_id} of #{object} stored in Id2Ref track hash" if $DEBUG
25
+ STDERR.puts "Object id #{oid} of #{obj} stored in Id2Ref track hash" if $DEBUG
28
26
 
29
- ObjectSpace.define_finalizer(object, -> id {
27
+ ObjectSpace.define_finalizer(obj, -> id {
30
28
  Id2Ref.delete(id)
31
29
 
32
- p "Object id #{id} deleted from Id2Ref track hash" if $DEBUG
30
+ STDERR.puts "Object id #{id} deleted from Id2Ref track hash" if $DEBUG
33
31
  })
32
+
33
+ oid
34
+ end
35
+
36
+ def UsingFFIStructs(*structs)
37
+ yield(*structs)
38
+ ensure
39
+ structs.each { |struct|
40
+ struct.pointer.free
41
+
42
+ STDERR.puts "#{struct} freed" if $DEBUG
43
+ }
34
44
  end
35
45
 
36
- module_function :Id2RefTrack
46
+ def UsingFFIMemoryPointers(*ptrs)
47
+ yield(*ptrs)
48
+ ensure
49
+ ptrs.each { |ptr|
50
+ ptr.free
37
51
 
38
- module AutoFFIStructClassSupport
39
- def new(*args)
40
- raise ArgumentError, 'Cannot accept both arguments and a block' if
41
- args.length > 0 && block_given?
52
+ STDERR.puts "#{ptr} freed" if $DEBUG
53
+ }
54
+ end
42
55
 
43
- struct = super
56
+ def Detonate(on, name, *args)
57
+ result = send(name, *args)
58
+ failed = [*on].include?(result)
44
59
 
45
- return struct unless block_given?
60
+ raise "#{name} failed (result: #{result})" if failed
46
61
 
47
- begin
48
- yield struct
49
- ensure
50
- struct.pointer.free
62
+ result
63
+ ensure
64
+ yield result if failed && block_given?
65
+ end
51
66
 
52
- p "Native memory for #{struct} freed" if $DEBUG
53
- end
67
+ def DetonateLastError(on, name, *args)
68
+ result = send(name, *args)
69
+ failed = [*on].include?(result)
70
+ last_error = 0
54
71
 
55
- nil
56
- end
72
+ raise "#{name} failed (last error: #{last_error = GetLastError()})" if failed
73
+
74
+ result
75
+ ensure
76
+ yield result, last_error if failed && block_given?
57
77
  end
58
78
 
79
+ module_function \
80
+ :FormatException,
81
+ :Id2RefTrack,
82
+ :UsingFFIStructs,
83
+ :UsingFFIMemoryPointers,
84
+ :Detonate,
85
+ :DetonateLastError
86
+
59
87
  INVALID_HANDLE_VALUE = FFI::Pointer.new(-1)
60
88
 
61
89
  def MAKEWORD(lobyte, hibyte)
@@ -70,8 +98,6 @@ module WindowsGUI
70
98
  (word >> 8) & 0xff
71
99
  end
72
100
 
73
- module_function :MAKEWORD, :LOBYTE, :HIBYTE
74
-
75
101
  def MAKELONG(loword, hiword)
76
102
  (loword & 0xffff) | ((hiword & 0xffff) << 16)
77
103
  end
@@ -92,7 +118,15 @@ module WindowsGUI
92
118
  ((hishort = HIWORD(long)) > 0x7fff) ? hishort - 0x1_0000 : hishort
93
119
  end
94
120
 
95
- module_function :MAKELONG, :LOWORD, :HIWORD, :LOSHORT, :HISHORT
121
+ module_function \
122
+ :MAKEWORD,
123
+ :LOBYTE,
124
+ :HIBYTE,
125
+ :MAKELONG,
126
+ :LOWORD,
127
+ :HIWORD,
128
+ :LOSHORT,
129
+ :HISHORT
96
130
 
97
131
  def L(str)
98
132
  (str << "\0").encode!('utf-16le')
@@ -102,45 +136,29 @@ module WindowsGUI
102
136
  raise 'Invalid Unicode string' unless
103
137
  wstr.encoding == Encoding::UTF_16LE && wstr[-1] == L('')
104
138
 
105
- ptr = FFI::MemoryPointer.new(:ushort, wstr.length).
139
+ FFI::MemoryPointer.new(:ushort, wstr.length).
106
140
  put_bytes(0, wstr)
107
-
108
- return ptr unless block_given?
109
-
110
- begin
111
- yield ptr
112
- ensure
113
- ptr.free
114
-
115
- p "Native copy of '#{wstr[0...-1].encode($0.encoding)}' freed" if $DEBUG
116
- end
117
-
118
- nil
119
141
  end
120
142
 
121
- module_function :L, :PWSTR
143
+ module_function \
144
+ :L,
145
+ :PWSTR
122
146
 
123
147
  APPNAME = L(File.basename($0, '.rbw'))
124
148
 
125
149
  class POINT < FFI::Struct
126
- extend AutoFFIStructClassSupport
127
-
128
150
  layout \
129
151
  :x, :long,
130
152
  :y, :long
131
153
  end
132
154
 
133
155
  class SIZE < FFI::Struct
134
- extend AutoFFIStructClassSupport
135
-
136
156
  layout \
137
157
  :cx, :long,
138
158
  :cy, :long
139
159
  end
140
160
 
141
161
  class RECT < FFI::Struct
142
- extend AutoFFIStructClassSupport
143
-
144
162
  layout \
145
163
  :left, :long,
146
164
  :top, :long,
@@ -1,5 +1,6 @@
1
- require_relative 'common'
2
1
  if __FILE__ == $0
2
+ require_relative 'common'
3
+ require_relative 'libc'
3
4
  require_relative 'kernel'
4
5
  end
5
6
 
@@ -25,7 +26,11 @@ module WindowsGUI
25
26
  LOBYTE(rgb >> 16)
26
27
  end
27
28
 
28
- module_function :RGB, :GetRValue, :GetGValue, :GetBValue
29
+ module_function \
30
+ :RGB,
31
+ :GetRValue,
32
+ :GetGValue,
33
+ :GetBValue
29
34
 
30
35
  attach_function :CreateCompatibleDC, [
31
36
  :pointer
@@ -53,7 +58,8 @@ module WindowsGUI
53
58
  -MulDiv(pointSize, DPIY, 72)
54
59
  end
55
60
 
56
- module_function :DPIAwareFontHeight
61
+ module_function \
62
+ :DPIAwareFontHeight
57
63
 
58
64
  FW_DONTCARE = 0
59
65
  FW_THIN = 100
@@ -102,8 +108,6 @@ module WindowsGUI
102
108
  FF_DECORATIVE = 5 << 4
103
109
 
104
110
  class LOGFONT < FFI::Struct
105
- extend AutoFFIStructClassSupport
106
-
107
111
  layout \
108
112
  :lfHeight, :long,
109
113
  :lfWidth, :long,
@@ -143,8 +147,6 @@ module WindowsGUI
143
147
  HS_DIAGCROSS = 5
144
148
 
145
149
  class LOGBRUSH < FFI::Struct
146
- extend AutoFFIStructClassSupport
147
-
148
150
  layout \
149
151
  :lbStyle, :uint,
150
152
  :lbColor, :ulong,
@@ -177,8 +179,6 @@ module WindowsGUI
177
179
  PS_JOIN_ROUND = 0x0000_0000
178
180
 
179
181
  class LOGPEN < FFI::Struct
180
- extend AutoFFIStructClassSupport
181
-
182
182
  layout \
183
183
  :lopnStyle, :uint,
184
184
  :lopnWidth, POINT,
@@ -367,7 +367,7 @@ module WindowsGUI
367
367
  :pointer
368
368
  ], :pointer
369
369
 
370
- def UseObjects(hdc, *hgdiobjs)
370
+ def UsingGDIObjects(hdc, *hgdiobjs)
371
371
  holds = []
372
372
 
373
373
  hgdiobjs.each { |hgdiobj|
@@ -376,14 +376,15 @@ module WindowsGUI
376
376
  )
377
377
  }
378
378
 
379
- yield
379
+ yield(*hgdiobjs)
380
380
  ensure
381
381
  holds.each { |hgdiobj|
382
382
  SelectObject(hdc, hgdiobj)
383
383
  }
384
384
  end
385
385
 
386
- module_function :UseObjects
386
+ module_function \
387
+ :UsingGDIObjects
387
388
 
388
389
  AD_COUNTERCLOCKWISE = 1
389
390
  AD_CLOCKWISE = 2
@@ -1,4 +1,7 @@
1
- require_relative 'common'
1
+ if __FILE__ == $0
2
+ require_relative 'common'
3
+ require_relative 'libc'
4
+ end
2
5
 
3
6
  module WindowsGUI
4
7
  ffi_lib 'kernel32'
@@ -12,29 +15,7 @@ module WindowsGUI
12
15
 
13
16
  ], :ulong
14
17
 
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
18
  class OSVERSIONINFOEX < FFI::Struct
36
- extend AutoFFIStructClassSupport
37
-
38
19
  layout \
39
20
  :dwOSVersionInfoSize, :ulong,
40
21
  :dwMajorVersion, :ulong,
@@ -53,15 +34,14 @@ module WindowsGUI
53
34
  OSVERSIONINFOEX.by_ref
54
35
  ], :int
55
36
 
56
- OSVERSION = OSVERSIONINFOEX.new.tap { |ovi|
57
- at_exit { OSVERSION.pointer.free }
37
+ OSVERSION = OSVERSIONINFOEX.new
58
38
 
59
- ovi[:dwOSVersionInfoSize] = ovi.size
39
+ at_exit { OSVERSION.pointer.free }
60
40
 
61
- DetonateLastError(0, :GetVersionEx,
62
- ovi
63
- )
64
- }
41
+ OSVERSION[:dwOSVersionInfoSize] = OSVERSION.size
42
+ DetonateLastError(0, :GetVersionEx,
43
+ OSVERSION
44
+ )
65
45
 
66
46
  NTDDI_WIN2K = 0x0500_0000
67
47
 
@@ -144,7 +124,8 @@ module WindowsGUI
144
124
  ) == IDNO
145
125
  end
146
126
 
147
- module_function :TARGETVER
127
+ module_function \
128
+ :TARGETVER
148
129
 
149
130
  attach_function :GetModuleHandle, :GetModuleHandleW, [
150
131
  :buffer_in
@@ -160,8 +141,6 @@ module WindowsGUI
160
141
 
161
142
  if WINVER >= WINXP
162
143
  class ACTCTX < FFI::Struct
163
- extend AutoFFIStructClassSupport
164
-
165
144
  layout \
166
145
  :cbSize, :ulong,
167
146
  :dwFlags, :ulong,
@@ -205,13 +184,14 @@ module WindowsGUI
205
184
  ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle]) unless
206
185
  COMMON_CONTROLS_ACTCTX[:handle] == INVALID_HANDLE_VALUE
207
186
 
208
- COMMON_CONTROLS_ACTCTX[:cookie].free
187
+ COMMON_CONTROLS_ACTCTX[:cookie].free unless
188
+ COMMON_CONTROLS_ACTCTX[:cookie] == FFI::Pointer::NULL
209
189
 
210
190
  COMMON_CONTROLS_ACTCTX[:handle] = INVALID_HANDLE_VALUE
211
- COMMON_CONTROLS_ACTCTX[:cookie] = 0
191
+ COMMON_CONTROLS_ACTCTX[:cookie] = FFI::Pointer::NULL
212
192
  COMMON_CONTROLS_ACTCTX[:activated] = false
213
193
 
214
- p "Visual styles cleanup, COMMON_CONTROLS_ACTCTX is #{COMMON_CONTROLS_ACTCTX}" if $DEBUG
194
+ STDERR.puts "Visual styles cleanup (COMMON_CONTROLS_ACTCTX: #{COMMON_CONTROLS_ACTCTX})" if $DEBUG
215
195
  }
216
196
  end
217
197
 
@@ -243,10 +223,10 @@ module WindowsGUI
243
223
  XML
244
224
  }
245
225
 
246
- ACTCTX.new { |ac|
226
+ UsingFFIStructs(ACTCTX.new) { |ac|
247
227
  ac[:cbSize] = ac.size
248
228
 
249
- PWSTR(L(manifest)) { |source|
229
+ UsingFFIMemoryPointers(PWSTR(L(manifest))) { |source|
250
230
  ac[:lpSource] = source
251
231
 
252
232
  COMMON_CONTROLS_ACTCTX[:handle] =
@@ -258,19 +238,18 @@ module WindowsGUI
258
238
 
259
239
  DetonateLastError(0, :ActivateActCtx,
260
240
  COMMON_CONTROLS_ACTCTX[:handle], COMMON_CONTROLS_ACTCTX[:cookie]
261
- ) { |failed|
262
- next unless failed
263
-
241
+ ) {
264
242
  ReleaseActCtx(COMMON_CONTROLS_ACTCTX[:handle])
265
243
  COMMON_CONTROLS_ACTCTX[:handle] = INVALID_HANDLE_VALUE
266
244
  }
267
245
 
268
246
  COMMON_CONTROLS_ACTCTX[:activated] = true
269
247
 
270
- p "Visual styles init, COMMON_CONTROLS_ACTCTX is #{COMMON_CONTROLS_ACTCTX}" if $DEBUG
248
+ STDERR.puts "Visual styles init (COMMON_CONTROLS_ACTCTX: #{COMMON_CONTROLS_ACTCTX})" if $DEBUG
271
249
  end
272
250
 
273
- module_function :EnableVisualStyles
251
+ module_function \
252
+ :EnableVisualStyles
274
253
 
275
254
  EnableVisualStyles() if WINDOWS_GUI_VISUAL_STYLES
276
255
 
@@ -1,4 +1,6 @@
1
- require_relative 'common'
1
+ if __FILE__ == $0
2
+ require_relative 'common'
3
+ end
2
4
 
3
5
  module WindowsGUI
4
6
  ffi_lib FFI::Library::LIBC
@@ -6,5 +8,5 @@ module WindowsGUI
6
8
 
7
9
  attach_function :windows_gui_wcslen, :wcslen, [
8
10
  :buffer_in
9
- ], :uint
11
+ ], :size_t
10
12
  end
@@ -1,5 +1,6 @@
1
- require_relative 'common'
2
1
  if __FILE__ == $0
2
+ require_relative 'common'
3
+ require_relative 'libc'
3
4
  require_relative 'kernel'
4
5
  require_relative 'gdi'
5
6
  end
@@ -72,7 +73,8 @@ module WindowsGUI
72
73
  rect[:top] > rect[:bottom]
73
74
  end
74
75
 
75
- module_function :NormalizeRect
76
+ module_function \
77
+ :NormalizeRect
76
78
 
77
79
  attach_function :DrawFocusRect, [
78
80
  :pointer,
@@ -131,10 +133,21 @@ module WindowsGUI
131
133
  attach_function :SetProcessDPIAware, [
132
134
 
133
135
  ], :int
136
+ end
137
+
138
+ def DeclareDPIAware
139
+ return unless WINVER >= WINVISTA
134
140
 
135
- Detonate(0, :SetProcessDPIAware) if WINDOWS_GUI_DPI_AWARE
141
+ Detonate(0, :SetProcessDPIAware)
142
+
143
+ STDERR.puts "DPI aware init"
136
144
  end
137
145
 
146
+ module_function \
147
+ :DeclareDPIAware
148
+
149
+ DeclareDPIAware() if WINDOWS_GUI_DPI_AWARE
150
+
138
151
  attach_function :GetWindowDC, [
139
152
  :pointer
140
153
  ], :pointer
@@ -148,7 +161,7 @@ module WindowsGUI
148
161
  :pointer
149
162
  ], :int
150
163
 
151
- def UseWindowDC(hwnd)
164
+ def UsingWindowDC(hwnd)
152
165
  hdc = DetonateLastError(FFI::Pointer::NULL, :GetWindowDC,
153
166
  hwnd
154
167
  )
@@ -160,7 +173,7 @@ module WindowsGUI
160
173
  end
161
174
  end
162
175
 
163
- def UseDC(hwnd)
176
+ def UsingDC(hwnd)
164
177
  hdc = DetonateLastError(FFI::Pointer::NULL, :GetDC,
165
178
  hwnd
166
179
  )
@@ -172,9 +185,11 @@ module WindowsGUI
172
185
  end
173
186
  end
174
187
 
175
- module_function :UseWindowDC, :UseDC
188
+ module_function \
189
+ :UsingWindowDC,
190
+ :UsingDC
176
191
 
177
- UseDC(nil) { |hdc|
192
+ UsingDC(nil) { |hdc|
178
193
  DPIX = GetDeviceCaps(hdc, LOGPIXELSX)
179
194
  DPIY = GetDeviceCaps(hdc, LOGPIXELSY)
180
195
  }
@@ -196,7 +211,10 @@ module WindowsGUI
196
211
  }
197
212
  end
198
213
 
199
- module_function :DPIAwareX, :DPIAwareY, :DPIAwareXY
214
+ module_function \
215
+ :DPIAwareX,
216
+ :DPIAwareY,
217
+ :DPIAwareXY
200
218
 
201
219
  SM_CXSCREEN = 0
202
220
  SM_CYSCREEN = 1
@@ -206,8 +224,6 @@ module WindowsGUI
206
224
  ], :int
207
225
 
208
226
  class NONCLIENTMETRICS < FFI::Struct
209
- extend AutoFFIStructClassSupport
210
-
211
227
  layout(*[
212
228
  :cbSize, :uint,
213
229
  :iBorderWidth, :int,
@@ -461,8 +477,6 @@ module WindowsGUI
461
477
  COLOR_MENU = 4
462
478
 
463
479
  class WNDCLASSEX < FFI::Struct
464
- extend AutoFFIStructClassSupport
465
-
466
480
  layout \
467
481
  :cbSize, :uint,
468
482
  :style, :uint,
@@ -625,8 +639,6 @@ module WindowsGUI
625
639
  ], :pointer
626
640
 
627
641
  class DLGTEMPLATE < FFI::Struct
628
- extend AutoFFIStructClassSupport
629
-
630
642
  layout \
631
643
  :style, :ulong,
632
644
  :dwExtendedStyle, :ulong,
@@ -921,8 +933,6 @@ module WindowsGUI
921
933
  SIF_DISABLENOSCROLL = 0x0008
922
934
 
923
935
  class SCROLLINFO < FFI::Struct
924
- extend AutoFFIStructClassSupport
925
-
926
936
  layout \
927
937
  :cbSize, :uint,
928
938
  :fMask, :uint,
@@ -1029,8 +1039,6 @@ module WindowsGUI
1029
1039
  ], :int
1030
1040
 
1031
1041
  class PAINTSTRUCT < FFI::Struct
1032
- extend AutoFFIStructClassSupport
1033
-
1034
1042
  layout \
1035
1043
  :hdc, :pointer,
1036
1044
  :fErase, :int,
@@ -1053,7 +1061,7 @@ module WindowsGUI
1053
1061
  def DoPaint(hwnd)
1054
1062
  return unless GetUpdateRect(hwnd, nil, 0) != 0
1055
1063
 
1056
- PAINTSTRUCT.new { |ps|
1064
+ UsingFFIStructs(PAINTSTRUCT.new) { |ps|
1057
1065
  DetonateLastError(FFI::Pointer::NULL, :BeginPaint,
1058
1066
  hwnd, ps
1059
1067
  )
@@ -1067,7 +1075,7 @@ module WindowsGUI
1067
1075
  end
1068
1076
 
1069
1077
  def DoPrintClient(hwnd, wParam)
1070
- PAINTSTRUCT.new { |ps|
1078
+ UsingFFIStructs(PAINTSTRUCT.new) { |ps|
1071
1079
  ps[:hdc] = FFI::Pointer.new(wParam)
1072
1080
  ps[:fErase] = 1
1073
1081
  GetClientRect(hwnd, ps[:rcPaint])
@@ -1076,7 +1084,9 @@ module WindowsGUI
1076
1084
  }
1077
1085
  end
1078
1086
 
1079
- module_function :DoPaint, :DoPrintClient
1087
+ module_function \
1088
+ :DoPaint,
1089
+ :DoPrintClient
1080
1090
 
1081
1091
  attach_function :SetCapture, [
1082
1092
  :pointer
@@ -1136,8 +1146,6 @@ module WindowsGUI
1136
1146
  MOUSEEVENTF_VIRTUALDESK = 0x4000
1137
1147
 
1138
1148
  class MOUSEINPUT < FFI::Struct
1139
- extend AutoFFIStructClassSupport
1140
-
1141
1149
  layout \
1142
1150
  :dx, :long,
1143
1151
  :dy, :long,
@@ -1153,8 +1161,6 @@ module WindowsGUI
1153
1161
  KEYEVENTF_UNICODE = 0x0004
1154
1162
 
1155
1163
  class KEYBDINPUT < FFI::Struct
1156
- extend AutoFFIStructClassSupport
1157
-
1158
1164
  layout \
1159
1165
  :wVk, :ushort,
1160
1166
  :wScan, :ushort,
@@ -1164,8 +1170,6 @@ module WindowsGUI
1164
1170
  end
1165
1171
 
1166
1172
  class HARDWAREINPUT < FFI::Struct
1167
- extend AutoFFIStructClassSupport
1168
-
1169
1173
  layout \
1170
1174
  :uMsg, :ulong,
1171
1175
  :wParamL, :ushort,
@@ -1173,8 +1177,6 @@ module WindowsGUI
1173
1177
  end
1174
1178
 
1175
1179
  class INPUT < FFI::Struct
1176
- extend AutoFFIStructClassSupport
1177
-
1178
1180
  layout \
1179
1181
  :type, :ulong,
1180
1182
 
@@ -1234,8 +1236,6 @@ module WindowsGUI
1234
1236
  HWND_BROADCAST = FFI::Pointer.new(0xffff)
1235
1237
 
1236
1238
  class CREATESTRUCT < FFI::Struct
1237
- extend AutoFFIStructClassSupport
1238
-
1239
1239
  layout \
1240
1240
  :lpCreateParams, :pointer,
1241
1241
  :hInstance, :pointer,
@@ -1270,8 +1270,6 @@ module WindowsGUI
1270
1270
  WM_ENDSESSION = 0x0016
1271
1271
 
1272
1272
  class STYLESTRUCT < FFI::Struct
1273
- extend AutoFFIStructClassSupport
1274
-
1275
1273
  layout \
1276
1274
  :styleOld, :ulong,
1277
1275
  :styleNew, :ulong
@@ -1299,8 +1297,6 @@ module WindowsGUI
1299
1297
  WM_SHOWWINDOW = 0x0018
1300
1298
 
1301
1299
  class MINMAXINFO < FFI::Struct
1302
- extend AutoFFIStructClassSupport
1303
-
1304
1300
  layout \
1305
1301
  :ptReserved, POINT,
1306
1302
  :ptMaxSize, POINT,
@@ -1312,8 +1308,6 @@ module WindowsGUI
1312
1308
  WM_GETMINMAXINFO = 0x0024
1313
1309
 
1314
1310
  class WINDOWPOS < FFI::Struct
1315
- extend AutoFFIStructClassSupport
1316
-
1317
1311
  layout \
1318
1312
  :hwnd, :pointer,
1319
1313
  :hwndInsertAfter, :pointer,
@@ -1518,8 +1512,6 @@ module WindowsGUI
1518
1512
  WM_COMMAND = 0x0111
1519
1513
 
1520
1514
  class NMHDR < FFI::Struct
1521
- extend AutoFFIStructClassSupport
1522
-
1523
1515
  layout \
1524
1516
  :hwndFrom, :pointer,
1525
1517
  :idFrom, :uint,
@@ -1540,8 +1532,6 @@ module WindowsGUI
1540
1532
  WM_CHARTOITEM = 0x002f
1541
1533
 
1542
1534
  class DELETEITEMSTRUCT < FFI::Struct
1543
- extend AutoFFIStructClassSupport
1544
-
1545
1535
  layout \
1546
1536
  :CtlType, :uint,
1547
1537
  :CtlID, :uint,
@@ -1553,8 +1543,6 @@ module WindowsGUI
1553
1543
  WM_DELETEITEM = 0x002d
1554
1544
 
1555
1545
  class COMPAREITEMSTRUCT < FFI::Struct
1556
- extend AutoFFIStructClassSupport
1557
-
1558
1546
  layout \
1559
1547
  :CtlType, :uint,
1560
1548
  :CtlID, :uint,
@@ -1577,8 +1565,6 @@ module WindowsGUI
1577
1565
  ODT_COMBOBOX = 3
1578
1566
 
1579
1567
  class MEASUREITEMSTRUCT < FFI::Struct
1580
- extend AutoFFIStructClassSupport
1581
-
1582
1568
  layout \
1583
1569
  :CtlType, :uint,
1584
1570
  :CtlID, :uint,
@@ -1610,8 +1596,6 @@ module WindowsGUI
1610
1596
  ODS_COMBOBOXEDIT = 0x1000
1611
1597
 
1612
1598
  class DRAWITEMSTRUCT < FFI::Struct
1613
- extend AutoFFIStructClassSupport
1614
-
1615
1599
  layout \
1616
1600
  :CtlType, :uint,
1617
1601
  :CtlID, :uint,
@@ -1672,8 +1656,6 @@ module WindowsGUI
1672
1656
  ], :void
1673
1657
 
1674
1658
  class MSG < FFI::Struct
1675
- extend AutoFFIStructClassSupport
1676
-
1677
1659
  layout \
1678
1660
  :hwnd, :pointer,
1679
1661
  :message, :uint,
@@ -1862,8 +1844,6 @@ module WindowsGUI
1862
1844
  MIIM_BITMAP = 0x0000_0080
1863
1845
 
1864
1846
  class MENUITEMINFO < FFI::Struct
1865
- extend AutoFFIStructClassSupport
1866
-
1867
1847
  layout \
1868
1848
  :cbSize, :uint,
1869
1849
  :fMask, :uint,
@@ -2022,8 +2002,6 @@ module WindowsGUI
2022
2002
  VK_VOLUME_DOWN = 0xae
2023
2003
 
2024
2004
  class ACCEL < FFI::Struct
2025
- extend AutoFFIStructClassSupport
2026
-
2027
2005
  layout \
2028
2006
  :fVirt, :uchar,
2029
2007
  :key, :ushort,
@@ -2401,8 +2379,6 @@ module WindowsGUI
2401
2379
  CBS_NOINTEGRALHEIGHT = 0x0400
2402
2380
 
2403
2381
  class COMBOBOXINFO < FFI::Struct
2404
- extend AutoFFIStructClassSupport
2405
-
2406
2382
  layout \
2407
2383
  :cbSize, :ulong,
2408
2384
  :rcItem, RECT,
@@ -2530,8 +2506,6 @@ module WindowsGUI
2530
2506
  OBJID_CLIENT = 0xffff_fffc - 0x1_0000_0000
2531
2507
 
2532
2508
  class SCROLLBARINFO < FFI::Struct
2533
- extend AutoFFIStructClassSupport
2534
-
2535
2509
  layout \
2536
2510
  :cbSize, :ulong,
2537
2511
  :rcScrollBar, RECT,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows_gui
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Peev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-22 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -36,6 +36,7 @@ files:
36
36
  - RELNOTES.md
37
37
  - examples/Command.rbw
38
38
  - examples/Hello.rbw
39
+ - examples/HelloBulgarian.rbw
39
40
  - examples/HelloOptout.rbw
40
41
  - examples/HelloTimeout.rbw
41
42
  - examples/Layered.rbw