在一个对话框上加了一个CWebBrowser2。
====
void CVerifyCodeDlg::OnButtonTest2()
{
......
// 获得Html文档指针
IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );
......}
编译的时候老是出错:
error C2065: 'IHTMLElement2' : undeclared identifier
====
void CVerifyCodeDlg::OnButtonTest2()
{
......
// 获得Html文档指针
IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );
......}
编译的时候老是出错:
error C2065: 'IHTMLElement2' : undeclared identifier
解决方案 »
- select返回1后,fd_isset返回0
- 数码相机取景器编程,怎么判断旋转角度,并使取景器中的图像自动旋转
- 事件对象,同一程序,打开2个实例,资源释放的问题.
- GDI+问题 难!无人能答
- 急!!!用fopen打开一个bmp文件后如何取得该文件中的一些重要信息?
- """"""""""""""""""""怎样创建*.BIN文件? 谢谢!!""""""""""""""""
- 怎样把双字节的字符串转化成单字节的字符串?
- VS2005关联控件问题,求高人指点
- CDateTimeCtrl如何重绘,请各位大哥大姐给与提示和帮助
- 如何在VC 6.0中使用新的SDK?
- 问个简单问题,有关EM_GETSEL和EM_SETSEL的
- 关于变量的定义
#include <mshtml.h>
#include <atlbase.h>
#include <oleacc.h>
如何从 HWND 获取 IHTMLDocument 2
#include <mshtml.h>
#include <atlbase.h>
#include <oleacc.h>BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
TCHAR buf[100]; ::GetClassName( hwnd, (LPTSTR)&buf, 100 );
if ( _tcscmp( buf, _T("Internet Explorer_Server") ) == 0 )
{
*(HWND*)lParam = hwnd;
return FALSE;
}
else
return TRUE;
};//You can store the interface pointer in a member variable
//for easier access
void CDlg::OnGetDocInterface(HWND hWnd)
{
CoInitialize( NULL ); // Explicitly load MSAA so we know if it's installed
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
if ( hInst != NULL )
{
if ( hWnd != NULL )
{
HWND hWndChild=NULL;
// Get 1st document window
::EnumChildWindows( hWnd, EnumChildProc, (LPARAM)&hWndChild );
if ( hWndChild )
{
CComPtr<IHTMLDocument2> spDoc;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes ); LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
if ( pfObjectFromLresult != NULL )
{
HRESULT hr;
hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc );
if ( SUCCEEDED(hr) )
{
CComPtr<IDispatch> spDisp;
CComQIPtr<IHTMLWindow2> spWin;
spDoc->get_Script( &spDisp );
spWin = spDisp;
spWin->get_document( &spDoc.p );
// Change background color to red
spDoc->put_bgColor( CComVariant("red") );
}
}
} // else document not ready
} // else Internet Explorer is not running
::FreeLibrary( hInst );
} // else Active Accessibility is not installed
CoUninitialize();
}
这3个头文件都包含了啊。不知道怎么回事。我用VC 6.0
代码没贴对...
你上面的代码中没这个
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ 然后注意Tools->Options->Directories中的顺序。把include/lib设置中的sdk目录放到最前面