Notifications
Clear all

[Closed] ActiveX ctrl as global var for access within functions

Hey,

 normally when I need to access something that is initialized later in the code,

I use (global) forward declarations. And usually it works. But somehow I can’t make it work with an activeX control I’d like to access from several functions. 🙁

 I tried something like this

     macroscript ...
     (
     
      ....
      global myXControl
      .....
      
      function x1
      (
        ....
        myXControl.Add()
        ....
      ) 
     
      function x2
      (
        ....
        myXControl.Add()
        ....
      )
     
      etc. ...
     
     rollout....
     (
        ....
        group "Output"
         (
           activeXControl myXControl "MSComctlLib.ListViewCtrl" height:400 
         )
     
        ....
     )
  
 ---------
 
 But I get runtime errors, as it says that myXControl is undefined.

Any idea?
thx

2 Replies

Rollout controls are always local to the rollout. Try forward-declaring your rollout instead, and then access the activex control as a property of the rollout.

macroscript ...
      (
     
      ....
      global myRollout
      .....
      
      function x1
      (
        ....
        myRollout.myXControl.Add()
        ....
      ) 
     
      function x2
      (
        ....
        myRollout.myXControl.Add()
        ....
      )
     
      etc. ...
     
     rollout myRollout ...
     (
        ....
        group "Output"
         (
           activeXControl myXControl "MSComctlLib.ListViewCtrl" height:400 
         )
          
        ....
     )

If that doesn’t work, you may need to actually declare your rollout in its entirety first.

RH

thank you. Haven’t done much mxs stuff for a while – so I guess I got rusty regarding these topics.
Though I wasn’t able to access it via the global rollout, I went thourgh the global declared floater: floater->rollout->control

cheers
dom