Using DsoFramer.OCX
-
Hi all, I have downloaded dsoframer.ocx ..... It is full of OLE / COM code. and i am newer to these interfaces and such activXcontrols..... What i am doing. i am trying to load office document ( from local file / from memory HGLOBAL ) into DsoFramer control placed in dialog based MFC application. Then after loading document , i want to disable keydown,on char,key up and right mouse button down. so that user cannt modify content. ( like viewer only.) I have debugged and put messagebox in source code but with no luck. I want to know where can i handle such win messages.? Does any other interface i need to add or implement? I am able to get such message in CDsoFramerControl::ControlWindowProc() but when NO Document is loaded.? Why? I have looked to windows with SPY++ i found that there are more windows handle underbeneth so is that i problem why i dont get any aforesaid messages.? Any help is greatly appreciated. Thank in advance. Regards Jetli Jetli conclusion means Coming to wrong Decision with confidence
-
Hi all, I have downloaded dsoframer.ocx ..... It is full of OLE / COM code. and i am newer to these interfaces and such activXcontrols..... What i am doing. i am trying to load office document ( from local file / from memory HGLOBAL ) into DsoFramer control placed in dialog based MFC application. Then after loading document , i want to disable keydown,on char,key up and right mouse button down. so that user cannt modify content. ( like viewer only.) I have debugged and put messagebox in source code but with no luck. I want to know where can i handle such win messages.? Does any other interface i need to add or implement? I am able to get such message in CDsoFramerControl::ControlWindowProc() but when NO Document is loaded.? Why? I have looked to windows with SPY++ i found that there are more windows handle underbeneth so is that i problem why i dont get any aforesaid messages.? Any help is greatly appreciated. Thank in advance. Regards Jetli Jetli conclusion means Coming to wrong Decision with confidence
Hi Jetli, What you are missing here is OLE automation, once you have loaded the document inside DSOFramer activex control. You should query for IDispatch pointer of embeeded active document. Once you have IDispatch you can start automating that active document. (OLE automation is meaning the same, control the functionality of the application !) hmmm... to disable the right click and typing etc see the methods expose by that active document IDispatch interface. You can use the utility provided by MS "OLE/COM Object Viewer" to see all the methods expose by the that application. As I remember for "MS-Word" you can disable the typing using the "protect" method expose by word. And for right click search on "CommandBars". I think its sufficient information ! :) Enjoy ! Cheers, Vishal
-
Hi Jetli, What you are missing here is OLE automation, once you have loaded the document inside DSOFramer activex control. You should query for IDispatch pointer of embeeded active document. Once you have IDispatch you can start automating that active document. (OLE automation is meaning the same, control the functionality of the application !) hmmm... to disable the right click and typing etc see the methods expose by that active document IDispatch interface. You can use the utility provided by MS "OLE/COM Object Viewer" to see all the methods expose by the that application. As I remember for "MS-Word" you can disable the typing using the "protect" method expose by word. And for right click search on "CommandBars". I think its sufficient information ! :) Enjoy ! Cheers, Vishal
Hi Vishal Many thanks to you. vishalmore wrote: What you are missing here is OLE automation, once you have loaded the document inside DSOFramer activex control. You should query for IDispatch pointer of embeeded active document. Once you have IDispatch you can start automating that active document. (OLE automation is meaning the same, control the functionality of the application !) above is new for me.... THANKS A LOT ... i have tried to get IDispatch and also played with some of methods by looking in OLE viewer. I would like to show how i have done this :
LPDISPATCH lpDisp = m_shControl.GetActiveDocument(); DISPID dispid; OLECHAR FAR* szFunction; szFunction = OLESTR("Protect"); //DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; // parameter structure DISPPARAMS dispparams; // one-element array of parameter names DISPID mydispid[1] = { DISP_PROPERTYPUT }; // one-element array of parameters VARIANTARG vararg[1]; dispparams.rgvarg = vararg; // 1-element array VariantInit(&dispparams.rgvarg[0]); dispparams.rgvarg[0].vt = VT_I4; // 32-bit integerwdAllowOnlyRevisions dispparams.rgvarg[0].iVal =2 ; dispparams.rgdispidNamedArgs = mydispid; // name array dispparams.cArgs = 1; // total args dispparams.cNamedArgs =1; // named args HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid); hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
"protect" property doesnot disable typing.. "Commandbars" is for toolbard floating in word window. ( which i can control via Dsoframer control. Is there any property / suggestion for doing this? Again Thanks In advance Jetli conclusion means Coming to wrong Decision with confidence -
Hi Vishal Many thanks to you. vishalmore wrote: What you are missing here is OLE automation, once you have loaded the document inside DSOFramer activex control. You should query for IDispatch pointer of embeeded active document. Once you have IDispatch you can start automating that active document. (OLE automation is meaning the same, control the functionality of the application !) above is new for me.... THANKS A LOT ... i have tried to get IDispatch and also played with some of methods by looking in OLE viewer. I would like to show how i have done this :
LPDISPATCH lpDisp = m_shControl.GetActiveDocument(); DISPID dispid; OLECHAR FAR* szFunction; szFunction = OLESTR("Protect"); //DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; // parameter structure DISPPARAMS dispparams; // one-element array of parameter names DISPID mydispid[1] = { DISP_PROPERTYPUT }; // one-element array of parameters VARIANTARG vararg[1]; dispparams.rgvarg = vararg; // 1-element array VariantInit(&dispparams.rgvarg[0]); dispparams.rgvarg[0].vt = VT_I4; // 32-bit integerwdAllowOnlyRevisions dispparams.rgvarg[0].iVal =2 ; dispparams.rgdispidNamedArgs = mydispid; // name array dispparams.cArgs = 1; // total args dispparams.cNamedArgs =1; // named args HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid); hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
"protect" property doesnot disable typing.. "Commandbars" is for toolbard floating in word window. ( which i can control via Dsoframer control. Is there any property / suggestion for doing this? Again Thanks In advance Jetli conclusion means Coming to wrong Decision with confidenceHi Jetli, Your code sounds gud to be gud to me. Jetli Quoted : "protect" property doesnot disable typing.. 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 ? ;) Well "Protect" method disables the typing in word document(I am very sure on this), have you check the return code in your automation routine for "protect" method ? Jetli Quoted : "Commandbars" is for toolbard floating in word window. ( which i can control via Dsoframer control. Is there any property / suggestion for doing this? Word context menus are comes under the category of "CommandBars" only, you can disable the context menus in following manner ... 1.)Get IDispatch for embeeded Active Document. 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 :) ) 3.)Now invoke the "Enabled" method using this disp ptr. This method takes 1 param of type BOOL. My suggestion is that put all the above three steps in one for/while loop. That's Context menus are disabled ! :) All the very best ! :cool: Cheers, Vishal
-
Hi Jetli, Your code sounds gud to be gud to me. Jetli Quoted : "protect" property doesnot disable typing.. 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 ? ;) Well "Protect" method disables the typing in word document(I am very sure on this), have you check the return code in your automation routine for "protect" method ? Jetli Quoted : "Commandbars" is for toolbard floating in word window. ( which i can control via Dsoframer control. Is there any property / suggestion for doing this? Word context menus are comes under the category of "CommandBars" only, you can disable the context menus in following manner ... 1.)Get IDispatch for embeeded Active Document. 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 :) ) 3.)Now invoke the "Enabled" method using this disp ptr. This method takes 1 param of type BOOL. My suggestion is that put all the above three steps in one for/while loop. That's Context menus are disabled ! :) All the very best ! :cool: Cheers, Vishal
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_U
-
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_U
Hi Jetli, hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT | DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); Look at the code closly, the 4th parameter. It should be either DISPATCH_PROPERTYPUT OR DISPATCH_METHOD OR DISPATCH_PROPERTYGET In your case it should be DISPATCH_METHOD One more sugestion you should always use the 2nd last parameter i.e EXCEPINFO. Its ease the life ... ;) Hope things are settled down ... :-D Cheers, Vishal
-
Hi Jetli, hr = lpDisp->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT | DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); Look at the code closly, the 4th parameter. It should be either DISPATCH_PROPERTYPUT OR DISPATCH_METHOD OR DISPATCH_PROPERTYGET In your case it should be DISPATCH_METHOD One more sugestion you should always use the 2nd last parameter i.e EXCEPINFO. Its ease the life ... ;) Hope things are settled down ... :-D Cheers, Vishal
Hi Vishal, Thanks for prompt reply. I have tried with Only DISPATCH_METHOD before and also now after you have said. And also Put EXCEPINFO ex; and &ex in 2nd last param.... but it contain nothing after failure.... hr=0x80020003:Member Not found for CommandBar/Enable case while hr=TypeMismatch errror for protect method is still commingg I am really thankful for yr help and yr patience. But bcoz of not haveing proper base i am asking bit more from you. Once Again Thanks:rose: Jetli conclusion means Coming to wrong Decision with confidence
-
Hi Vishal, Thanks for prompt reply. I have tried with Only DISPATCH_METHOD before and also now after you have said. And also Put EXCEPINFO ex; and &ex in 2nd last param.... but it contain nothing after failure.... hr=0x80020003:Member Not found for CommandBar/Enable case while hr=TypeMismatch errror for protect method is still commingg I am really thankful for yr help and yr patience. But bcoz of not haveing proper base i am asking bit more from you. Once Again Thanks:rose: Jetli conclusion means Coming to wrong Decision with confidence
Hmmm... I think you should read more on OLE automation ... As far as this problem is consern, I am out of ideas ! :| Cheers, Vishal
-
Hmmm... I think you should read more on OLE automation ... As far as this problem is consern, I am out of ideas ! :| Cheers, Vishal
Hi Vishal I am able to excute protect:-D Here Is Working Code.... LPDISPATCH lpDisp = m_shControl.GetActiveDocument(); EXCEPINFO ex; OLECHAR FAR* szFunction; DISPID dispid; szFunction = OLESTR("Protect"); HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1,LOCALE_USER_DEFAULT, &dispid); //dispid = 0x00000078 // Protect type,noreset,pass ,,,,,, Pass Ole in Reverse Order VARIANT vArgs[3]; DISPPARAMS dpP; dpP.cArgs = 3; dpP.cNamedArgs = 0; dpP.rgvarg = vArgsSaveAs; VARIANT vOpt; vOpt.vt = VT_ERROR; vOpt.scode = DISP_E_PARAMNOTFOUND; vArgsSaveAs[2].vt = VT_I4; vArgsSaveAs[2].lVal = 1; vArgsSaveAs[1] = vOpt; vArgsSaveAs[0] = vOpt; hr = lpDisp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dpP, NULL, &ex, NULL); And I am able to eat keystrokes via protection....:laugh: As Far As CommandBars I have looked a bit.... I found Commandbar Property returns commandbar collection and error i was getting becoz "member not found" i guess it was becoz of not having appropriate Dispatch ptr. Another thing i am not able to find Commandbars ( and also CommandBars Collection) Interface and its properties.. In OLe Viewer..... Any Ideas? If you can give me some MORE info on 3 steps for disabling context menu... I will really appericiate..... But Once Again Many Many Thanks To You. Jetli conclusion means Coming to wrong Decision with confidence
-
Hi Vishal I am able to excute protect:-D Here Is Working Code.... LPDISPATCH lpDisp = m_shControl.GetActiveDocument(); EXCEPINFO ex; OLECHAR FAR* szFunction; DISPID dispid; szFunction = OLESTR("Protect"); HRESULT hr = lpDisp->GetIDsOfNames (IID_NULL, &szFunction, 1,LOCALE_USER_DEFAULT, &dispid); //dispid = 0x00000078 // Protect type,noreset,pass ,,,,,, Pass Ole in Reverse Order VARIANT vArgs[3]; DISPPARAMS dpP; dpP.cArgs = 3; dpP.cNamedArgs = 0; dpP.rgvarg = vArgsSaveAs; VARIANT vOpt; vOpt.vt = VT_ERROR; vOpt.scode = DISP_E_PARAMNOTFOUND; vArgsSaveAs[2].vt = VT_I4; vArgsSaveAs[2].lVal = 1; vArgsSaveAs[1] = vOpt; vArgsSaveAs[0] = vOpt; hr = lpDisp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dpP, NULL, &ex, NULL); And I am able to eat keystrokes via protection....:laugh: As Far As CommandBars I have looked a bit.... I found Commandbar Property returns commandbar collection and error i was getting becoz "member not found" i guess it was becoz of not having appropriate Dispatch ptr. Another thing i am not able to find Commandbars ( and also CommandBars Collection) Interface and its properties.. In OLe Viewer..... Any Ideas? If you can give me some MORE info on 3 steps for disabling context menu... I will really appericiate..... But Once Again Many Many Thanks To You. Jetli conclusion means Coming to wrong Decision with confidence
Damm... I was aware of this thing, that parameters should passed in reverse order. Nways good to hear that u finaly done it ! See the pseduo code for context menus prob: VARIANT v1,v2,v3; While( i > 88) { v1.vt = VT_I4; v1.lVal = i; Invoke(pDispWord,"CommandBars",0,DISPATCH_PROPERTYGET,1,v1,v2) v3.vt = VT_BOOL; v3.boolVal = 0; Invoke(v2.pdispVal,"Enabled",0,DISPATCH_PROPERTYPUT,1,v3,NULL); i++; } That's al ! Gud luck ! Cheers, Vishal