// Is this the DocumentComplete event for the top frame window?
// Check COM identity: compare IUnknown interface pointers.
hr = m_pBrowser->QueryInterface(IID_IUnknown, (void**)&pUnkBrowser);
if (SUCCEEDED(hr))
{
hr = pDisp->QueryInterface(IID_IUnknown, (void**)&pUnkDisp);
if (SUCCEEDED(hr))
{
if (pUnkBrowser == pUnkDisp)
{
// This is the DocumentComplete event for the top frame.
// This page is loaded, so we can access the DHTML Object Model.
hr = m_pBrowser->get_Document(&pDocDisp);
if (SUCCEEDED(hr))
{
// Obtained the document object.
pDocDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc);
if (SUCCEEDED(hr))
{
// Obtained the IHTMLDocument2 interface for the document object
ProcessDocument(pDoc);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
// {
// Load our DLL containing the OLE/COM code. We do this once-only. It's named "cwebpage.dll"
if (!(cwebdll = LoadLibrary("cwebpage.dll")))
{
MessageBox(0, "Can't open cwebpage.dll!", "ERROR", MB_OK);
return(-1);
}
// }
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
...
}
...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
// {
case WM_CREATE:
// Embed the browser object into our host window. We need do this only
// once. Note that the browser object will start calling some of our
// IOleInPlaceFrame and IOleClientSite functions as soon as we start
// calling browser object functions in EmbedBrowserObject().
if (EmbedBrowserObject(hWnd)) return(-1); DisplayHTMLPage(hWnd, "http://www.microsoft.com");
break;
// }
case WM_DESTROY:
// {
// Detach the browser object from this window, and free resources. UnEmbedBrowserObject(hWnd);
// }
PostQuitMessage(0);
break;
case WM_COMMAND:
...
break;
case WM_SIZE:
// Resize the browser object to fit the window ResizeBrowser(hWnd, LOWORD(lParam), HIWORD(lParam));
break;
...
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}