Click here to Skip to main content
15,878,543 members
Home / Discussions / COM
   

COM

 
GeneralImporting C# methods Pin
Fragging7-Feb-05 2:19
Fragging7-Feb-05 2:19 
GeneralRe: Importing C# methods Pin
Fragging28-Feb-05 3:10
Fragging28-Feb-05 3:10 
GeneralRe: Importing C# methods Pin
MichaelLeslie30-Apr-08 12:20
MichaelLeslie30-Apr-08 12:20 
GeneralUsing DsoFramer.OCX Pin
Jetli Jerry5-Feb-05 2:57
Jetli Jerry5-Feb-05 2:57 
GeneralRe: Using DsoFramer.OCX Pin
vishalmore7-Feb-05 19:53
vishalmore7-Feb-05 19:53 
GeneralRe: Using DsoFramer.OCX Pin
Jetli Jerry9-Feb-05 0:13
Jetli Jerry9-Feb-05 0:13 
GeneralRe: Using DsoFramer.OCX Pin
vishalmore9-Feb-05 1:11
vishalmore9-Feb-05 1:11 
GeneralRe: Using DsoFramer.OCX Pin
Jetli Jerry11-Feb-05 1:55
Jetli Jerry11-Feb-05 1:55 
Hi Vishal,


Many Thanks To You.....
But unfortunately i am still not able to do.... I need further help
I have done what u have said and tried things tooo .. but with no luck...
I have placed code as per your last reply...


>>One possible mistake you have done is this
>>dispparams.rgvarg[0].iVal = 2 ;
>>It should be dispparams.rgvarg[0].lVal = 1 ;
>>You are saying that dispparams.rgvarg[0].vt = VT_I4; and storing short value in long ?

i have corrected it......but still having same problem

// Again my revised code to look at
LPDISPATCH lpDisp = m_shControl.GetActiveDocument();
DISPID dispid;
OLECHAR FAR* szFunction;
szFunction = OLESTR("Protect");
DISPPARAMS dispparams;
DISPID mydispid = { DISPID_PROPERTYPUT };

// wdAllowOnlyComments=1// wdAllowOnlyRevisions=0,// wdAllowOnlyFormFields=2
//CComVariant vrProtecttionType((long)0);//1

VARIANTARG vararg[1];
dispparams.rgvarg = vararg; // 1-element array
VariantInit(&dispparams.rgvarg[0]);
dispparams.rgvarg[0].vt = VT_I4;
dispparams.rgvarg[0].lVal=1 ;

//dispparams.rgvarg=&vrProtecttionType ;
dispparams.cArgs=1;
dispparams.rgvarg=vararg ;
dispparams.cNamedArgs=1;
dispparams.rgdispidNamedArgs=&mydispid;

HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1,LOCALE_USER_DEFAULT, &dispid);
//dispid = 0x00000078
hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUT |DISPATCH_METHOD, &dispparams, NULL, NULL,
NULL);
//hr=0x80020005: Type Mismatch


>>have you check the return code in your automation routine for "protect" method ?
//hr=0x80020005: Type Mismatch

you can disable the context menus in following manner ...

>>1.)Get IDispatch for embeeded Active Document.
LPDISPATCH lpDisp = m_shControl.GetActiveDocument();

>>2.)Ask IDispatch for DISPATCH_PROPERTYGET - "CommandBars", it will return disp ptr for CommandBars. This property takes one

param i.e. nothing but id of that command bar (in word id for context menus starts from 38)
(you can use VBA to check the codes for these context menus for different office version )

DISPID dispid;
OLECHAR FAR* szFunction;
szFunction = OLESTR("CommandBars");
// parameter structure
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
CComVariant vrTrue = (long)38;
dispparamsNoArgs.cArgs = 1;
dispparamsNoArgs.rgvarg = &vrTrue;
dispparamsNoArgs.cNamedArgs = 0;
dispparamsNoArgs.rgdispidNamedArgs = NULL;

HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid);
//dispid 0x39
VARIANT vOut;
VariantInit(&vOut);

LPDISPATCH pCommandBarDispatch;
hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vOut, NULL,
NULL);
//hr=S_OK


>>3.)Now invoke the "Enabled" method using this disp ptr. This method takes 1 param of type BOOL.

pCommandBarDispatch = vOut.pdispVal;
OLECHAR FAR* szStr;
szStr = OLESTR("Enabled");
DISPID dispid1;
hr = pCommandBarDispatch->GetIDsOfNames(IID_NULL,&szStr,1,LOCALE_USER_DEFAULT,&dispid1);
//dispid1=0x60040005
DISPPARAMS dispParams = { NULL, NULL, 0, 0 };
DISPID dispidNamed = DISPID_PROPERTYPUT;

//CComVariant vrId(VARIANT_FALSE); (also tried)
VARIANTARG vararg[1];
dispParams.rgvarg = vararg; // 1-element array
VariantInit(&dispParams.rgvarg[0]);
dispParams.rgvarg[0].vt = VT_BOOL;
dispParams.rgvarg[0].boolVal =VARIANT_FALSE;

dispParams.cArgs = 1;
dispParams.rgvarg = &vrId;
dispParams.cNamedArgs = 1;
dispParams.rgdispidNamedArgs = &dispidNamed;

hr = pCommandBarDispatch->Invoke(dispid,IID_NULL,LOCALE_USER_DEFAULT,DISPATCH_PROPERTYGET

|DISPATCH_METHOD,&dispparamsNoArgs,NULL,NULL,NULL);
// hr=0x80020003:Member Not found


Once Again Many thanks To You
Thanks In Advance...

Jetli
conclusion means Coming to wrong Decision with confidence
GeneralRe: Using DsoFramer.OCX Pin
vishalmore11-Feb-05 2:09
vishalmore11-Feb-05 2:09 
GeneralRe: Using DsoFramer.OCX Pin
Jetli Jerry11-Feb-05 2:51
Jetli Jerry11-Feb-05 2:51 
GeneralRe: Using DsoFramer.OCX Pin
vishalmore13-Feb-05 19:47
vishalmore13-Feb-05 19:47 
GeneralRe: Using DsoFramer.OCX Pin
Jetli Jerry13-Feb-05 20:20
Jetli Jerry13-Feb-05 20:20 
GeneralRe: Using DsoFramer.OCX Pin
vishalmore13-Feb-05 22:44
vishalmore13-Feb-05 22:44 
GeneralCOM DLL instantiated twice Pin
Pascal Pinchauret-Lamothe4-Feb-05 4:33
Pascal Pinchauret-Lamothe4-Feb-05 4:33 
GeneralRe: COM DLL instantiated twice Pin
rwestgraham6-Feb-05 11:50
rwestgraham6-Feb-05 11:50 
GeneralRe: COM DLL instantiated twice Pin
Pascal Pinchauret-Lamothe6-Feb-05 20:41
Pascal Pinchauret-Lamothe6-Feb-05 20:41 
GeneralRe: COM DLL instantiated twice Pin
rwestgraham7-Feb-05 0:22
rwestgraham7-Feb-05 0:22 
GeneralRe: COM DLL instantiated twice Pin
Pascal Pinchauret-Lamothe7-Feb-05 21:33
Pascal Pinchauret-Lamothe7-Feb-05 21:33 
GeneralRe: COM DLL instantiated twice Pin
rwestgraham8-Feb-05 9:02
rwestgraham8-Feb-05 9:02 
GeneralRe: COM DLL instantiated twice Pin
Pascal Pinchauret-Lamothe8-Feb-05 10:57
Pascal Pinchauret-Lamothe8-Feb-05 10:57 
GeneralRe: COM DLL instantiated twice Pin
engrx221-Sep-07 5:41
engrx221-Sep-07 5:41 
GeneralQuestion about [in, out] parameters Pin
AndyCheetham4-Feb-05 2:43
AndyCheetham4-Feb-05 2:43 
GeneralRe: Question about [in, out] parameters Pin
Mike Dimmick7-Feb-05 0:00
Mike Dimmick7-Feb-05 0:00 
GeneralRe: Question about [in, out] parameters Pin
Jörgen Sigvardsson8-Feb-05 9:55
Jörgen Sigvardsson8-Feb-05 9:55 
GeneralCOM + several classes Pin
Geert van Horrik3-Feb-05 22:52
Geert van Horrik3-Feb-05 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.