ActiveX By-reference Arguments for Methods and Events

ActiveX supports by-reference arguments for methods and events since 3ds Max 5.1.

For example:

rollout winsockTester "Winsock Tester" (


activeXControl axWinsock "{248DD896-BB45-11CF-9ABC-0080C7E7B78D}" align:#left

edittext txt text:"" 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



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


.Accept requestID:integer

.SendData data:undefined

.GetData &data:undefined type:undefined maxLen:undefined

.PeekData &data:undefined type:undefined maxLen:undefined


.Bind LocalPort:undefined LocalIP:undefined

Since the value type for the 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.

See also

ActiveX Controls in MAXScript Rollouts