ActiveX by-reference arguments for methods and events
NOTE:
ActiveX Controls have been deprecated by Microsoft in the latest versions of the
Windows operating system in favor of the DotNet framework and its controls.
While MAXScript still supports ActiveX controls, these have to be installed and registered
on the system to be accessible to MAXScript.
As a replacement of ActiveX controls, MAXScript supports DotNet controls in 3ds Max 9 and higher.
The following example will not work unless the used ActiveX control is installed on
your system.
ActiveX supports by-reference arguments for methods and events since 3ds Max 5.1.
EXAMPLE
|
rollout winsockTester "Winsock Tester" (
activeXControl axWinsock "{248DD896-BB45-11CF-9ABC-0080C7E7B78D}" align:#left
edittext txt text:"mail.iwaynet.net" offset:[-12, 0] fieldwidth:90
edittext txt2 "Port:" text:"110" offset:[8, -2]
button btn "Connect" width:90 height:16 offset:[0, 2]
button btn2 "Disconnect" width:90 height:16 offset:[0, -2] enabled:false
-- some data has arrived..
on axWinsock DataArrival bytes do
(
format "% bytes received.\n" bytes
local wsckData = "" -- initialize to a string
p = axWinsock.getdata &wsckdata -- by-reference argument
format "Data: %\n" wsckData
)
-- connected to remote host
on axWinsock Connect do
(
format "Connected.\n"
btn2.enabled = true
btn.enabled = false
)
-- connect!
on btn pressed do
(
axWinsock.connect txt.text txt2.text
format "Connecting ...\n"
)
-- disconnect
on btn2 pressed do
(
axWinsock.close()
format "Connection closed.\n"
btn2.enabled = false
btn.enabled = true
)
)
createdialog winsockTester 100 115
|
By-reference arguments are preceded with a '&' in showMethods and showEvents.
FOR EXAMPLE
|
showmethods winsockTester.axWinsock
.Connect RemoteHost:undefined RemotePort:undefined
.Listen()
.Accept requestID:integer
.SendData data:undefined
.GetData &data:undefined type:undefined maxLen:undefined
.PeekData &data:undefined type:undefined maxLen:undefined
.Close()
.Bind LocalPort:undefined LocalIP:undefined
|
Since the value type for the 'data' argument for GetData and PeekData is 'unknown',
we have to pass a value type that the ActiveX control knows how to handle. In this
case, the methods want a buffer where they can store data, and they know how to deal
with a string value. That is why we initialized variable wsckData to a null string.