--!movie
--!encoding=utf-8
global $
global mx
----------------------------------------
--
----------------------------------------
on startMovie
_player.debugplaybackenabled = 1
-- movie/window setup
_movie.stage.rect = rect(0,0,320,240)
_movie.centerStage = 1
_movie.stage.title = "demo_projector" --> this title has to be passed to middleware.exe
_movie.stage.titlebarOptions.visible = TRUE
_movie.puppetTempo(30)
_movie.stage.visible = 1
mx = xtra("Msg").new()
-- start listening to WM_COPYDATA (=74) messages
mx.msg_listen([74], VOID, #slotMsgReceived)
put "Listening to WM_COPYDATA messages..."
end
--------------------------------------
-- @callback
--------------------------------------
on slotMsgReceived (hwnd, msg, wParam, lParam, data, dwData)
-- convert bytearray to string
data = data.readRawString(data.length)
-- extract hwnd and cmd
hwnd_middleware = integer(data.word[1])
cmd = data.word[2..data.word.count]
put "Received:" && cmd
res = value(cmd)
put "Returned:" && res
-- now "return" the result by sending it to middleware.exe as WM_COPYDATA message
mx.send_data(hwnd_middleware, string(res))
end