Soul_Eater
October 21st, 2004, 04:15 AM
goin a little nuts.
The following headers are included:
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#pragma comment(lib, "comctl32.lib")
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
#include <commctrl.h>
#include <windef.h>
#include <mshtml.h>
#include <atlbase.h>
#include <oleacc.h>
#import <shdocvw.dll>
Ok, in my code, I can't get the IHTMLDocument2 to navigate(if im doing something wrong tell me), so I'm trying to do it via Iwebbrowser2, and I'm getting compile errors. Someone please tell me whats wrong, thanks:
HWND web = FindWindowEx(shelldoc,NULL,"Internet Explorer_Server",NULL);
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
CComPtr<IHTMLDocument2> spDoc;
CComPtr<IWebBrowser2> pwb2;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( web, 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") );
spWin->navigate((BSTR)"http://www.codeguru.com");
ObjectFromLresult(lRes, IID_IHTMLDocument, 0, (void**)&pwb2);
pwb2->Navigate((BSTR)"http://www.codeguru.com",NULL,NULL,NULL,NULL);
}
}
::FreeLibrary( hInst );
CoUninitialize();
These are my errors:
error C2039: 'Navigate' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IWebBrowser2>'
error C2504: 'IWebBrowser2' : base class undefined see reference to class template instantiation 'ATL::_NoAddRefReleaseOnCComPtr<struct IWebBrowser2>' being compiled
The following headers are included:
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#pragma comment(lib, "comctl32.lib")
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
#include <commctrl.h>
#include <windef.h>
#include <mshtml.h>
#include <atlbase.h>
#include <oleacc.h>
#import <shdocvw.dll>
Ok, in my code, I can't get the IHTMLDocument2 to navigate(if im doing something wrong tell me), so I'm trying to do it via Iwebbrowser2, and I'm getting compile errors. Someone please tell me whats wrong, thanks:
HWND web = FindWindowEx(shelldoc,NULL,"Internet Explorer_Server",NULL);
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
CComPtr<IHTMLDocument2> spDoc;
CComPtr<IWebBrowser2> pwb2;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( web, 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") );
spWin->navigate((BSTR)"http://www.codeguru.com");
ObjectFromLresult(lRes, IID_IHTMLDocument, 0, (void**)&pwb2);
pwb2->Navigate((BSTR)"http://www.codeguru.com",NULL,NULL,NULL,NULL);
}
}
::FreeLibrary( hInst );
CoUninitialize();
These are my errors:
error C2039: 'Navigate' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IWebBrowser2>'
error C2504: 'IWebBrowser2' : base class undefined see reference to class template instantiation 'ATL::_NoAddRefReleaseOnCComPtr<struct IWebBrowser2>' being compiled