ffi-wingui-core 0.4.0 → 0.5.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.
- data/examples/Command.rbw +42 -23
- data/examples/Hello.rbw +1 -2
- data/examples/HelloOptout.rbw +1 -2
- data/examples/HelloTimeout.rbw +11 -12
- data/examples/Layered.rbw +99 -0
- data/examples/LifeCycle.rbw +3 -4
- data/examples/LifeCycleNC.rbw +3 -4
- data/examples/Menu.rbw +47 -58
- data/examples/MenuContext.rbw +11 -14
- data/examples/MenuPARGB32.rbw +58 -73
- data/examples/MinMax.rbw +101 -0
- data/examples/Minimal.rbw +3 -4
- data/examples/Region.rbw +100 -0
- data/examples/Scribble.rbw +15 -18
- data/examples/WndExtra.rbw +7 -8
- data/lib/ffi-wingui-core.rb +496 -50
- data/lib/ffi-wingui-core/ocra.rb +1 -0
- metadata +17 -13
data/examples/Scribble.rbw
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
require 'ffi-wingui-core'
|
2
|
-
|
3
|
-
exit if defined?(Ocra)
|
2
|
+
require 'ffi-wingui-core/ocra'
|
4
3
|
|
5
4
|
include WinGUI
|
6
5
|
|
7
|
-
APPNAME = L(File.basename(__FILE__, '.rbw'))
|
8
|
-
|
9
6
|
WndExtra = Struct.new(
|
10
7
|
:scribbles,
|
11
8
|
:hpen
|
12
|
-
)
|
9
|
+
)
|
13
10
|
|
14
11
|
def onCreate(hwnd,
|
15
12
|
cs
|
16
13
|
)
|
17
|
-
xtra =
|
14
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
18
15
|
|
19
16
|
xtra[:scribbles] = []
|
20
17
|
|
@@ -29,7 +26,7 @@ def onCreate(hwnd,
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def onDestroy(hwnd)
|
32
|
-
xtra =
|
29
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
33
30
|
|
34
31
|
DeleteObject(xtra[:hpen])
|
35
32
|
|
@@ -39,7 +36,7 @@ end
|
|
39
36
|
def onPaint(hwnd,
|
40
37
|
ps
|
41
38
|
)
|
42
|
-
xtra =
|
39
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
43
40
|
|
44
41
|
hdefpen = SelectObject(ps[:hdc], xtra[:hpen])
|
45
42
|
|
@@ -59,7 +56,7 @@ end
|
|
59
56
|
def onLButtonDown(hwnd,
|
60
57
|
x, y
|
61
58
|
)
|
62
|
-
xtra =
|
59
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
63
60
|
|
64
61
|
SetCapture(hwnd)
|
65
62
|
|
@@ -80,8 +77,6 @@ end
|
|
80
77
|
def onLButtonUp(hwnd,
|
81
78
|
x, y
|
82
79
|
)
|
83
|
-
xtra = WndExtra::REFS[GetWindowLong(hwnd, GWL_USERDATA)]
|
84
|
-
|
85
80
|
ReleaseCapture()
|
86
81
|
|
87
82
|
0
|
@@ -92,7 +87,7 @@ def onMouseMove(hwnd,
|
|
92
87
|
)
|
93
88
|
return 0 if GetCapture() != hwnd
|
94
89
|
|
95
|
-
xtra =
|
90
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
96
91
|
|
97
92
|
xtra[:scribbles].last << [x, y]
|
98
93
|
|
@@ -106,7 +101,7 @@ def onRButtonDown(hwnd,
|
|
106
101
|
)
|
107
102
|
return 0 if GetCapture() == hwnd
|
108
103
|
|
109
|
-
xtra =
|
104
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
110
105
|
|
111
106
|
xtra[:scribbles].clear
|
112
107
|
|
@@ -151,17 +146,19 @@ begin
|
|
151
146
|
end
|
152
147
|
|
153
148
|
when WM_LBUTTONDOWN
|
154
|
-
onLButtonDown(hwnd,
|
149
|
+
onLButtonDown(hwnd, LOSHORT(lParam), HISHORT(lParam))
|
155
150
|
when WM_LBUTTONUP
|
156
|
-
onLButtonUp(hwnd,
|
151
|
+
onLButtonUp(hwnd, LOSHORT(lParam), HISHORT(lParam))
|
157
152
|
when WM_MOUSEMOVE
|
158
|
-
onMouseMove(hwnd,
|
153
|
+
onMouseMove(hwnd, LOSHORT(lParam), HISHORT(lParam))
|
159
154
|
|
160
155
|
when WM_RBUTTONDOWN
|
161
|
-
onRButtonDown(hwnd,
|
156
|
+
onRButtonDown(hwnd, LOSHORT(lParam), HISHORT(lParam))
|
162
157
|
end
|
163
158
|
|
164
159
|
result || DefWindowProc(hwnd, uMsg, wParam, lParam)
|
160
|
+
rescue SystemExit => ex
|
161
|
+
PostQuitMessage(ex.status)
|
165
162
|
rescue
|
166
163
|
case MessageBox(hwnd,
|
167
164
|
L(Util.FormatException($!)),
|
@@ -177,7 +174,7 @@ end
|
|
177
174
|
}
|
178
175
|
|
179
176
|
def main
|
180
|
-
xtra = WndExtra.new
|
177
|
+
Util.Id2RefTrack(xtra = WndExtra.new)
|
181
178
|
|
182
179
|
WNDCLASSEX.new { |wc|
|
183
180
|
wc[:cbSize] = wc.size
|
data/examples/WndExtra.rbw
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'ffi-wingui-core'
|
2
|
-
|
3
|
-
exit if defined?(Ocra)
|
2
|
+
require 'ffi-wingui-core/ocra'
|
4
3
|
|
5
4
|
include WinGUI
|
6
5
|
|
7
|
-
APPNAME = L(File.basename(__FILE__, '.rbw'))
|
8
|
-
|
9
6
|
WndExtra = Struct.new(
|
10
7
|
:foo
|
11
|
-
)
|
8
|
+
)
|
12
9
|
|
13
10
|
def onCreate(hwnd,
|
14
11
|
cs
|
15
12
|
)
|
16
|
-
xtra =
|
13
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
17
14
|
|
18
15
|
xtra[:foo] = L('Foo')
|
19
16
|
|
@@ -21,7 +18,7 @@ def onCreate(hwnd,
|
|
21
18
|
end
|
22
19
|
|
23
20
|
def onDestroy(hwnd)
|
24
|
-
xtra =
|
21
|
+
xtra = Util::Id2Ref[GetWindowLong(hwnd, GWL_USERDATA)]
|
25
22
|
|
26
23
|
MessageBox(nil,
|
27
24
|
xtra[:foo],
|
@@ -54,6 +51,8 @@ begin
|
|
54
51
|
end
|
55
52
|
|
56
53
|
result || DefWindowProc(hwnd, uMsg, wParam, lParam)
|
54
|
+
rescue SystemExit => ex
|
55
|
+
PostQuitMessage(ex.status)
|
57
56
|
rescue
|
58
57
|
case MessageBox(hwnd,
|
59
58
|
L(Util.FormatException($!)),
|
@@ -69,7 +68,7 @@ end
|
|
69
68
|
}
|
70
69
|
|
71
70
|
def main
|
72
|
-
xtra = WndExtra.new
|
71
|
+
Util.Id2RefTrack(xtra = WndExtra.new)
|
73
72
|
|
74
73
|
WNDCLASSEX.new { |wc|
|
75
74
|
wc[:cbSize] = wc.size
|
data/lib/ffi-wingui-core.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
|
+
WINGUI_VISUAL_STYLES = true unless defined?(WINGUI_VISUAL_STYLES)
|
4
|
+
WINGUI_DPI_AWARE = true unless defined?(WINGUI_DPI_AWARE)
|
5
|
+
|
3
6
|
module WinGUI
|
4
7
|
extend FFI::Library
|
5
8
|
|
@@ -15,20 +18,18 @@ module WinGUI
|
|
15
18
|
|
16
19
|
module_function :FormatException
|
17
20
|
|
18
|
-
|
19
|
-
REFS = {}
|
20
|
-
|
21
|
-
def initialize(*args)
|
22
|
-
super
|
21
|
+
Id2Ref = {}
|
23
22
|
|
24
|
-
|
23
|
+
def Id2RefTrack(object)
|
24
|
+
Id2Ref[object.object_id] = object
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
ObjectSpace.define_finalizer(object, -> id {
|
27
|
+
Id2Ref.delete(id)
|
28
|
+
})
|
30
29
|
end
|
31
30
|
|
31
|
+
module_function :Id2RefTrack
|
32
|
+
|
32
33
|
unless FFI::Struct.respond_to?(:by_ref)
|
33
34
|
class << FFI::Struct
|
34
35
|
def by_ref(*args)
|
@@ -89,7 +90,15 @@ module WinGUI
|
|
89
90
|
(long >> 16) & 0xffff
|
90
91
|
end
|
91
92
|
|
92
|
-
|
93
|
+
def LOSHORT(long)
|
94
|
+
((loshort = LOWORD(long)) > 0x7fff) ? loshort - 0x1_0000 : loshort
|
95
|
+
end
|
96
|
+
|
97
|
+
def HISHORT(long)
|
98
|
+
((hishort = HIWORD(long)) > 0x7fff) ? hishort - 0x1_0000 : hishort
|
99
|
+
end
|
100
|
+
|
101
|
+
module_function :MAKELONG, :LOWORD, :HIWORD, :LOSHORT, :HISHORT
|
93
102
|
|
94
103
|
def L(str)
|
95
104
|
(str << "\0").encode!('utf-16le')
|
@@ -117,6 +126,8 @@ module WinGUI
|
|
117
126
|
|
118
127
|
module_function :L, :PWSTR
|
119
128
|
|
129
|
+
APPNAME = L(File.basename($0, '.rbw'))
|
130
|
+
|
120
131
|
class POINT < FFI::Struct
|
121
132
|
extend Util::ScopedStruct
|
122
133
|
|
@@ -259,6 +270,19 @@ module WinGUI
|
|
259
270
|
|
260
271
|
WINVER = HIWORD(NTDDI_VERSION)
|
261
272
|
|
273
|
+
def TARGETVER(version, message)
|
274
|
+
version = MAKELONG(0x0000, version) if version < 0xffff
|
275
|
+
|
276
|
+
exit(-1) if NTDDI_VERSION < version &&
|
277
|
+
MessageBox(nil,
|
278
|
+
message,
|
279
|
+
APPNAME,
|
280
|
+
MB_YESNO | MB_ICONERROR | MB_DEFBUTTON2
|
281
|
+
) == IDNO
|
282
|
+
end
|
283
|
+
|
284
|
+
module_function :TARGETVER
|
285
|
+
|
262
286
|
attach_function :GetModuleHandle, :GetModuleHandleW, [
|
263
287
|
:buffer_in
|
264
288
|
], :pointer
|
@@ -377,8 +401,7 @@ module WinGUI
|
|
377
401
|
|
378
402
|
module_function :EnableVisualStyles
|
379
403
|
|
380
|
-
EnableVisualStyles()
|
381
|
-
Object.const_defined?(:WINGUI_VISUAL_STYLES) && !WINGUI_VISUAL_STYLES
|
404
|
+
EnableVisualStyles() if WINGUI_VISUAL_STYLES
|
382
405
|
|
383
406
|
attach_function :MulDiv, [
|
384
407
|
:int,
|
@@ -475,6 +498,69 @@ module WinGUI
|
|
475
498
|
LOGPEN.by_ref(:in)
|
476
499
|
], :pointer
|
477
500
|
|
501
|
+
attach_function :CreateRectRgn, [
|
502
|
+
:int,
|
503
|
+
:int,
|
504
|
+
:int,
|
505
|
+
:int
|
506
|
+
], :pointer
|
507
|
+
|
508
|
+
attach_function :CreateRoundRectRgn, [
|
509
|
+
:int,
|
510
|
+
:int,
|
511
|
+
:int,
|
512
|
+
:int,
|
513
|
+
:int,
|
514
|
+
:int
|
515
|
+
], :pointer
|
516
|
+
|
517
|
+
attach_function :CreateEllipticRgn, [
|
518
|
+
:int,
|
519
|
+
:int,
|
520
|
+
:int,
|
521
|
+
:int
|
522
|
+
], :pointer
|
523
|
+
|
524
|
+
#{ POLYFILL_xxx
|
525
|
+
ALTERNATE = 1
|
526
|
+
WINDING = 2
|
527
|
+
#}
|
528
|
+
|
529
|
+
attach_function :CreatePolygonRgn, [
|
530
|
+
:pointer,
|
531
|
+
:int,
|
532
|
+
:int
|
533
|
+
], :pointer
|
534
|
+
|
535
|
+
attach_function :CreatePolyPolygonRgn, [
|
536
|
+
:pointer,
|
537
|
+
:pointer,
|
538
|
+
:int,
|
539
|
+
:int
|
540
|
+
], :pointer
|
541
|
+
|
542
|
+
#{ RGN_xxx
|
543
|
+
RGN_COPY = 5
|
544
|
+
RGN_DIFF = 4
|
545
|
+
RGN_AND = 1
|
546
|
+
RGN_OR = 2
|
547
|
+
RGN_XOR = 3
|
548
|
+
#}
|
549
|
+
|
550
|
+
#{ xxxREGION
|
551
|
+
ERROR = 0
|
552
|
+
NULLREGION = 1
|
553
|
+
SIMPLEREGION = 2
|
554
|
+
COMPLEXREGION = 3
|
555
|
+
#}
|
556
|
+
|
557
|
+
attach_function :CombineRgn, [
|
558
|
+
:pointer,
|
559
|
+
:pointer,
|
560
|
+
:pointer,
|
561
|
+
:int
|
562
|
+
], :int
|
563
|
+
|
478
564
|
attach_function :DeleteObject, [
|
479
565
|
:pointer
|
480
566
|
], :int
|
@@ -539,8 +625,7 @@ module WinGUI
|
|
539
625
|
|
540
626
|
], :int
|
541
627
|
|
542
|
-
Detonate(0, :SetProcessDPIAware)
|
543
|
-
Object.const_defined?(:WINGUI_DPI_AWARE) && !WINGUI_DPI_AWARE
|
628
|
+
Detonate(0, :SetProcessDPIAware) if WINGUI_DPI_AWARE
|
544
629
|
end
|
545
630
|
|
546
631
|
attach_function :GetDC, [
|
@@ -618,7 +703,7 @@ module WinGUI
|
|
618
703
|
}
|
619
704
|
end
|
620
705
|
|
621
|
-
SPI_SETNONCLIENTMETRICS =
|
706
|
+
SPI_SETNONCLIENTMETRICS = 0x002a
|
622
707
|
SPI_GETNONCLIENTMETRICS = 0x0029
|
623
708
|
#}
|
624
709
|
|
@@ -761,6 +846,25 @@ module WinGUI
|
|
761
846
|
:buffer_in
|
762
847
|
], :pointer
|
763
848
|
|
849
|
+
begin
|
850
|
+
attach_function :PrivateExtractIcons, :PrivateExtractIconsW, [
|
851
|
+
:buffer_in,
|
852
|
+
:int,
|
853
|
+
:int,
|
854
|
+
:int,
|
855
|
+
:pointer,
|
856
|
+
:pointer,
|
857
|
+
:uint,
|
858
|
+
:uint
|
859
|
+
], :uint
|
860
|
+
rescue FFI::NotFoundError # PrivateExtractIcons is not intended for general use
|
861
|
+
|
862
|
+
end
|
863
|
+
|
864
|
+
attach_function :DestroyIcon, [
|
865
|
+
:pointer
|
866
|
+
], :int
|
867
|
+
|
764
868
|
#{ IDC_xxx
|
765
869
|
IDC_WAIT = FFI::Pointer.new(32514)
|
766
870
|
IDC_APPSTARTING = FFI::Pointer.new(32650)
|
@@ -784,6 +888,18 @@ module WinGUI
|
|
784
888
|
:buffer_in
|
785
889
|
], :pointer
|
786
890
|
|
891
|
+
attach_function :DestroyCursor, [
|
892
|
+
:pointer
|
893
|
+
], :int
|
894
|
+
|
895
|
+
attach_function :SetCursor, [
|
896
|
+
:pointer
|
897
|
+
], :pointer
|
898
|
+
|
899
|
+
attach_function :GetCursor, [
|
900
|
+
|
901
|
+
], :pointer
|
902
|
+
|
787
903
|
attach_function :SetCursorPos, [
|
788
904
|
:int,
|
789
905
|
:int
|
@@ -793,6 +909,10 @@ module WinGUI
|
|
793
909
|
POINT.by_ref(:out)
|
794
910
|
], :int
|
795
911
|
|
912
|
+
attach_function :ShowCursor, [
|
913
|
+
:int
|
914
|
+
], :int
|
915
|
+
|
796
916
|
#{ COLOR_xxx
|
797
917
|
COLOR_DESKTOP = 1
|
798
918
|
COLOR_APPWORKSPACE = 12
|
@@ -974,6 +1094,38 @@ module WinGUI
|
|
974
1094
|
:int
|
975
1095
|
], :long
|
976
1096
|
|
1097
|
+
#{ LWA_xxx
|
1098
|
+
LWA_COLORKEY = 0x00000001
|
1099
|
+
LWA_ALPHA = 0x00000002
|
1100
|
+
#}
|
1101
|
+
|
1102
|
+
attach_function :SetLayeredWindowAttributes, [
|
1103
|
+
:pointer,
|
1104
|
+
:ulong,
|
1105
|
+
:uchar,
|
1106
|
+
:ulong
|
1107
|
+
], :int
|
1108
|
+
|
1109
|
+
if WINVER >= WINXP
|
1110
|
+
attach_function :GetLayeredWindowAttributes, [
|
1111
|
+
:pointer,
|
1112
|
+
:pointer,
|
1113
|
+
:pointer,
|
1114
|
+
:pointer
|
1115
|
+
], :int
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
attach_function :SetWindowRgn, [
|
1119
|
+
:pointer,
|
1120
|
+
:pointer,
|
1121
|
+
:int
|
1122
|
+
], :int
|
1123
|
+
|
1124
|
+
attach_function :GetWindowRgn, [
|
1125
|
+
:pointer,
|
1126
|
+
:pointer
|
1127
|
+
], :int
|
1128
|
+
|
977
1129
|
attach_function :IsWindowEnabled, [
|
978
1130
|
:pointer
|
979
1131
|
], :int
|
@@ -983,16 +1135,55 @@ module WinGUI
|
|
983
1135
|
:int
|
984
1136
|
], :int
|
985
1137
|
|
1138
|
+
attach_function :SetActiveWindow, [
|
1139
|
+
:pointer
|
1140
|
+
], :pointer
|
1141
|
+
|
1142
|
+
attach_function :GetActiveWindow, [
|
1143
|
+
|
1144
|
+
], :pointer
|
1145
|
+
|
1146
|
+
attach_function :SetForegroundWindow, [
|
1147
|
+
:pointer
|
1148
|
+
], :int
|
1149
|
+
|
1150
|
+
attach_function :GetForegroundWindow, [
|
1151
|
+
|
1152
|
+
], :pointer
|
1153
|
+
|
1154
|
+
attach_function :SetFocus, [
|
1155
|
+
:pointer
|
1156
|
+
], :pointer
|
1157
|
+
|
1158
|
+
attach_function :GetFocus, [
|
1159
|
+
|
1160
|
+
], :pointer
|
1161
|
+
|
986
1162
|
attach_function :IsWindowVisible, [
|
987
1163
|
:pointer
|
988
1164
|
], :int
|
989
1165
|
|
1166
|
+
attach_function :IsIconic, [
|
1167
|
+
:pointer
|
1168
|
+
], :int
|
1169
|
+
|
1170
|
+
attach_function :IsZoomed, [
|
1171
|
+
:pointer
|
1172
|
+
], :int
|
1173
|
+
|
990
1174
|
#{ SW_xxx
|
1175
|
+
SW_SHOWDEFAULT = 10
|
991
1176
|
SW_HIDE = 0
|
992
1177
|
SW_SHOW = 5
|
1178
|
+
SW_SHOWNA = 8
|
993
1179
|
SW_SHOWNORMAL = 1
|
1180
|
+
SW_SHOWNOACTIVATE = 4
|
994
1181
|
SW_SHOWMINIMIZED = 2
|
1182
|
+
SW_SHOWMINNOACTIVE = 7
|
1183
|
+
SW_MINIMIZE = 6
|
1184
|
+
SW_FORCEMINIMIZE = 11
|
995
1185
|
SW_SHOWMAXIMIZED = 3
|
1186
|
+
SW_MAXIMIZE = 3
|
996
1187
|
SW_RESTORE = 9
|
997
1188
|
#}
|
998
1189
|
|
@@ -1001,6 +1192,11 @@ module WinGUI
|
|
1001
1192
|
:int
|
1002
1193
|
], :int
|
1003
1194
|
|
1195
|
+
attach_function :ShowWindowAsync, [
|
1196
|
+
:pointer,
|
1197
|
+
:int
|
1198
|
+
], :int
|
1199
|
+
|
1004
1200
|
#{ HWND_xxx
|
1005
1201
|
HWND_TOP = FFI::Pointer.new(0)
|
1006
1202
|
HWND_BOTTOM = FFI::Pointer.new(1)
|
@@ -1010,10 +1206,12 @@ module WinGUI
|
|
1010
1206
|
|
1011
1207
|
#{ SWP_xxx
|
1012
1208
|
SWP_FRAMECHANGED = 0x0020
|
1209
|
+
SWP_NOACTIVATE = 0x0010
|
1013
1210
|
SWP_NOOWNERZORDER = 0x0200
|
1014
1211
|
SWP_NOZORDER = 0x0004
|
1015
1212
|
SWP_NOMOVE = 0x0002
|
1016
1213
|
SWP_NOSIZE = 0x0001
|
1214
|
+
SWP_ASYNCWINDOWPOS = 0x4000
|
1017
1215
|
#}
|
1018
1216
|
|
1019
1217
|
attach_function :SetWindowPos, [
|
@@ -1115,6 +1313,11 @@ module WinGUI
|
|
1115
1313
|
|
1116
1314
|
], :pointer
|
1117
1315
|
|
1316
|
+
attach_function :GetSystemMenu, [
|
1317
|
+
:pointer,
|
1318
|
+
:int
|
1319
|
+
], :pointer
|
1320
|
+
|
1118
1321
|
attach_function :SetMenu, [
|
1119
1322
|
:pointer,
|
1120
1323
|
:pointer
|
@@ -1137,14 +1340,6 @@ module WinGUI
|
|
1137
1340
|
:pointer
|
1138
1341
|
], :int
|
1139
1342
|
|
1140
|
-
attach_function :SetFocus, [
|
1141
|
-
:pointer
|
1142
|
-
], :pointer
|
1143
|
-
|
1144
|
-
attach_function :GetFocus, [
|
1145
|
-
|
1146
|
-
], :pointer
|
1147
|
-
|
1148
1343
|
#{ HWND_xxx
|
1149
1344
|
HWND_BROADCAST = FFI::Pointer.new(0xffff)
|
1150
1345
|
#}
|
@@ -1176,6 +1371,30 @@ module WinGUI
|
|
1176
1371
|
WM_DESTROY = 0x0002
|
1177
1372
|
WM_NCDESTROY = 0x0082
|
1178
1373
|
|
1374
|
+
#{ ENDSESSION_xxx
|
1375
|
+
ENDSESSION_CLOSEAPP = 0x00000001
|
1376
|
+
ENDSESSION_CRITICAL = 0x40000000
|
1377
|
+
ENDSESSION_LOGOFF = 0x80000000
|
1378
|
+
#}
|
1379
|
+
|
1380
|
+
WM_QUERYENDSESSION = 0x0011
|
1381
|
+
WM_ENDSESSION = 0x0016
|
1382
|
+
|
1383
|
+
WM_QUIT = 0x0012
|
1384
|
+
|
1385
|
+
class STYLESTRUCT < FFI::Struct
|
1386
|
+
extend Util::ScopedStruct
|
1387
|
+
|
1388
|
+
layout \
|
1389
|
+
:styleOld, :ulong,
|
1390
|
+
:styleNew, :ulong
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
WM_STYLECHANGING = 0x007c
|
1394
|
+
WM_STYLECHANGED = 0x007d
|
1395
|
+
|
1396
|
+
WM_ENABLE = 0x000a
|
1397
|
+
|
1179
1398
|
#{ WA_xxx
|
1180
1399
|
WA_INACTIVE = 0
|
1181
1400
|
WA_ACTIVE = 1
|
@@ -1184,20 +1403,106 @@ module WinGUI
|
|
1184
1403
|
|
1185
1404
|
WM_ACTIVATE = 0x0006
|
1186
1405
|
|
1187
|
-
|
1188
|
-
|
1406
|
+
WM_SETFOCUS = 0x0007
|
1407
|
+
WM_KILLFOCUS = 0x0008
|
1189
1408
|
|
1190
|
-
|
1409
|
+
#{ SW_xxx
|
1410
|
+
SW_PARENTOPENING = 3
|
1411
|
+
SW_PARENTCLOSING = 1
|
1412
|
+
SW_OTHERZOOM = 2
|
1413
|
+
SW_OTHERUNZOOM = 4
|
1414
|
+
#}
|
1415
|
+
|
1416
|
+
WM_SHOWWINDOW = 0x0018
|
1417
|
+
|
1418
|
+
class MINMAXINFO < FFI::Struct
|
1419
|
+
extend Util::ScopedStruct
|
1191
1420
|
|
1192
|
-
|
1193
|
-
|
1421
|
+
layout \
|
1422
|
+
:ptReserved, POINT,
|
1423
|
+
:ptMaxSize, POINT,
|
1424
|
+
:ptMaxPosition, POINT,
|
1425
|
+
:ptMinTrackSize, POINT,
|
1426
|
+
:ptMaxTrackSize, POINT
|
1194
1427
|
end
|
1195
1428
|
|
1196
|
-
|
1197
|
-
|
1429
|
+
WM_GETMINMAXINFO = 0x0024
|
1430
|
+
|
1431
|
+
class WINDOWPOS < FFI::Struct
|
1432
|
+
extend Util::ScopedStruct
|
1433
|
+
|
1434
|
+
layout \
|
1435
|
+
:hwnd, :pointer,
|
1436
|
+
:hwndInsertAfter, :pointer,
|
1437
|
+
:x, :int,
|
1438
|
+
:y, :int,
|
1439
|
+
:cx, :int,
|
1440
|
+
:cy, :int,
|
1441
|
+
:flags, :int
|
1442
|
+
end
|
1443
|
+
|
1444
|
+
WM_WINDOWPOSCHANGING = 0x0046
|
1445
|
+
WM_WINDOWPOSCHANGED = 0x0047
|
1446
|
+
|
1447
|
+
WM_MOVING = 0x0216
|
1448
|
+
WM_MOVE = 0x0003
|
1449
|
+
|
1450
|
+
#{ WMSZ_xxx
|
1451
|
+
WMSZ_LEFT = 1
|
1452
|
+
WMSZ_TOP = 3
|
1453
|
+
WMSZ_RIGHT = 2
|
1454
|
+
WMSZ_BOTTOM = 6
|
1455
|
+
WMSZ_TOPLEFT = 4
|
1456
|
+
WMSZ_TOPRIGHT = 5
|
1457
|
+
WMSZ_BOTTOMLEFT = 7
|
1458
|
+
WMSZ_BOTTOMRIGHT = 8
|
1459
|
+
#}
|
1460
|
+
|
1461
|
+
WM_SIZING = 0x0214
|
1462
|
+
|
1463
|
+
#{ SIZE_xxx
|
1464
|
+
SIZE_MINIMIZED = 1
|
1465
|
+
SIZE_MAXIMIZED = 2
|
1466
|
+
SIZE_RESTORED = 0
|
1467
|
+
SIZE_MAXHIDE = 4
|
1468
|
+
SIZE_MAXSHOW = 3
|
1469
|
+
#}
|
1470
|
+
|
1471
|
+
WM_SIZE = 0x0005
|
1472
|
+
|
1473
|
+
#{ ICON_xxx
|
1474
|
+
ICON_SMALL = 0
|
1475
|
+
ICON_BIG = 1
|
1476
|
+
if WINVER >= WINXP
|
1477
|
+
ICON_SMALL2 = 2
|
1198
1478
|
end
|
1479
|
+
#}
|
1199
1480
|
|
1200
|
-
|
1481
|
+
WM_SETICON = 0x0080
|
1482
|
+
WM_GETICON = 0x007f
|
1483
|
+
|
1484
|
+
WM_SETTEXT = 0x000c
|
1485
|
+
WM_GETTEXT = 0x000d
|
1486
|
+
WM_GETTEXTLENGTH = 0x000e
|
1487
|
+
|
1488
|
+
WM_SETFONT = 0x0030
|
1489
|
+
WM_GETFONT = 0x0031
|
1490
|
+
|
1491
|
+
WM_ERASEBKGND = 0x0014
|
1492
|
+
|
1493
|
+
WM_PAINT = 0x000f
|
1494
|
+
|
1495
|
+
WM_CAPTURECHANGED = 0x0215
|
1496
|
+
|
1497
|
+
#{ MK_xxx
|
1498
|
+
MK_LBUTTON = 0x0001
|
1499
|
+
MK_RBUTTON = 0x0002
|
1500
|
+
MK_MBUTTON = 0x0010
|
1501
|
+
MK_XBUTTON1 = 0x0020
|
1502
|
+
MK_XBUTTON2 = 0x0040
|
1503
|
+
MK_CONTROL = 0x0008
|
1504
|
+
MK_SHIFT = 0x0004
|
1505
|
+
#}
|
1201
1506
|
|
1202
1507
|
WM_LBUTTONDOWN = 0x0201
|
1203
1508
|
WM_LBUTTONUP = 0x0202
|
@@ -1211,9 +1516,93 @@ module WinGUI
|
|
1211
1516
|
WM_MBUTTONUP = 0x0208
|
1212
1517
|
WM_MBUTTONDBLCLK = 0x0209
|
1213
1518
|
|
1519
|
+
#{ XBUTTONxxx
|
1520
|
+
XBUTTON1 = 0x0001
|
1521
|
+
XBUTTON2 = 0x0002
|
1522
|
+
#}
|
1523
|
+
|
1524
|
+
WM_XBUTTONDOWN = 0x020b
|
1525
|
+
WM_XBUTTONUP = 0x020c
|
1526
|
+
WM_XBUTTONDBLCLK = 0x020d
|
1527
|
+
|
1528
|
+
#{ WHEEL_xxx
|
1529
|
+
WHEEL_DELTA = 120
|
1530
|
+
#}
|
1531
|
+
|
1532
|
+
WM_MOUSEWHEEL = 0x020a
|
1533
|
+
if WINVER >= WINVISTA
|
1534
|
+
WM_MOUSEHWHEEL = 0x020e
|
1535
|
+
end
|
1536
|
+
|
1214
1537
|
WM_MOUSEMOVE = 0x0200
|
1215
1538
|
|
1216
|
-
WM_CONTEXTMENU =
|
1539
|
+
WM_CONTEXTMENU = 0x007b
|
1540
|
+
|
1541
|
+
WM_INITMENU = 0x0116
|
1542
|
+
WM_INITMENUPOPUP = 0x0117
|
1543
|
+
|
1544
|
+
WM_USER = 0x0400
|
1545
|
+
WM_APP = 0x8000
|
1546
|
+
|
1547
|
+
#{ SC_xxx
|
1548
|
+
SC_DEFAULT = 0xf160
|
1549
|
+
|
1550
|
+
SC_MOVE = 0xf010
|
1551
|
+
SC_SIZE = 0xf000
|
1552
|
+
SC_MINIMIZE = 0xf020
|
1553
|
+
SC_MAXIMIZE = 0xf030
|
1554
|
+
SC_RESTORE = 0xf120
|
1555
|
+
SC_CLOSE = 0xf060
|
1556
|
+
|
1557
|
+
SC_HSCROLL = 0xf080
|
1558
|
+
SC_VSCROLL = 0xf070
|
1559
|
+
|
1560
|
+
SC_NEXTWINDOW = 0xf040
|
1561
|
+
SC_PREVWINDOW = 0xf050
|
1562
|
+
SC_ARRANGE = 0xf110
|
1563
|
+
|
1564
|
+
SC_MOUSEMENU = 0xf090
|
1565
|
+
SC_KEYMENU = 0xf100
|
1566
|
+
SC_HOTKEY = 0xf150
|
1567
|
+
|
1568
|
+
SC_TASKLIST = 0xf130
|
1569
|
+
SC_SCREENSAVE = 0xf140
|
1570
|
+
SC_MONITORPOWER = 0xf170
|
1571
|
+
|
1572
|
+
SC_CONTEXTHELP = 0xf180
|
1573
|
+
#}
|
1574
|
+
|
1575
|
+
(SYSID = {}).
|
1576
|
+
instance_variable_set(:@last, 0xf00)
|
1577
|
+
|
1578
|
+
class << SYSID
|
1579
|
+
private :[]=, :store
|
1580
|
+
|
1581
|
+
def [](key)
|
1582
|
+
return key if key.is_a?(Integer)
|
1583
|
+
|
1584
|
+
(id = fetch(key, nil)) ?
|
1585
|
+
id :
|
1586
|
+
self[key] = (@last -= 1) << 4
|
1587
|
+
end
|
1588
|
+
end
|
1589
|
+
|
1590
|
+
WM_SYSCOMMAND = 0x0112
|
1591
|
+
|
1592
|
+
(ID = {}).
|
1593
|
+
instance_variable_set(:@last, WM_APP)
|
1594
|
+
|
1595
|
+
class << ID
|
1596
|
+
private :[]=, :store
|
1597
|
+
|
1598
|
+
def [](key)
|
1599
|
+
return key if key.is_a?(Integer)
|
1600
|
+
|
1601
|
+
(id = fetch(key, nil)) ?
|
1602
|
+
id :
|
1603
|
+
self[key] = @last += 1
|
1604
|
+
end
|
1605
|
+
end
|
1217
1606
|
|
1218
1607
|
WM_COMMAND = 0x0111
|
1219
1608
|
|
@@ -1226,10 +1615,11 @@ module WinGUI
|
|
1226
1615
|
:code, :uint
|
1227
1616
|
end
|
1228
1617
|
|
1229
|
-
WM_NOTIFY =
|
1618
|
+
WM_NOTIFY = 0x004e
|
1230
1619
|
|
1231
|
-
|
1232
|
-
|
1620
|
+
attach_function :RegisterWindowMessage, :RegisterWindowMessageW, [
|
1621
|
+
:buffer_in
|
1622
|
+
], :uint
|
1233
1623
|
#}
|
1234
1624
|
|
1235
1625
|
attach_function :SendMessage, :SendMessageW, [
|
@@ -1246,6 +1636,10 @@ module WinGUI
|
|
1246
1636
|
:long
|
1247
1637
|
], :int
|
1248
1638
|
|
1639
|
+
attach_function :PostQuitMessage, [
|
1640
|
+
:int
|
1641
|
+
], :void
|
1642
|
+
|
1249
1643
|
class MSG < FFI::Struct
|
1250
1644
|
extend Util::ScopedStruct
|
1251
1645
|
|
@@ -1258,6 +1652,20 @@ module WinGUI
|
|
1258
1652
|
:pt, POINT
|
1259
1653
|
end
|
1260
1654
|
|
1655
|
+
#{ PM_xxx
|
1656
|
+
PM_NOREMOVE = 0x0000
|
1657
|
+
PM_REMOVE = 0x0001
|
1658
|
+
PM_NOYIELD = 0x0002
|
1659
|
+
#}
|
1660
|
+
|
1661
|
+
attach_function :PeekMessage, :PeekMessageW, [
|
1662
|
+
MSG.by_ref(:out),
|
1663
|
+
:pointer,
|
1664
|
+
:uint,
|
1665
|
+
:uint,
|
1666
|
+
:uint
|
1667
|
+
], :int
|
1668
|
+
|
1261
1669
|
attach_function :GetMessage, :GetMessageW, [
|
1262
1670
|
MSG.by_ref(:out),
|
1263
1671
|
:pointer,
|
@@ -1284,10 +1692,6 @@ module WinGUI
|
|
1284
1692
|
MSG.by_ref(:in)
|
1285
1693
|
], :long
|
1286
1694
|
|
1287
|
-
attach_function :PostQuitMessage, [
|
1288
|
-
:int
|
1289
|
-
], :void
|
1290
|
-
|
1291
1695
|
attach_function :CreateMenu, [
|
1292
1696
|
|
1293
1697
|
], :pointer
|
@@ -1300,33 +1704,68 @@ module WinGUI
|
|
1300
1704
|
:pointer
|
1301
1705
|
], :int
|
1302
1706
|
|
1303
|
-
#{
|
1707
|
+
#{ MF_xxx
|
1708
|
+
MF_BYCOMMAND = 0x00000000
|
1709
|
+
MF_BYPOSITION = 0x00000400
|
1710
|
+
|
1304
1711
|
MF_POPUP = 0x00000010
|
1305
1712
|
MF_STRING = 0x00000000
|
1306
1713
|
MF_BITMAP = 0x00000004
|
1307
1714
|
MF_OWNERDRAW = 0x00000100
|
1308
1715
|
MF_SEPARATOR = 0x00000800
|
1716
|
+
|
1309
1717
|
MF_MENUBARBREAK = 0x00000020
|
1310
1718
|
MF_MENUBREAK = 0x00000040
|
1311
1719
|
MF_RIGHTJUSTIFY = 0x00004000
|
1312
1720
|
|
1721
|
+
MF_DEFAULT = 0x00001000
|
1313
1722
|
MF_ENABLED = 0x00000000
|
1314
1723
|
MF_DISABLED = 0x00000002
|
1315
1724
|
MF_GRAYED = 0x00000001
|
1316
1725
|
MF_CHECKED = 0x00000008
|
1317
|
-
MFT_RADIOCHECK = 0x00000200
|
1318
1726
|
MF_UNCHECKED = 0x00000000
|
1319
1727
|
MF_HILITE = 0x00000080
|
1320
1728
|
MF_UNHILITE = 0x00000000
|
1321
1729
|
#}
|
1322
1730
|
|
1323
|
-
|
1731
|
+
#{ MFT_xxx
|
1732
|
+
MFT_RADIOCHECK = 0x00000200
|
1733
|
+
#}
|
1734
|
+
|
1735
|
+
#{ MFS_xxx
|
1736
|
+
MFS_GRAYED = 0x00000003
|
1737
|
+
#}
|
1738
|
+
|
1739
|
+
attach_function :InsertMenu, :InsertMenuW, [
|
1324
1740
|
:pointer,
|
1325
1741
|
:uint,
|
1326
1742
|
:uint,
|
1743
|
+
:uint,
|
1327
1744
|
:buffer_in
|
1328
1745
|
], :int
|
1329
1746
|
|
1747
|
+
attach_function :GetMenuItemID, [
|
1748
|
+
:pointer,
|
1749
|
+
:int
|
1750
|
+
], :uint
|
1751
|
+
|
1752
|
+
attach_function :GetSubMenu, [
|
1753
|
+
:pointer,
|
1754
|
+
:int
|
1755
|
+
], :pointer
|
1756
|
+
|
1757
|
+
attach_function :RemoveMenu, [
|
1758
|
+
:pointer,
|
1759
|
+
:uint,
|
1760
|
+
:uint
|
1761
|
+
], :int
|
1762
|
+
|
1763
|
+
attach_function :DeleteMenu, [
|
1764
|
+
:pointer,
|
1765
|
+
:uint,
|
1766
|
+
:uint
|
1767
|
+
], :int
|
1768
|
+
|
1330
1769
|
attach_function :SetMenuDefaultItem, [
|
1331
1770
|
:pointer,
|
1332
1771
|
:uint,
|
@@ -1344,11 +1783,6 @@ module WinGUI
|
|
1344
1783
|
:uint
|
1345
1784
|
], :uint
|
1346
1785
|
|
1347
|
-
#{ MF_xxx
|
1348
|
-
MF_BYCOMMAND = 0x00000000
|
1349
|
-
MF_BYPOSITION = 0x00000400
|
1350
|
-
#}
|
1351
|
-
|
1352
1786
|
attach_function :EnableMenuItem, [
|
1353
1787
|
:pointer,
|
1354
1788
|
:uint,
|
@@ -1382,15 +1816,16 @@ module WinGUI
|
|
1382
1816
|
:uint
|
1383
1817
|
], :uint
|
1384
1818
|
|
1819
|
+
#{ MIIM_xxx
|
1820
|
+
MIIM_FTYPE = 0x00000100
|
1385
1821
|
MIIM_STATE = 0x00000001
|
1386
1822
|
MIIM_ID = 0x00000002
|
1387
1823
|
MIIM_SUBMENU = 0x00000004
|
1388
1824
|
MIIM_CHECKMARKS = 0x00000008
|
1389
|
-
MIIM_TYPE = 0x00000010
|
1390
1825
|
MIIM_DATA = 0x00000020
|
1391
1826
|
MIIM_STRING = 0x00000040
|
1392
1827
|
MIIM_BITMAP = 0x00000080
|
1393
|
-
|
1828
|
+
#}
|
1394
1829
|
|
1395
1830
|
class MENUITEMINFO < FFI::Struct
|
1396
1831
|
extend Util::ScopedStruct
|
@@ -1410,6 +1845,13 @@ module WinGUI
|
|
1410
1845
|
:hbmpItem, :pointer
|
1411
1846
|
end
|
1412
1847
|
|
1848
|
+
attach_function :InsertMenuItem, :InsertMenuItemW, [
|
1849
|
+
:pointer,
|
1850
|
+
:uint,
|
1851
|
+
:int,
|
1852
|
+
MENUITEMINFO.by_ref(:in)
|
1853
|
+
], :int
|
1854
|
+
|
1413
1855
|
attach_function :SetMenuItemInfo, :SetMenuItemInfoW, [
|
1414
1856
|
:pointer,
|
1415
1857
|
:uint,
|
@@ -1455,6 +1897,10 @@ module WinGUI
|
|
1455
1897
|
RECT.by_ref(:in)
|
1456
1898
|
], :int
|
1457
1899
|
|
1900
|
+
attach_function :EndMenu, [
|
1901
|
+
|
1902
|
+
], :int
|
1903
|
+
|
1458
1904
|
#{ Fxxx
|
1459
1905
|
FVIRTKEY = 1
|
1460
1906
|
FCONTROL = 0x08
|