ActiveX problem

We have created an ActiveX program in Visual Basic (6) for one of our gadgets, but while the activex control is running, it's not possible to interact with the gadget. Unfortunately, the ActiveX control runs for around 5 seconds, so I can't see this being such a good idea as an end-user gadget *grin*

Is there a way to make the ActiveX control run asynchronously Does anyone know how to do it in VB6

Thanks in advance for the help.

Andy




Answer this question

ActiveX problem

  • Northern Rob

    Jonathan Abbott wrote:
    You can give control back as previously suggested, run the ActiveX through a timer. Sidebar isn't multithreaded very well, so it's still not going to give total control back though.

    D'oh, I wish there were an easier way! thanks for the help, Jonathan, but I think I'm gonna give up on it for a while until I've read some really thick books :)

    Andy



  • leonlai

    Another problem, I want my Gadget to check to see if the ActiveX control is registered. I tried your script to register the ActiveX control automatically, Jonathan, but it doesn't seem to work with RC2.

    I have a try/catch statement around where I call my ActiveX control, as follows:

    try { 
    var activeCon = new ActiveXObject("MyActiveX.Class");
    } catch (e) {
    System.Debug.outputString(e.message + "-" + e.description);
    }

    Anyone know what the deal is with that

    Andy E



  • Nimble

    Translate all HKCR registry entries to HKCU/HKLM format. ie

    <root>\Software\Classes

    HKCR is a combination of HKLM\Software\Classes with HKCU\Software\Classes overlayed.

  • Lostlogic

    You can give control back as previously suggested, run the ActiveX through a timer. Sidebar isn't multithreaded very well, so it's still not going to give total control back though.

    The fact you need it to "run when it runs" doesn't matter. Just implement a semaphore which your code can check on another timer event. Use ByRef in the VB definition, and just set it to true when your VB code has finished. eg:

    var semaphore;
    var checkTimerID;

    function myFunction() {
    // Setup code for ActiveX call
    ...
    // Clear the semaphore and initialize the timers
    semaphore = false;
    window.setTimeout(callActiveX, 500);
    checkTimerID = window.setInterval(checkSemaphore, 200);
    }


    function callActiveX() {
    // Call the ActiveX function
    myCOM.myFunction(semaphore);
    }


    function checkSemaphore(() {
    if (!semaphore) return;

    window.clearTimeout(checkTimerID);
    // ActiveX has done it's thing, now do something with the result
    }

    The only other solution is to switch to C++ and implement a callback function. Have a look a Bruce's sidebarAlert which uses a callback to call a Javascript function when something happens externally.

  • CezaryK

    You mean a timer in the gadget, or a timer in the VB code It wouldn't be practical to add a timer to the gadget. We need the ActiveX control to run when it runs, but still allow access to the gadget.

    I'll admit, I'm not really a VB expert. I'll also admit that I wasn't the person who created the ActiveX control and, unfortunately, he's not an expert either. I had the idea of adding a timer to the ActiveX control but I don't really know how to do it and neither does he.

    Andy



  • DadUnit

    Is it not possible to kick off a timer and do what you are doing That way, the activex gets a chance to process user events as well as do it's own stuff
  • Mike Batton

    Finally got it working. Many thanks (again), Jonathan.

    Andy


  • Kosmo007

    I'm not too sure... I'll try it again. If it works for you, it should work for me, right BTW, there are keys in HKCR, too - do I need to add those

    Andy



  • EastShores

    So long as you have all the reg entries, it should work. I use it in Media Player and another with no problems.

    What's the problem Is it failing in both HKCU and HKLM

  • ActiveX problem