exerb 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/ChangeLog.ja.rd +305 -0
  4. data/README.en.txt +12 -0
  5. data/README.ja.html +143 -0
  6. data/README.ja.txt +6 -0
  7. data/README.md +50 -0
  8. data/Rakefile +205 -0
  9. data/bin/exerb +185 -0
  10. data/bin/mkexy +47 -0
  11. data/doc/LGPL +513 -0
  12. data/doc/class.ja.html +92 -0
  13. data/doc/command.ja.html +109 -0
  14. data/doc/core.ja.html +72 -0
  15. data/doc/example.ja.html +89 -0
  16. data/doc/faq.ja.html +59 -0
  17. data/doc/inside.ja.rd +404 -0
  18. data/doc/license.ja.html +62 -0
  19. data/doc/logo.gif +0 -0
  20. data/doc/misc.ja.html +72 -0
  21. data/doc/navi.gif +0 -0
  22. data/doc/recipe.ja.html +317 -0
  23. data/doc/style.css +187 -0
  24. data/doc/tutorial.ja.html +182 -0
  25. data/example/Makefile +54 -0
  26. data/example/cat_n.rb +14 -0
  27. data/example/exception.rb +9 -0
  28. data/example/ext/Win32API.so +0 -0
  29. data/example/ext/swin.so +0 -0
  30. data/example/msgbox.rb +14 -0
  31. data/example/rubytk.rb +22 -0
  32. data/example/runtime.ico +0 -0
  33. data/example/runtime.rb +19 -0
  34. data/example/vr/clipboard.rb +106 -0
  35. data/example/vr/compat/rubycompat.rb +18 -0
  36. data/example/vr/compat/vrcomctl.rb +12 -0
  37. data/example/vr/compat/vrcontrol.rb +50 -0
  38. data/example/vr/compat/vrmmedia.rb +24 -0
  39. data/example/vr/contrib/inifile.rb +116 -0
  40. data/example/vr/contrib/msgboxconst.rb +55 -0
  41. data/example/vr/contrib/toolbar.rb +371 -0
  42. data/example/vr/contrib/vrctlcolor.rb +110 -0
  43. data/example/vr/contrib/vrhotkey.rb +35 -0
  44. data/example/vr/contrib/vrlistviewex.rb +71 -0
  45. data/example/vr/contrib/vrstdscrollbar.rb +414 -0
  46. data/example/vr/contrib/vrwincomponent.rb +54 -0
  47. data/example/vr/dragdropformat.rb +209 -0
  48. data/example/vr/rscutil.rb +168 -0
  49. data/example/vr/sysmod.rb +249 -0
  50. data/example/vr/vractivex.rb +56 -0
  51. data/example/vr/vrclipboard.rb +53 -0
  52. data/example/vr/vrcomctl.rb +1819 -0
  53. data/example/vr/vrcontrol.rb +1374 -0
  54. data/example/vr/vrdde.rb +623 -0
  55. data/example/vr/vrddrop.rb +190 -0
  56. data/example/vr/vrdialog.rb +406 -0
  57. data/example/vr/vrhandler.rb +195 -0
  58. data/example/vr/vrlayout.old.rb +209 -0
  59. data/example/vr/vrlayout.rb +173 -0
  60. data/example/vr/vrlayout2.rb +340 -0
  61. data/example/vr/vrmargin.rb +141 -0
  62. data/example/vr/vrmgdlayout.rb +381 -0
  63. data/example/vr/vrmmedia.rb +287 -0
  64. data/example/vr/vrolednd.rb +192 -0
  65. data/example/vr/vrowndraw.rb +108 -0
  66. data/example/vr/vrrichedit.rb +366 -0
  67. data/example/vr/vrtimer.rb +148 -0
  68. data/example/vr/vrtooltip.rb +273 -0
  69. data/example/vr/vrtray.rb +143 -0
  70. data/example/vr/vrtvitem.rb +118 -0
  71. data/example/vr/vrtwopane.rb +223 -0
  72. data/example/vr/vruby.rb +1051 -0
  73. data/example/vr/winconst.rb +158 -0
  74. data/example/vruby.rb +38 -0
  75. data/exerb.gemspec +26 -0
  76. data/extconf.rb +7 -0
  77. data/lib/exerb/archive.rb +143 -0
  78. data/lib/exerb/config.rb +51 -0
  79. data/lib/exerb/error.rb +15 -0
  80. data/lib/exerb/executable.rb +68 -0
  81. data/lib/exerb/file_table.rb +189 -0
  82. data/lib/exerb/mkexy.rb +81 -0
  83. data/lib/exerb/name_table.rb +120 -0
  84. data/lib/exerb/recipe.rb +465 -0
  85. data/lib/exerb/resource.rb +190 -0
  86. data/lib/exerb/resource/base.rb +29 -0
  87. data/lib/exerb/resource/binary.rb +31 -0
  88. data/lib/exerb/resource/dialog.rb +30 -0
  89. data/lib/exerb/resource/group_icon.rb +85 -0
  90. data/lib/exerb/resource/icon.rb +52 -0
  91. data/lib/exerb/resource/version_info.rb +155 -0
  92. data/lib/exerb/resource_library.rb +120 -0
  93. data/lib/exerb/utility.rb +95 -0
  94. data/lib/exerb/utility2.rb +122 -0
  95. data/lib/exerb/version.rb +13 -0
  96. data/lib/exerb/win32/const/resource.rb +51 -0
  97. data/lib/exerb/win32/icon_file.rb +78 -0
  98. data/lib/exerb/win32/pe_file.rb +59 -0
  99. data/lib/exerb/win32/resource_directory.rb +105 -0
  100. data/lib/exerb/win32/resource_directory_root.rb +67 -0
  101. data/lib/exerb/win32/resource_entry.rb +98 -0
  102. data/lib/exerb/win32/struct/base.rb +43 -0
  103. data/lib/exerb/win32/struct/icon_dir_entry.rb +83 -0
  104. data/lib/exerb/win32/struct/icon_header.rb +43 -0
  105. data/lib/exerb/win32/struct/icon_res_entry.rb +48 -0
  106. data/lib/exerb/win32/struct/image_dos_header.rb +73 -0
  107. data/lib/exerb/win32/struct/image_file_header.rb +47 -0
  108. data/lib/exerb/win32/struct/image_nt_headers32.rb +53 -0
  109. data/lib/exerb/win32/struct/image_optional_header32.rb +107 -0
  110. data/lib/exerb/win32/struct/image_resource_data_entry.rb +45 -0
  111. data/lib/exerb/win32/struct/image_resource_directory.rb +47 -0
  112. data/lib/exerb/win32/struct/image_resource_directory_entry.rb +72 -0
  113. data/lib/exerb/win32/struct/image_section_header.rb +53 -0
  114. data/lib/exerb/win32/struct/version_info_block.rb +75 -0
  115. data/lib/exerb/win32/struct/vs_fixed_file_info.rb +62 -0
  116. data/src/exerb/cui.c +48 -0
  117. data/src/exerb/default.rb +1 -0
  118. data/src/exerb/exerb.c +877 -0
  119. data/src/exerb/exerb.h +92 -0
  120. data/src/exerb/gui.c +176 -0
  121. data/src/exerb/module.c +138 -0
  122. data/src/exerb/module.h +7 -0
  123. data/src/exerb/patch.c +27 -0
  124. data/src/exerb/resource.h +22 -0
  125. data/src/exerb/resource.rc +121 -0
  126. data/src/exerb/ruby.ico +0 -0
  127. data/src/exerb/utility.c +263 -0
  128. data/src/exerb/utility.h +33 -0
  129. data/test/alltests.rb +16 -0
  130. data/test/test-argv.rb +26 -0
  131. data/test/test-argv/test-argv.rb +9 -0
  132. data/test/test-argv/test-argv.ret +1 -0
  133. data/test/test-dollarzero.rb +26 -0
  134. data/test/test-dollarzero/test-dollarzero.rb +10 -0
  135. data/test/test-dollarzero/test-dollarzero.ret +2 -0
  136. data/test/test-dot.rb +26 -0
  137. data/test/test-dot/dot.dot.dot.rb +9 -0
  138. data/test/test-dot/dot.dot.rb +9 -0
  139. data/test/test-dot/test-dot.rb +13 -0
  140. data/test/test-dot/test-dot.ret +5 -0
  141. data/test/test-exitcode.rb +28 -0
  142. data/test/test-exitcode/test-exitcode.rb +9 -0
  143. data/test/test-kcode.rb +43 -0
  144. data/test/test-kcode/euc.rb +10 -0
  145. data/test/test-kcode/euc.ret +2 -0
  146. data/test/test-kcode/none.rb +10 -0
  147. data/test/test-kcode/none.ret +2 -0
  148. data/test/test-kcode/sjis.rb +10 -0
  149. data/test/test-kcode/sjis.ret +2 -0
  150. data/test/test-kcode/utf8.rb +10 -0
  151. data/test/test-kcode/utf8.ret +2 -0
  152. data/test/test-loadpath.rb +24 -0
  153. data/test/test-loadpath/test-loadpath.rb +9 -0
  154. data/test/test-nest.rb +18 -0
  155. data/test/test-nest/foo.rb +1 -0
  156. data/test/test-nest/foo/bar.rb +2 -0
  157. data/test/test-nest/foo/foo.rb +1 -0
  158. data/test/test-nest/test-nest.rb +1 -0
  159. data/test/test-nest/test-nest.ret +1 -0
  160. data/test/test-preload.rb +24 -0
  161. data/test/test-preload/test-preload.rb +9 -0
  162. data/test/test-regexp.rb +26 -0
  163. data/test/test-regexp/test-regexp.rb +23 -0
  164. data/test/test-regexp/test-regexp.ret +13 -0
  165. data/test/test-require1.rb +26 -0
  166. data/test/test-require1/require1.rb +9 -0
  167. data/test/test-require1/require2.rb +9 -0
  168. data/test/test-require1/require3.rb +9 -0
  169. data/test/test-require1/require4.rb +9 -0
  170. data/test/test-require1/require5.rb +9 -0
  171. data/test/test-require1/require6.rb +9 -0
  172. data/test/test-require1/test-require1.rb +41 -0
  173. data/test/test-require1/test-require1.ret +27 -0
  174. data/test/test-socket.rb +26 -0
  175. data/test/test-socket/test-socket.rb +7 -0
  176. data/test/test-socket/test-socket.ret +1 -0
  177. data/test/testcase.rb +66 -0
  178. data/vendor/mkexports.rb +167 -0
  179. metadata +352 -0
@@ -0,0 +1,54 @@
1
+ ###############################
2
+ #
3
+ # contrib/vrwincomponent.rb
4
+ #
5
+ # These modules/classes are contributed by Yuya-san.
6
+ # Modified by nyasu <nyasu@osk.3web.ne.jp>
7
+ # Distributed at http://vruby.sourceforge.net/index.html
8
+ #
9
+ ###############################
10
+
11
+ #====================================================================#
12
+ # VRWinComponent Class
13
+ class VRWinComponent
14
+
15
+ #==================================================================#
16
+ # Instance Methods
17
+
18
+ def maximizebox
19
+ return self.winstyle.getter(WStyle::WS_MAXIMIZEBOX)
20
+ end
21
+
22
+ def maximizebox=(bool)
23
+ self.winstyle.setter(WStyle::WS_MAXIMIZEBOX, bool)
24
+ end
25
+
26
+ def minimizebox
27
+ return self.winstyle.getter(WStyle::WS_MINIMIZEBOX)
28
+ end
29
+
30
+ def minimizebox=(bool)
31
+ self.winstyle.setter(WStyle::WS_MINIMIZEBOX, bool)
32
+ end
33
+
34
+ def sizebox
35
+ return self.winstyle.getter(WStyle::WS_SIZEBOX)
36
+ end
37
+
38
+ def sizebox=(bool)
39
+ self.winstyle.setter(WStyle::WS_SIZEBOX, bool)
40
+ end
41
+
42
+ def tabstop
43
+ return self.winstyle.getter(WStyle::WS_TABSTOP)
44
+ end
45
+
46
+ def tabstop=(bool)
47
+ self.winstyle.setter(WStyle::WS_TABSTOP, bool)
48
+ end
49
+
50
+ end
51
+
52
+ #====================================================================#
53
+ # End of source.
54
+ #====================================================================#
@@ -0,0 +1,209 @@
1
+ ###################################
2
+ #
3
+ # dragdropformat.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 2002-2005 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://vruby.sourceforge.net/index.html
8
+ #
9
+ ###################################
10
+
11
+ VR_DIR="vr/" unless defined?(::VR_DIR)
12
+ require VR_DIR+'sysmod'
13
+ require 'Win32API'
14
+
15
+ module ClipboardFormat
16
+ RegisterClipboardFormat =
17
+ Win32API.new("user32","RegisterClipboardFormat","P","I")
18
+
19
+ CF_URL = RegisterClipboardFormat.call("UniformResourceLocator")
20
+
21
+ end
22
+
23
+ class DragDropObject
24
+ =begin
25
+ == DragDropObject
26
+ A capsule for OLE Drag and Drop
27
+ This is just a base class. Don't use this directly.
28
+
29
+ === Methods
30
+ --- handle
31
+ Returns a global heap handle containing the file pathes.
32
+ --- free_handle
33
+ Tries to free the handle.
34
+ Please check you really need to free it, because sometimes your OS will
35
+ free it automatically at the appropriate timing.
36
+ =end
37
+
38
+ def initialize
39
+ @__binarydata=""
40
+ end
41
+ def handle
42
+ @handle=GMEM::AllocStr(0x2000,@__binarydata)
43
+ end
44
+ def free_handle
45
+ GMEM::Free(@handle)
46
+ @handle=0
47
+ end
48
+
49
+ def objectformat
50
+ self.class::FormatId
51
+ end
52
+
53
+ end
54
+
55
+ class DragDropText < DragDropObject
56
+ =begin
57
+ == DragDropText
58
+ This class deals the structure for drag-and-drop files.
59
+
60
+ === Class Methods
61
+ --- set(files)
62
+ Creates object and sets the file pathes in ((|files|)) to the object.
63
+ --- get(handle)
64
+ Create object and sets the file pathes containing in ((|handle|)).
65
+ The ((|handle|)) is a global heap handle.
66
+ === Methods
67
+ --- text
68
+ Returns the text.
69
+ =end
70
+
71
+ FormatName="CF_TEXT"
72
+ FormatId=ClipboardFormat::CF_TEXT
73
+
74
+ def initialize(text,handle=0)
75
+ @__binarydata = @__texts = text.to_str.dup
76
+ @handle=handle
77
+ end
78
+
79
+ def self.set(texts)
80
+ self.new(texts)
81
+ end
82
+
83
+ def self.get(handle)
84
+ self.new(GMEM::Get(handle),handle)
85
+ end
86
+
87
+ def text
88
+ @__texts.dup
89
+ end
90
+ end
91
+
92
+ class DragDropFiles < DragDropObject
93
+ =begin
94
+ == DragDropFiles
95
+ This class deals the structure for drag-and-drop files.
96
+
97
+ === Class Methods
98
+ --- set(files)
99
+ Creates object and sets the file pathes in ((|files|)) to the object.
100
+ --- get(handle)
101
+ Create object and sets the file pathes containing in ((|handle|)).
102
+ The ((|handle|)) is a global heap handle.
103
+ === Methods
104
+ --- files
105
+ Returns the file pathes.
106
+ =end
107
+
108
+ FormatName = "CF_HDROP"
109
+ FormatId = ClipboardFormat::CF_HDROP
110
+
111
+ DragQueryFile = Win32API.new("shell32","DragQueryFile", ["I","I","P","I"],"I")
112
+
113
+ def initialize(files,handle=0)
114
+ @__files = files.dup
115
+ @handle=handle
116
+ @__binarydata="\0"*0x14+@__files.join("\0")+"\0"
117
+ @__binarydata[0]=0x14
118
+ end
119
+
120
+ def self.set(files)
121
+ self.new(files)
122
+ end
123
+
124
+ def self.get(handle)
125
+ __fnbuffer = " "*16 #256bytes
126
+ n=DragQueryFile.call(handle,-1,__fnbuffer,__fnbuffer.size)
127
+ r=[]
128
+ 0.upto(n-1) do |i|
129
+ s=DragQueryFile.call(handle,i,__fnbuffer,__fnbuffer.size)
130
+ r.push __fnbuffer[0,s]
131
+ end
132
+ self.new(r,handle)
133
+ end
134
+
135
+ def files
136
+ @__files.dup
137
+ end
138
+ end
139
+
140
+
141
+ module DragDropRubyObjectFactory
142
+ =begin
143
+ == DragDropRubyObjectFactory
144
+ This class' feature is to register new clipboard format into your system for
145
+ drag&drop ruby object.
146
+
147
+ === Class Methods
148
+ --- declare_dndclass(classname,registername)
149
+ Registers new format and create new wrapper class for ruby.
150
+ The format is registered as ((|registername|)) and
151
+ the wrapper class is declared as DragDropRubyObjectFactory::((|classname|)).
152
+ This methods returns the wrapper class.
153
+ =end
154
+
155
+
156
+ class DragDropRubyObject < DragDropObject
157
+ =begin
158
+ == DragDropRubyObjectFactory::DragDropRubyObject
159
+ This is a base class of wrapper classes created by
160
+ DragDropRubyObjectFactory.declare_dndclass()
161
+
162
+ === Class Methods
163
+ --- new(binstr,handle=0)
164
+ No need to use this. (maybe)
165
+ --- set(obj)
166
+ Returns new wrapper object of ((|obj|)) for drag&drop.
167
+ --- get(handle)
168
+ Returns wrapper object using global heap of ((|handle|)).
169
+ === Method
170
+ --- object
171
+ returns the wrapped object.
172
+ =end
173
+
174
+ include ClipboardFormat
175
+ FormatName = "DumpedRubyObjectForDnD"
176
+ FormatId = RegisterClipboardFormat.call(FormatName)
177
+
178
+ def initialize(bin,handle=0)
179
+ @objectformat = ClipboardFormat::CF_TEXT # only for base class
180
+ @__binarydata = bin
181
+ @handle=handle
182
+ end
183
+
184
+ def self.set(obj)
185
+ self.new(Marshal.dump(obj))
186
+ end
187
+
188
+ def self.get(handle)
189
+ bin = GMEM::Get(handle)
190
+ self.new(bin,handle)
191
+ end
192
+
193
+ def object
194
+ Marshal.load(@__binarydata)
195
+ end
196
+ end
197
+
198
+ def self.declare_dndclass(classname,registername)
199
+ str = <<"EEOOFF"
200
+ class #{classname} < DragDropRubyObject
201
+ FormatName = '#{registername}'
202
+ FormatId = RegisterClipboardFormat.call(FormatName)
203
+ end
204
+ EEOOFF
205
+ eval(str)
206
+ eval("#{classname} ")
207
+ end
208
+
209
+ end
@@ -0,0 +1,168 @@
1
+ ###################################
2
+ #
3
+ # rscutil.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 2000-2005 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://vruby.sourceforge.net/index.html
8
+ #
9
+ #
10
+ ###################################
11
+
12
+ require 'swin'
13
+
14
+
15
+ =begin
16
+ = rscutil.rb
17
+ Utilities for resources
18
+
19
+ == Base64dumper
20
+ The module to use binary data with base64
21
+ === Class Method
22
+ --- loadString(str)
23
+ Load a object from base64 encoded string.
24
+ === Method
25
+ --- dumpString
26
+ Dumps an object into base64 encoded string.
27
+ =end
28
+
29
+ module Base64dumper
30
+ def self.loadString(str)
31
+ Marshal.load(str.unpack("m")[0])
32
+ end
33
+
34
+ def dumpString
35
+ [Marshal.dump(self)].pack("m")
36
+ end
37
+ end
38
+
39
+
40
+
41
+ module SWin
42
+ class Bitmap
43
+ include Base64dumper
44
+ def self.loadString(str) Base64dumper.loadString(str) end
45
+ end
46
+ end
47
+
48
+ #####
49
+
50
+ module SWin
51
+ class Font
52
+ STRIKEOUT=4
53
+ UNDERLINE=2
54
+ ITALIC=1
55
+ end
56
+ end
57
+
58
+ ## ####--------------------
59
+
60
+ # FontStruct for handling fonts and text attributes.
61
+
62
+ =begin
63
+ == FontStruct
64
+ Subclass of Struct for representing text attributes.
65
+
66
+ === Attributes
67
+ --- fontface
68
+ --- height
69
+ --- style
70
+ --- weight
71
+ --- width
72
+ --- escapement
73
+ --- orientation
74
+ --- pitch_family
75
+ --- charset
76
+ --- point
77
+ --- color
78
+
79
+ === Class Method
80
+ --- new2(args)
81
+ Use new2 instead of new.
82
+
83
+ === Methods
84
+ --- params
85
+ Returns parameters that can be used for parameter of
86
+ SWin::LWFactory.newfont()
87
+ --- spec
88
+ Returns text attributes for parameter of SWin::CommonDialog.chooseFont
89
+ --- bold?
90
+ Returns whether the attributes means bold style
91
+ --- bold=(flag)
92
+ Sets or resets bold style.
93
+ --- italic?
94
+ Returns whether the attributes means italic style
95
+ --- italic=(flag)
96
+ Sets or resets italic style.
97
+ --- underlined?
98
+ Returns whether the attributes means underline style
99
+ --- underlined=(flag)
100
+ Sets or resets underline style.
101
+ --- striked?
102
+ Returns whether the attributes means strike-out style
103
+ --- striked=(flag)
104
+ Sets or resets strike-out style.
105
+ =end
106
+
107
+ FontStruct = Struct.new("FontStruct",
108
+ :fontface,:height,:style,:weight,:width,:escapement,
109
+ :orientation,:pitch_family,:charset,
110
+ :point,:color)
111
+
112
+ class FontStruct
113
+ private_class_method :new
114
+
115
+ def self.new2(*args)
116
+ new(*args.flatten)
117
+ end
118
+
119
+ def params
120
+ to_a[0,9]
121
+ end
122
+
123
+ def spec
124
+ a=self.to_a
125
+ [ a[0,9],a[9],a[10] ]
126
+ end
127
+
128
+ def bold=(flag)
129
+ self.weight = if flag then 600 else 300 end
130
+ end
131
+ def bold?
132
+ (@weight>400)
133
+ end
134
+
135
+ def italic=(flag)
136
+ if flag then
137
+ self.style |= 1 # 1=SWINFONT_ITALIC
138
+ else
139
+ self.style &= 0xfffffffe
140
+ end
141
+ end
142
+ def italic?
143
+ (self.style&1)>0
144
+ end
145
+
146
+ def underlined=(flag)
147
+ if flag then
148
+ self.style |= 2 # 2=SWINFONT_ULINE
149
+ else
150
+ self.style &= 0xfffffffd
151
+ end
152
+ end
153
+ def underlined?
154
+ (self.style&2)>0
155
+ end
156
+
157
+ def striked=(flag)
158
+ if flag then
159
+ self.style |= 4 # 4=SWINFONT_STRIKE
160
+ else
161
+ self.style &= 0xfffffffb
162
+ end
163
+ end
164
+ def striked?
165
+ (self.style&4)>0
166
+ end
167
+ end
168
+
@@ -0,0 +1,249 @@
1
+ ###################################
2
+ #
3
+ # sysmod.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 1999-2005 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://vruby.sourceforge.net/index.html
8
+ #
9
+ ###################################
10
+
11
+ require 'Win32API'
12
+
13
+ =begin
14
+ = sysmod.rb
15
+ Win32 Utilities
16
+ =end
17
+
18
+ module MEMCOPY #Thanks, ruby-chan :)
19
+ =begin
20
+ == MEMCOPY
21
+ This is for copying string and memory each other.
22
+
23
+ === Class Methods
24
+ --- MEMCOPY::Str2Mem(dst,src,len)
25
+ Copies src (String) into memory at address dst (Integer).
26
+ --- MEMCOPY::Mem2Str(dst,src,len)
27
+ Copies contents from address dst (Integer) into src (String).
28
+ =end
29
+ begin
30
+ ## Windows2000
31
+ Pmemcpy1 = Win32API.new("NTDLL", "memcpy", ['P', 'L', 'I'], 'L')
32
+ Pmemcpy2 = Win32API.new("NTDLL", "memcpy", ['L', 'P', 'I'], 'L')
33
+ rescue
34
+ ## Windows95/98
35
+ Pmemcpy1 = Win32API.new("CRTDLL", "memcpy", ['P', 'L', 'I'], 'L')
36
+ Pmemcpy2 = Win32API.new("CRTDLL", "memcpy", ['L', 'P', 'I'], 'L')
37
+ end
38
+
39
+ def MEMCOPY::Str2Mem(dst,src,len)
40
+ Pmemcpy2.call(dst,src,len)
41
+ end
42
+ def MEMCOPY::Mem2Str(dst,src,len=dst.length)
43
+ Pmemcpy1.call(dst,src,len)
44
+ end
45
+ end
46
+
47
+ module GAtom
48
+ =begin
49
+ == GAtom
50
+ This is for utilizing Global Atoms.
51
+
52
+ --- GAtom::Add(text)
53
+ Create a new global atom whose name is ((|text|)).
54
+ --- GAtom::Delete(atm)
55
+ Delete ((|atm|)) of global atom.
56
+ --- GAtom::GetName(atm)
57
+ Returns name of ((|atm|)) of global atom.
58
+ =end
59
+
60
+ GlobalAddAtom = Win32API.new("kernel32","GlobalAddAtom",["P"],"I")
61
+ GlobalDeleteAtom=Win32API.new("kernel32","GlobalDeleteAtom",["I"],"I")
62
+ GlobalGetAtomName=Win32API.new("kernel32","GlobalGetAtomName",["I","P","I"],"I")
63
+
64
+ def GAtom::Add(text) (0xffff & GlobalAddAtom.call(text.to_s)) end
65
+ def GAtom::Delete(atm) GlobalDeleteAtom.call(atm) end
66
+
67
+ def GAtom::GetName(atm)
68
+ buffer=" "*256
69
+ r = GlobalGetAtomName.call(atm,buffer,256)
70
+ buffer[0,r]
71
+ end
72
+ end
73
+
74
+ module GMEM
75
+ =begin
76
+ == GMEM
77
+ This is for utilizing Global memories.
78
+
79
+ === Class Methods
80
+ --- GMEM::AllocStr(mode,text)
81
+ Allocates a global memory and set its contents as ((|text|)).
82
+ --- GMEM::Set(gmem,text,len)
83
+ Sets the contents of global memory gmem as ((|text|)).
84
+ --- GMEM::Get(gmem)
85
+ Gets the contents of gmem.
86
+
87
+ --- GMEM::Alloc(size)
88
+ Allocates a global memory.
89
+ --- GMEM::Lock(gmem)
90
+ Locks gmem to access it.
91
+ --- GMEM::Unlock(gmem)
92
+ Unlocks gmem.
93
+ --- GMEM::Free(gmem)
94
+ Frees gmem.
95
+ --- GMEM::Size(gmem)
96
+ Returns the size of gmem.
97
+ =end
98
+
99
+ #GlobalAlloc(method,size)
100
+ GlobalAlloc = Win32API.new("kernel32","GlobalAlloc",["I","I"],"I")
101
+
102
+ GlobalLock = Win32API.new("kernel32","GlobalLock",["I"],"I")
103
+ GlobalUnlock = Win32API.new("kernel32","GlobalUnlock",["I"],"")
104
+ GlobalFree = Win32API.new("kernel32","GlobalFree",["I"],"I")
105
+ GlobalSize = Win32API.new("kernel32","GlobalSize",["I"],"I")
106
+ GlobalFlags= Win32API.new("kernel32","GlobalFlags",["I"],"I")
107
+
108
+ def GMEM::Alloc(*arg) GlobalAlloc.call(*arg) end
109
+ def GMEM::Lock(*arg) GlobalLock.call(*arg) end
110
+ def GMEM::Unlock(*arg) GlobalUnlock.call(*arg) end
111
+ def GMEM::Free(*arg) GlobalFree.call(*arg) end
112
+ def GMEM::Size(*arg) GlobalSize.call(*arg) end
113
+
114
+ def GMEM::AllocStr(mode,text)
115
+ mem = GlobalAlloc.call(mode,text.length+1)
116
+ Set(mem,text,text.size+1)
117
+ mem
118
+ end
119
+
120
+ def GMEM::Set(hglb,text,siz=nil)
121
+ len= if siz then siz.to_i else [size,Size(hglb)].min end
122
+ lp = GlobalLock.call(hglb)
123
+ MEMCOPY::Str2Mem(lp,text.to_s,len)
124
+ GlobalUnlock.call(hglb)
125
+ end
126
+ def GMEM::Get(hglb)
127
+ lp = GlobalLock.call(hglb)
128
+ len = GlobalSize.call(hglb)
129
+ #p format "%x %d, %x",hglb, lp, GlobalFlags.call(hglb)
130
+ raise "Memory not accessible" if len==0
131
+ str = " " * (len+1)
132
+ MEMCOPY::Mem2Str(str,lp,len)
133
+ GlobalUnlock.call(hglb)
134
+ str
135
+ end
136
+ end
137
+
138
+ module SMSG
139
+ =begin
140
+ == SMSG
141
+ This is for Windows Messaging.
142
+
143
+ === Class Methods
144
+ --- sendMessage(hwnd,uMsg,wParam,lParam)
145
+ Calls SendMessage(). see Windows SDK document.
146
+ ((|lParam|)) can be both type of Integer and String
147
+ --- postMessage(hwnd,uMsg,wParam,lParam)
148
+ Calls PostMessage(). see Windows SDK document.
149
+ ((|lParam|)) can be both type of Integer and String
150
+ =end
151
+
152
+ SendMessage = Win32API.new("user32","SendMessage",["I","I","I","I"],"I")
153
+ PostMessage = Win32API.new("user32","PostMessage",["I","I","I","I"],"I")
154
+ SendMessage2 = Win32API.new("user32","SendMessage",["I","I","I","P"],"I")
155
+ PostMessage2 = Win32API.new("user32","PostMessage",["I","I","I","P"],"I")
156
+
157
+ def SMSG.sendMessage(*arg)
158
+ if arg[3].is_a?(Integer) then
159
+ SendMessage.call(*arg)
160
+ else
161
+ SendMessage2.call(*arg)
162
+ end
163
+ end
164
+
165
+ def SMSG.postMessage(*arg)
166
+ if arg[3].is_a?(Integer) then
167
+ PostMessage.call(*arg)
168
+ else
169
+ PostMessage2.call(*arg)
170
+ end
171
+ end
172
+ end
173
+
174
+ module Cursor
175
+ =begin
176
+ == Cursor
177
+ This is for System cursor handling.
178
+
179
+ === Class Methods
180
+ --- get_screenposition
181
+ Returns x,y in the screen coordinate.
182
+ --- set_screenposition(x,y)
183
+ Sets cursor position into (x,y) in the screen coordinate.
184
+ =end
185
+
186
+ GetCursorPos = Win32API.new("user32","GetCursorPos","P","I")
187
+ SetCursorPos = Win32API.new("user32","SetCursorPos","II","I")
188
+ POINTSTRUCT="II"
189
+
190
+ def self.get_screenposition
191
+ r=[0,0].pack(POINTSTRUCT)
192
+ GetCursorPos.call(r)
193
+ r.unpack(POINTSTRUCT)
194
+ end
195
+
196
+ def self.set_screenposition(x,y)
197
+ SetCursorPos.call(x.to_i,y.to_i)
198
+ end
199
+ end
200
+
201
+ module LastError
202
+ =begin
203
+ == LastError
204
+ This is for handling LastError.
205
+
206
+ === Class Methods
207
+ --- set(ecode)
208
+ Sets lasterror code as ((|ecode|)).
209
+ --- code
210
+ --- get
211
+ Gets last error code.
212
+ --- code2msg(ecode,msgarg=0)
213
+ Get the error message of ((|ecode|)).
214
+ ((|msgarg|)) is optional argument for message formatting.
215
+ --- message(arg=0)
216
+ Returns last error message.
217
+ =end
218
+
219
+ GetLastError = Win32API.new('kernel32','GetLastError','V','L')
220
+ SetLastError = Win32API.new('kernel32','SetLastError','L','V')
221
+ FormatMessage = Win32API.new('kernel32','FormatMessageA','LPLLPLP','L')
222
+ FORMAT_MESSAGE_FROM_SYSTEM = 4096
223
+
224
+ def self.set(ecode)
225
+ SetLastError.call(ecode)
226
+ end
227
+
228
+ def self.code
229
+ GetLastError.call()
230
+ end
231
+ def self.get() self.code end
232
+
233
+ def self.code2msg(scode,msg=0)
234
+ buffer = " "*(2048)
235
+ len = FormatMessage.call FORMAT_MESSAGE_FROM_SYSTEM,0,scode,0,
236
+ buffer,buffer.size,msg
237
+ buffer[0,len]
238
+ end
239
+
240
+ def self.message(msg=0)
241
+ self.code2msg(self.code,msg)
242
+ end
243
+ end
244
+
245
+ module ClipboardFormat
246
+ CF_TEXT = 1
247
+ CF_OEMTEXT = 7
248
+ CF_HDROP = 15
249
+ end