vruby 2004.08.07
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vr/clipboard.rb +107 -0
- data/lib/vr/compat/rubycompat.rb +18 -0
- data/lib/vr/compat/vrcomctl.rb +12 -0
- data/lib/vr/compat/vrcontrol.rb +50 -0
- data/lib/vr/compat/vrmmedia.rb +24 -0
- data/lib/vr/contrib/inifile.rb +111 -0
- data/lib/vr/contrib/msgboxconst.rb +55 -0
- data/lib/vr/contrib/toolbar.rb +378 -0
- data/lib/vr/contrib/vrctlcolor.rb +110 -0
- data/lib/vr/contrib/vrhotkey.rb +35 -0
- data/lib/vr/contrib/vrlistviewex.rb +71 -0
- data/lib/vr/contrib/vrwincomponent.rb +54 -0
- data/lib/vr/dragdropformat.rb +210 -0
- data/lib/vr/handlers.rd +5 -0
- data/lib/vr/rscutil.rb +170 -0
- data/lib/vr/sysmod.rb +250 -0
- data/lib/vr/vractivex.rb +56 -0
- data/lib/vr/vrclipboard.rb +55 -0
- data/lib/vr/vrcomctl.rb +1779 -0
- data/lib/vr/vrcontrol.rb +1326 -0
- data/lib/vr/vrdde.rb +625 -0
- data/lib/vr/vrddrop.rb +191 -0
- data/lib/vr/vrdialog.rb +403 -0
- data/lib/vr/vrhandler.rb +196 -0
- data/lib/vr/vrlayout.old.rb +209 -0
- data/lib/vr/vrlayout.rb +174 -0
- data/lib/vr/vrlayout2.rb +340 -0
- data/lib/vr/vrmmedia.rb +289 -0
- data/lib/vr/vrolednd.rb +193 -0
- data/lib/vr/vrowndraw.rb +109 -0
- data/lib/vr/vrrichedit.rb +335 -0
- data/lib/vr/vrtimer.rb +150 -0
- data/lib/vr/vrtooltip.rb +274 -0
- data/lib/vr/vrtray.rb +144 -0
- data/lib/vr/vrtvitem.rb +120 -0
- data/lib/vr/vrtwopane.rb +226 -0
- data/lib/vr/vruby.rb +1050 -0
- data/lib/vr/winconst.rb +159 -0
- metadata +86 -0
data/lib/vr/handlers.rd
ADDED
data/lib/vr/rscutil.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# rscutil.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 2000-2001 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://www.osk.3web.ne.jp/~nyasu/software/vrproject.html
|
8
|
+
# (in Japanese)
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
###################################
|
13
|
+
|
14
|
+
require 'swin'
|
15
|
+
|
16
|
+
|
17
|
+
=begin
|
18
|
+
= rscutil.rb
|
19
|
+
Utilities for resources
|
20
|
+
|
21
|
+
== Base64dumper
|
22
|
+
The module to use binary data with base64
|
23
|
+
=== Class Method
|
24
|
+
--- loadString(str)
|
25
|
+
Load a object from base64 encoded string.
|
26
|
+
=== Method
|
27
|
+
--- dumpString
|
28
|
+
Dumps an object into base64 encoded string.
|
29
|
+
=end
|
30
|
+
|
31
|
+
module Base64dumper
|
32
|
+
def self.loadString(str)
|
33
|
+
Marshal.load(str.unpack("m")[0])
|
34
|
+
end
|
35
|
+
|
36
|
+
def dumpString
|
37
|
+
[Marshal.dump(self)].pack("m")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
module SWin
|
44
|
+
class Bitmap
|
45
|
+
include Base64dumper
|
46
|
+
def self.loadString(str) Base64dumper.loadString(str) end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#####
|
51
|
+
|
52
|
+
module SWin
|
53
|
+
class Font
|
54
|
+
STRIKEOUT=4
|
55
|
+
UNDERLINE=2
|
56
|
+
ITALIC=1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
## ####--------------------
|
61
|
+
|
62
|
+
# FontStruct for handling fonts and text attributes.
|
63
|
+
|
64
|
+
=begin
|
65
|
+
== FontStruct
|
66
|
+
Subclass of Struct for representing text attributes.
|
67
|
+
|
68
|
+
=== Attributes
|
69
|
+
--- fontface
|
70
|
+
--- height
|
71
|
+
--- style
|
72
|
+
--- weight
|
73
|
+
--- width
|
74
|
+
--- escapement
|
75
|
+
--- orientation
|
76
|
+
--- pitch_family
|
77
|
+
--- charset
|
78
|
+
--- point
|
79
|
+
--- color
|
80
|
+
|
81
|
+
=== Class Method
|
82
|
+
--- new2(args)
|
83
|
+
Use new2 instead of new.
|
84
|
+
|
85
|
+
=== Methods
|
86
|
+
--- params
|
87
|
+
Returns parameters that can be used for parameter of
|
88
|
+
SWin::LWFactory.newfont()
|
89
|
+
--- spec
|
90
|
+
Returns text attributes for parameter of SWin::CommonDialog.chooseFont
|
91
|
+
--- bold?
|
92
|
+
Returns whether the attributes means bold style
|
93
|
+
--- bold=(flag)
|
94
|
+
Sets or resets bold style.
|
95
|
+
--- italic?
|
96
|
+
Returns whether the attributes means italic style
|
97
|
+
--- italic=(flag)
|
98
|
+
Sets or resets italic style.
|
99
|
+
--- underlined?
|
100
|
+
Returns whether the attributes means underline style
|
101
|
+
--- underlined=(flag)
|
102
|
+
Sets or resets underline style.
|
103
|
+
--- striked?
|
104
|
+
Returns whether the attributes means strike-out style
|
105
|
+
--- striked=(flag)
|
106
|
+
Sets or resets strike-out style.
|
107
|
+
=end
|
108
|
+
|
109
|
+
FontStruct = Struct.new("FontStruct",
|
110
|
+
:fontface,:height,:style,:weight,:width,:escapement,
|
111
|
+
:orientation,:pitch_family,:charset,
|
112
|
+
:point,:color)
|
113
|
+
|
114
|
+
class FontStruct
|
115
|
+
private_class_method :new
|
116
|
+
|
117
|
+
def self.new2(*args)
|
118
|
+
new(*args.flatten)
|
119
|
+
end
|
120
|
+
|
121
|
+
def params
|
122
|
+
to_a[0,9]
|
123
|
+
end
|
124
|
+
|
125
|
+
def spec
|
126
|
+
a=self.to_a
|
127
|
+
[ a[0,9],a[9],a[10] ]
|
128
|
+
end
|
129
|
+
|
130
|
+
def bold=(flag)
|
131
|
+
self.weight = if flag then 600 else 300 end
|
132
|
+
end
|
133
|
+
def bold?
|
134
|
+
(@weight>400)
|
135
|
+
end
|
136
|
+
|
137
|
+
def italic=(flag)
|
138
|
+
if flag then
|
139
|
+
self.style |= 1 # 1=SWINFONT_ITALIC
|
140
|
+
else
|
141
|
+
self.style &= 0xfffffffe
|
142
|
+
end
|
143
|
+
end
|
144
|
+
def italic?
|
145
|
+
(self.style&1)>0
|
146
|
+
end
|
147
|
+
|
148
|
+
def underlined=(flag)
|
149
|
+
if flag then
|
150
|
+
self.style |= 2 # 2=SWINFONT_ULINE
|
151
|
+
else
|
152
|
+
self.style &= 0xfffffffd
|
153
|
+
end
|
154
|
+
end
|
155
|
+
def underlined?
|
156
|
+
(self.style&2)>0
|
157
|
+
end
|
158
|
+
|
159
|
+
def striked=(flag)
|
160
|
+
if flag then
|
161
|
+
self.style |= 4 # 4=SWINFONT_STRIKE
|
162
|
+
else
|
163
|
+
self.style &= 0xfffffffb
|
164
|
+
end
|
165
|
+
end
|
166
|
+
def striked?
|
167
|
+
(self.style&4)>0
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
data/lib/vr/sysmod.rb
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# sysmod.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 1999-2001 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
|
8
|
+
# (in Japanese)
|
9
|
+
#
|
10
|
+
###################################
|
11
|
+
|
12
|
+
require 'Win32API'
|
13
|
+
|
14
|
+
=begin
|
15
|
+
= sysmod.rb
|
16
|
+
Win32 Utilities
|
17
|
+
=end
|
18
|
+
|
19
|
+
module MEMCOPY #Thanks, ruby-chan :)
|
20
|
+
=begin
|
21
|
+
== MEMCOPY
|
22
|
+
This is for copying string and memory each other.
|
23
|
+
|
24
|
+
=== Class Methods
|
25
|
+
--- MEMCOPY::Str2Mem(dst,src,len)
|
26
|
+
Copies src (String) into memory at address dst (Integer).
|
27
|
+
--- MEMCOPY::Mem2Str(dst,src,len)
|
28
|
+
Copies contents from address dst (Integer) into src (String).
|
29
|
+
=end
|
30
|
+
begin
|
31
|
+
## Windows2000
|
32
|
+
Pmemcpy1 = Win32API.new("NTDLL", "memcpy", ['P', 'L', 'I'], 'L')
|
33
|
+
Pmemcpy2 = Win32API.new("NTDLL", "memcpy", ['L', 'P', 'I'], 'L')
|
34
|
+
rescue
|
35
|
+
## Windows95/98
|
36
|
+
Pmemcpy1 = Win32API.new("CRTDLL", "memcpy", ['P', 'L', 'I'], 'L')
|
37
|
+
Pmemcpy2 = Win32API.new("CRTDLL", "memcpy", ['L', 'P', 'I'], 'L')
|
38
|
+
end
|
39
|
+
|
40
|
+
def MEMCOPY::Str2Mem(dst,src,len)
|
41
|
+
Pmemcpy2.call(dst,src,len)
|
42
|
+
end
|
43
|
+
def MEMCOPY::Mem2Str(dst,src,len=dst.length)
|
44
|
+
Pmemcpy1.call(dst,src,len)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module GAtom
|
49
|
+
=begin
|
50
|
+
== GAtom
|
51
|
+
This is for utilizing Global Atoms.
|
52
|
+
|
53
|
+
--- GAtom::Add(text)
|
54
|
+
Create a new global atom whose name is ((|text|)).
|
55
|
+
--- GAtom::Delete(atm)
|
56
|
+
Delete ((|atm|)) of global atom.
|
57
|
+
--- GAtom::GetName(atm)
|
58
|
+
Returns name of ((|atm|)) of global atom.
|
59
|
+
=end
|
60
|
+
|
61
|
+
GlobalAddAtom = Win32API.new("kernel32","GlobalAddAtom",["P"],"I")
|
62
|
+
GlobalDeleteAtom=Win32API.new("kernel32","GlobalDeleteAtom",["I"],"I")
|
63
|
+
GlobalGetAtomName=Win32API.new("kernel32","GlobalGetAtomName",["I","P","I"],"I")
|
64
|
+
|
65
|
+
def GAtom::Add(text) (0xffff & GlobalAddAtom.call(text.to_s)) end
|
66
|
+
def GAtom::Delete(atm) GlobalDeleteAtom.call(atm) end
|
67
|
+
|
68
|
+
def GAtom::GetName(atm)
|
69
|
+
buffer=" "*256
|
70
|
+
r = GlobalGetAtomName.call(atm,buffer,256)
|
71
|
+
buffer[0,r]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
module GMEM
|
76
|
+
=begin
|
77
|
+
== GMEM
|
78
|
+
This is for utilizing Global memories.
|
79
|
+
|
80
|
+
=== Class Methods
|
81
|
+
--- GMEM::AllocStr(mode,text)
|
82
|
+
Allocates a global memory and set its contents as ((|text|)).
|
83
|
+
--- GMEM::Set(gmem,text,len)
|
84
|
+
Sets the contents of global memory gmem as ((|text|)).
|
85
|
+
--- GMEM::Get(gmem)
|
86
|
+
Gets the contents of gmem.
|
87
|
+
|
88
|
+
--- GMEM::Alloc(size)
|
89
|
+
Allocates a global memory.
|
90
|
+
--- GMEM::Lock(gmem)
|
91
|
+
Locks gmem to access it.
|
92
|
+
--- GMEM::Unlock(gmem)
|
93
|
+
Unlocks gmem.
|
94
|
+
--- GMEM::Free(gmem)
|
95
|
+
Frees gmem.
|
96
|
+
--- GMEM::Size(gmem)
|
97
|
+
Returns the size of gmem.
|
98
|
+
=end
|
99
|
+
|
100
|
+
#GlobalAlloc(method,size)
|
101
|
+
GlobalAlloc = Win32API.new("kernel32","GlobalAlloc",["I","I"],"I")
|
102
|
+
|
103
|
+
GlobalLock = Win32API.new("kernel32","GlobalLock",["I"],"I")
|
104
|
+
GlobalUnlock = Win32API.new("kernel32","GlobalUnlock",["I"],"")
|
105
|
+
GlobalFree = Win32API.new("kernel32","GlobalFree",["I"],"I")
|
106
|
+
GlobalSize = Win32API.new("kernel32","GlobalSize",["I"],"I")
|
107
|
+
GlobalFlags= Win32API.new("kernel32","GlobalFlags",["I"],"I")
|
108
|
+
|
109
|
+
def GMEM::Alloc(*arg) GlobalAlloc.call(*arg) end
|
110
|
+
def GMEM::Lock(*arg) GlobalLock.call(*arg) end
|
111
|
+
def GMEM::Unlock(*arg) GlobalUnlock.call(*arg) end
|
112
|
+
def GMEM::Free(*arg) GlobalFree.call(*arg) end
|
113
|
+
def GMEM::Size(*arg) GlobalSize.call(*arg) end
|
114
|
+
|
115
|
+
def GMEM::AllocStr(mode,text)
|
116
|
+
mem = GlobalAlloc.call(mode,text.length+1)
|
117
|
+
Set(mem,text,text.size+1)
|
118
|
+
mem
|
119
|
+
end
|
120
|
+
|
121
|
+
def GMEM::Set(hglb,text,siz=nil)
|
122
|
+
len= if siz then siz.to_i else [size,Size(hglb)].min end
|
123
|
+
lp = GlobalLock.call(hglb)
|
124
|
+
MEMCOPY::Str2Mem(lp,text.to_s,len)
|
125
|
+
GlobalUnlock.call(hglb)
|
126
|
+
end
|
127
|
+
def GMEM::Get(hglb)
|
128
|
+
lp = GlobalLock.call(hglb)
|
129
|
+
len = GlobalSize.call(hglb)
|
130
|
+
#p format "%x %d, %x",hglb, lp, GlobalFlags.call(hglb)
|
131
|
+
raise "Memory not accessible" if len==0
|
132
|
+
str = " " * (len+1)
|
133
|
+
MEMCOPY::Mem2Str(str,lp,len)
|
134
|
+
GlobalUnlock.call(hglb)
|
135
|
+
str
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
module SMSG
|
140
|
+
=begin
|
141
|
+
== SMSG
|
142
|
+
This is for Windows Messaging.
|
143
|
+
|
144
|
+
=== Class Methods
|
145
|
+
--- sendMessage(hwnd,uMsg,wParam,lParam)
|
146
|
+
Calls SendMessage(). see Windows SDK document.
|
147
|
+
((|lParam|)) can be both type of Integer and String
|
148
|
+
--- postMessage(hwnd,uMsg,wParam,lParam)
|
149
|
+
Calls PostMessage(). see Windows SDK document.
|
150
|
+
((|lParam|)) can be both type of Integer and String
|
151
|
+
=end
|
152
|
+
|
153
|
+
SendMessage = Win32API.new("user32","SendMessage",["I","I","I","I"],"I")
|
154
|
+
PostMessage = Win32API.new("user32","PostMessage",["I","I","I","I"],"I")
|
155
|
+
SendMessage2 = Win32API.new("user32","SendMessage",["I","I","I","P"],"I")
|
156
|
+
PostMessage2 = Win32API.new("user32","PostMessage",["I","I","I","P"],"I")
|
157
|
+
|
158
|
+
def SMSG.sendMessage(*arg)
|
159
|
+
if arg[3].is_a?(Integer) then
|
160
|
+
SendMessage.call(*arg)
|
161
|
+
else
|
162
|
+
SendMessage2.call(*arg)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def SMSG.postMessage(*arg)
|
167
|
+
if arg[3].is_a?(Integer) then
|
168
|
+
PostMessage.call(*arg)
|
169
|
+
else
|
170
|
+
PostMessage2.call(*arg)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
module Cursor
|
176
|
+
=begin
|
177
|
+
== Cursor
|
178
|
+
This is for System cursor handling.
|
179
|
+
|
180
|
+
=== Class Methods
|
181
|
+
--- get_screenposition
|
182
|
+
Returns x,y in the screen coordinate.
|
183
|
+
--- set_screenposition(x,y)
|
184
|
+
Sets cursor position into (x,y) in the screen coordinate.
|
185
|
+
=end
|
186
|
+
|
187
|
+
GetCursorPos = Win32API.new("user32","GetCursorPos","P","I")
|
188
|
+
SetCursorPos = Win32API.new("user32","SetCursorPos","II","I")
|
189
|
+
POINTSTRUCT="II"
|
190
|
+
|
191
|
+
def self.get_screenposition
|
192
|
+
r=[0,0].pack(POINTSTRUCT)
|
193
|
+
GetCursorPos.call(r)
|
194
|
+
r.unpack(POINTSTRUCT)
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.set_screenposition(x,y)
|
198
|
+
SetCursorPos.call(x.to_i,y.to_i)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
module LastError
|
203
|
+
=begin
|
204
|
+
== LastError
|
205
|
+
This is for handling LastError.
|
206
|
+
|
207
|
+
=== Class Methods
|
208
|
+
--- set(ecode)
|
209
|
+
Sets lasterror code as ((|ecode|)).
|
210
|
+
--- code
|
211
|
+
--- get
|
212
|
+
Gets last error code.
|
213
|
+
--- code2msg(ecode,msgarg=0)
|
214
|
+
Get the error message of ((|ecode|)).
|
215
|
+
((|msgarg|)) is optional argument for message formatting.
|
216
|
+
--- message(arg=0)
|
217
|
+
Returns last error message.
|
218
|
+
=end
|
219
|
+
|
220
|
+
GetLastError = Win32API.new('kernel32','GetLastError','V','L')
|
221
|
+
SetLastError = Win32API.new('kernel32','SetLastError','L','V')
|
222
|
+
FormatMessage = Win32API.new('kernel32','FormatMessageA','LPLLPLP','L')
|
223
|
+
FORMAT_MESSAGE_FROM_SYSTEM = 4096
|
224
|
+
|
225
|
+
def self.set(ecode)
|
226
|
+
SetLastError.call(ecode)
|
227
|
+
end
|
228
|
+
|
229
|
+
def self.code
|
230
|
+
GetLastError.call()
|
231
|
+
end
|
232
|
+
def self.get() self.code end
|
233
|
+
|
234
|
+
def self.code2msg(scode,msg=0)
|
235
|
+
buffer = " "*(2048)
|
236
|
+
len = FormatMessage.call FORMAT_MESSAGE_FROM_SYSTEM,0,scode,0,
|
237
|
+
buffer,buffer.size,msg
|
238
|
+
buffer[0,len]
|
239
|
+
end
|
240
|
+
|
241
|
+
def self.message(msg=0)
|
242
|
+
self.code2msg(self.code,msg)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
module ClipboardFormat
|
247
|
+
CF_TEXT = 1
|
248
|
+
CF_OEMTEXT = 7
|
249
|
+
CF_HDROP = 15
|
250
|
+
end
|
data/lib/vr/vractivex.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vractivex.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 2003 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
|
8
|
+
# (in Japanese)
|
9
|
+
#
|
10
|
+
###################################
|
11
|
+
|
12
|
+
require 'vr/vruby'
|
13
|
+
require 'Win32API'
|
14
|
+
require 'win32ole'
|
15
|
+
|
16
|
+
class VRActiveXControl < VRControl
|
17
|
+
Win32API.new("atl.dll","AtlAxWinInit","","I").call
|
18
|
+
|
19
|
+
WINCLASSINFO=["AtlAxWin",0]
|
20
|
+
ACTIVEXCINFO=["",""] # PROGID,EVENTSINK
|
21
|
+
|
22
|
+
alias :progId :caption
|
23
|
+
alias :progId= :caption=
|
24
|
+
def caption() "" end
|
25
|
+
def caption=(arg) arg end
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
self.progId = self.class::ACTIVEXCINFO[0]
|
29
|
+
class <<self
|
30
|
+
undef_method :progId=
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def vrinit
|
35
|
+
super
|
36
|
+
@_vr_win32ole = self.get_oleinterface
|
37
|
+
if self.class::ACTIVEXCINFO[1] then
|
38
|
+
@_vr_win32ole_event =
|
39
|
+
WIN32OLE_EVENT.new(@_vr_win32ole,self.class::ACTIVEXCINFO[1])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def ole_interface() @_vr_win32ole; end
|
44
|
+
def ole_events() @_vr_win32ole_event; end
|
45
|
+
|
46
|
+
def add_oleeventhandler(evname,handlername=evname.downcase)
|
47
|
+
ole_events.on_event(evname) do |*args|
|
48
|
+
@parent.controlmsg_dispatching(self,handlername,*args)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _invoke(*args) @_vr_win32ole._invoke(*args) end
|
53
|
+
def _setproperty(*args) @_vr_win32ole._setproperty(*args) end
|
54
|
+
def _getproperty(*args) @_vr_win32ole._getproperty(*args) end
|
55
|
+
|
56
|
+
end
|