Re: CHtmlView OLECMDID_PRINT CreateControlSite
- From: "Sheng Jiang[MVP]" <sheng_jiang@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Aug 2007 16:37:39 -0500
even you load your BHO, you still can not access the IE control site,
because it is in the IE, not in your webbrowser control.
"AmitSharma" <amit_sharma@xxxxxxxxxxxxxxxxxxxxxxxxx> дÈëÏûÏ¢ÐÂÎÅ:8C8A7723-03E9-45DD-9C1E-FE295C712BE0@xxxxxxxxxxxxxxxx
I have been trying since last 14 days now. i think i have tried returning
all
types of value but to no result. Now i am trying to find a way to have BHO
attached to my CHtmlView based Browser. If you can help me on this or give
me
a better solution,
it would be gr8 og u.
--
Thanx
"Sheng Jiang[MVP]" wrote:
OLECMDERR_E_UNKNOWNGROUP or OLECMDERR_E_NOTSUPPORTED means the command
can
not be executed. I think you need to return E_NOTIMPL or something.
You have no access to the IE host of the webbrowser control because you
are
replacing it with your host.
--
Sheng Jiang
Microsoft MVP in VC++
"AmitSharma" <amit_sharma@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA0C54D3-A7CC-44B4-B0ED-0A1C549CB268@xxxxxxxxxxxxxxxx
Hi All,derived
Please help on to bring up the print dialog when implementing the
Custom
control site to suprress/handle the script error I have a CHtmlView
class. When I use the custom site, I can't get a print dialog when Ithe
press
Ctrl+P. if I remove that I am able to bring up the print dialog. I need
custom site to handle script errors in OLECMDID_SCRIPTERROR...0);
Pl look at the below code and a solution would be a gr8 help, i have
been
trying this since last 10 days...
BOOL CTestPrint_HtmlViewView::CreateControlSite(COleControlContainer*
pContainer,
COleControlSite** ppSite, UINT /* nID */, REFCLSID /* clsid */)
{
ASSERT(ppSite != NULL);
// when the below line is commented, On Ctrl+P the Print dialog is
invoked
*ppSite = new CMyHtmlControlSite(pContainer);
return TRUE;
}
void CTestPrint_HtmlViewView::OnFilePrint()
{
HRESULT hr;
CComPtr<IHTMLDocument2> spDoc = (IHTMLDocument2*)
GetHtmlDocument();
if (spDoc != NULL)
{
CComQIPtr<IOleCommandTarget> spCmdTarget = spDoc;
if (spCmdTarget != NULL)
{
hr = spCmdTarget->Exec(NULL,
OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT, 0, 0);
}
}
//Also tried with this->ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DODEFAULT,
0,
}nCmdID,0,
STDMETHODIMP CMyHtmlControlSite::XOleCommandTarget::Exec(const GUID*
pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG* pvaIn,
VARIANTARG* pvaOut )
{
METHOD_PROLOGUE_EX_(CMyHtmlControlSite, OleCommandTarget)
HRESULT hr = S_OK;
if (pguidCmdGroup && IsEqualGUID(*pguidCmdGroup,
CGID_DocHostCommandHandler))
{
switch (nCmdID)
{
case OLECMDID_PRINT:
{
//return S_OK;//1 or any value doesnt bring the print dialog
//if we do the below, It falls in the same case ITS A KIND OF RECURSIVE
CALL
CComQIPtr<IOleCommandTarget> pCmdTarget = pThis->GetIDispatch(TRUE);
if (pCmdTarget != NULL)
{
hr = pCmdTarget->Exec(pguidCmdGroup,
NULL, NULL);fContinueRunningScripts
return hr;
}
}
//is required to handle/supress script error
case OLECMDID_SHOWSCRIPTERROR:
{
IHTMLDocument2* pDoc = NULL;
IHTMLWindow2* pWindow = NULL;
IHTMLEventObj* pEventObj = NULL;
BSTR rgwszNames[5] =
{
SysAllocString(L"errorLine"),
SysAllocString(L"errorCharacter"),
SysAllocString(L"errorCode"),
SysAllocString(L"errorMessage"),
SysAllocString(L"errorUrl")
};
DISPID rgDispIDs[5];
VARIANT rgvaEventInfo[5];
DISPPARAMS params;
BOOL
= true;viewed.
int i;
params.cArgs = 0;
params.cNamedArgs = 0;
// Get the document that is currently being
hr =object.
pvaIn->punkVal->QueryInterface(IID_IHTMLDocument2, (void **)
&pDoc);
// Get document.parentWindow.
hr = pDoc->get_parentWindow(&pWindow);
pDoc->Release();
// Get the window.event object.
hr = pWindow->get_event(&pEventObj);
// Get the error info from the window.event
for (i = 0; i < 5; i++)user
{
// Get the property's dispID.
hr = pEventObj->GetIDsOfNames(IID_NULL,
&rgwszNames[i], 1,
LOCALE_SYSTEM_DEFAULT,
&rgDispIDs[i]);
// Get the value of the property.
hr = pEventObj->Invoke(rgDispIDs[i],
IID_NULL,LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, ¶ms,
&rgvaEventInfo[i],NULL, NULL);
SysFreeString(rgwszNames[i]);
}
// At this point, you would normally alert the
withon
// the information about the error, which is
now
contained
// in rgvaEventInfo[]. Or, you could just exit
silently.
(*pvaOut).vt = VT_BOOL;
break;
}
case OLECMDID_SHOWMESSAGE:
(*pvaOut).boolVal = VARIANT_TRUE;
break;
default:
hr = OLECMDERR_E_NOTSUPPORTED;
break;
}//end of switch
}
else
{
hr = OLECMDERR_E_UNKNOWNGROUP;
}
return 0L;
}
if u need more information i can provide the sample code and its
available
http://files-upload.com/files/453048/TestPrint_HtmlView.zip
i am already registered with experts-exchange but no one could provide
a
solution to this..
Thanx in advance
.
- References:
- CHtmlView OLECMDID_PRINT CreateControlSite
- From: AmitSharma
- Re: CHtmlView OLECMDID_PRINT CreateControlSite
- From: Sheng Jiang[MVP]
- Re: CHtmlView OLECMDID_PRINT CreateControlSite
- From: AmitSharma
- CHtmlView OLECMDID_PRINT CreateControlSite
- Prev by Date: Re: CHtmlView OLECMDID_PRINT CreateControlSite
- Next by Date: Where is the admin?
- Previous by thread: Re: CHtmlView OLECMDID_PRINT CreateControlSite
- Next by thread: help in Beforenavigate2
- Index(es):