none
Application Visible RRS feed

  • Question

  • I'm creating a Word 2007 instance from unmanaged C++. The Code looks like this:

    IDispatchPtr spIWord;
    CComDispatchDriver spDispWord;
    CLSID clsidWordApplication;  
    
    hr = CLSIDFromProgID(L"Word.Application", &clsidWordApplication);
    
    if (SUCCEEDED(hr))
    {
       hr = CoCreateInstance(clsidWordApplication, NULL, CLSCTX_SERVER, IID_IDispatch, (void **) (IDispatch *) &spIWord);
    
       if (SUCCEEDED(hr) && (spIWord != NULL))
       { 
         spDispWord.Attach(spIWord);
        
         // ...
       }
    }
    

    After creating the instance Word is not visible, everything is fine.

    Now I'm doing the same with Visio 2007.

    IDispatchPtr spIWord;
    CComDispatchDriver spDispWord;
    CLSID clsidWordApplication;  
    
    hr = CLSIDFromProgID(L"Visio.Application", &clsidWordApplication);
    
    if (SUCCEEDED(hr))
    {
       hr = CoCreateInstance(clsidWordApplication, NULL, CLSCTX_SERVER, IID_IDispatch, (void **) (IDispatch *) &spIWord);
    
       if (SUCCEEDED(hr) && (spIWord != NULL))
       { 
         spDispWord.Attach(spIWord);
        
         DISPID dispidVisible = 0;
         VARIANT vParam;
         vParam.vt = VT_BOOL;
         vParam.boolVal = VARIANT_FALSE;
         hr = spDispWord.GetIDOfName(L"Visible", &dispidVisible);
         hr = spDispWord.PutProperty(dispidVisible, &vParam);
    
         // ...
       }
    }
    
    

    But after creating the instance, Visio is visible. Even if I set the "Visible" property to false, the application is still visible for about a second (time between CreateInstance and PutProperty).

    How do I get the same behavior with Visio, like with Word?

    Monday, November 15, 2010 10:17 AM

Answers

  • Not really my area, but instead of

    Visio.Application

    you may be able to use 

    Visio.InvisibleApp


    Peter Jamieson
    • Marked as answer by IjonTichy Monday, November 15, 2010 2:08 PM
    Monday, November 15, 2010 12:22 PM