1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5. global mx
  6.  
  7. ----------------------------------------
  8. --
  9. ----------------------------------------
  10. on startMovie
  11.     _player.debugplaybackenabled = 1
  12.  
  13.     -- movie/window setup
  14.     _movie.stage.rect = rect(0,0,320,240)
  15.     _movie.centerStage = 1
  16.     _movie.stage.title = "demo_projector" --> this title has to be passed to middleware.exe
  17.     _movie.stage.titlebarOptions.visible = TRUE
  18.     _movie.puppetTempo(30)
  19.     _movie.stage.visible = 1
  20.  
  21.     mx = xtra("Msg").new()
  22.  
  23.     -- start listening to WM_COPYDATA (=74) messages
  24.     mx.msg_listen([74], VOID, #slotMsgReceived)
  25.  
  26.     put "Listening to WM_COPYDATA messages..."
  27. end
  28.  
  29. --------------------------------------
  30. -- @callback
  31. --------------------------------------
  32. on slotMsgReceived (hwnd, msg, wParam, lParam, data, dwData)
  33.  
  34.     -- convert bytearray to string
  35.     data = data.readRawString(data.length)
  36.  
  37.     -- extract hwnd and cmd
  38.     hwnd_middleware = integer(data.word[1])
  39.     cmd = data.word[2..data.word.count]
  40.     put "Received:" && cmd
  41.  
  42.     res = value(cmd)
  43.     put "Returned:" && res
  44.  
  45.     -- now "return" the result by sending it to middleware.exe as WM_COPYDATA message
  46.     mx.send_data(hwnd_middleware, string(res))
  47. end
  48.  
[raw code]