15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Printing OLE control

Mike Lechner -- Mike_Lechner@msn.com
Sunday, November 03, 1996

Environment:  VC4.2b, Win95

Hello, 
I'm trying to print the contents of my CWebBrowser control, which is derived 
from CWnd.
The Microsoft documentation sez to do this:
Printing from the Web Browser Control 
Use the following steps to print the document that the Web browser control is 
currently displaying: 
	1	Retrieve the document object's IDispatch interface by calling 
IWebBrowser::get_Document. 
	2	Retrieve the document object's IOleCommandTarget interface by calling 
IDispatch::QueryInterface. 
	3	Print the document by calling IOleCommandTarget::Exec(NULL,OLECMDID_PRINT, 
OLECMDEXECOPT_DONTPROMPTUSER, NULL,NULL). This function acts as though the 
Print menu item was chosen through the user interface. 

which immediately gave me a knot in my stomach.  Here's what I tried:

void CTest2View::OnPrint(CDC* pDC, CPrintInfo*)
{
	LPDISPATCH disp = fBrowser.GetDocument ();
	if (disp) {
		IOleCommandTarget* target;
		HRESULT result = 
			disp->QueryInterface (fBrowser.GetClsid (), (void **) &target);
		if (result == S_OK)
			target->Exec (NULL, OLECMDID_PRINT,
	 				OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
		else if (result == E_NOINTERFACE)
			TRACE ("Interface not supported.\n");
	}
}

which returns E_NOINTERFACE from the QueryInterface call.  I'm rather confused 
about the relationship between classes (such as CWebBrowser) and their OLE 
interface (such as IWebBrowser).  
Can anyone shine a light my way?
Thanks, Mike
Mike_Lechner@msn.com



James Chen -- james@jcsoft.com
Friday, November 08, 1996

There is a MFC WebBrowser sample application at =
http://www.jcsoft.com/samples/jc_browser/

The sample shows how to integrate WebBrowser ActiveX into Visual C++ =
project, How to process the events and how to print and COPY the =
WebBrowser ActiveX. There are also some source annotation.

Enjoy

James
http://www.jcsoft.com


----------
From: 	Mike Lechner[SMTP:Mike_Lechner@msn.com]
Sent: 	Sunday, November 03, 1996 11:21 AM
To: 	mfc-l@netcom.com
Subject: 	Printing OLE control

Environment:  VC4.2b, Win95

Hello,=20
I'm trying to print the contents of my CWebBrowser control, which is =
derived=20
from CWnd.
The Microsoft documentation sez to do this:
Printing from the Web Browser Control=20
Use the following steps to print the document that the Web browser =
control is=20
currently displaying:=20
	1	Retrieve the document object's IDispatch interface by calling=20
IWebBrowser::get_Document.=20
	2	Retrieve the document object's IOleCommandTarget interface by calling =

IDispatch::QueryInterface.=20
	3	Print the document by calling =
IOleCommandTarget::Exec(NULL,OLECMDID_PRINT,=20
OLECMDEXECOPT_DONTPROMPTUSER, NULL,NULL). This function acts as though =
the=20
Print menu item was chosen through the user interface.=20

which immediately gave me a knot in my stomach.  Here's what I tried:

void CTest2View::OnPrint(CDC* pDC, CPrintInfo*)
{
	LPDISPATCH disp =3D fBrowser.GetDocument ();
	if (disp) {
		IOleCommandTarget* target;
		HRESULT result =3D=20
			disp->QueryInterface (fBrowser.GetClsid (), (void **) &target);
		if (result =3D=3D S_OK)
			target->Exec (NULL, OLECMDID_PRINT,
	 				OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
		else if (result =3D=3D E_NOINTERFACE)
			TRACE ("Interface not supported.\n");
	}
}

which returns E_NOINTERFACE from the QueryInterface call.  I'm rather =
confused=20
about the relationship between classes (such as CWebBrowser) and their =
OLE=20
interface (such as IWebBrowser). =20
Can anyone shine a light my way?
Thanks, Mike
Mike_Lechner@msn.com




| Вернуться в корень Архива |