This commit is contained in:
locka%iol.ie 1999-05-04 22:51:34 +00:00
Родитель 56ff61c011
Коммит af22cbff69
14 изменённых файлов: 163 добавлений и 27 удалений

Просмотреть файл

@ -5,6 +5,7 @@
#include "cbrowse.h"
#include "CBrowseDlg.h"
#include "ControlEventSink.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -60,6 +61,7 @@ CBrowseDlg::CBrowseDlg(CWnd* pParent /*=NULL*/)
CWinApp *pApp = AfxGetApp();
m_szTestURL = pApp->GetProfileString(SECTION_TEST, KEY_TESTURL, KEY_TESTURL_DEFAULTVALUE);
m_szTestCGI = pApp->GetProfileString(SECTION_TEST, KEY_TESTCGI, KEY_TESTCGI_DEFAULTVALUE);
}
void CBrowseDlg::DoDataExchange(CDataExchange* pDX)
@ -151,6 +153,14 @@ BOOL CBrowseDlg::OnInitDialog()
}
m_cmbURLs.SetCurSel(0);
// Create the contained web browser
CreateWebBrowser();
return TRUE; // return TRUE unless you set the focus to a control
}
HRESULT CBrowseDlg::CreateWebBrowser()
{
// Get the position of the browser marker
CRect rcMarker;
GetDlgItem(IDC_BROWSER_MARKER)->GetWindowRect(&rcMarker);
@ -159,15 +169,51 @@ BOOL CBrowseDlg::OnInitDialog()
GetDlgItem(IDC_BROWSER_MARKER)->DestroyWindow();
CControlSiteInstance::CreateInstance(&m_pControlSite);
if (m_pControlSite)
if (m_pControlSite == NULL)
{
PropertyList pl;
m_pControlSite->Create(m_clsid, pl);
m_pControlSite->Attach(GetSafeHwnd(), rcMarker, NULL);
m_pControlSite->SetPosition(rcMarker);
return E_OUTOFMEMORY;
}
return TRUE; // return TRUE unless you set the focus to a control
CControlEventSinkInstance *pEventSink = NULL;
CControlEventSinkInstance::CreateInstance(&pEventSink);
if (pEventSink == NULL)
{
m_pControlSite->Release();
m_pControlSite = NULL;
return E_OUTOFMEMORY;
}
pEventSink->m_pBrowseDlg = this;
PropertyList pl;
m_pControlSite->Create(m_clsid, pl);
m_pControlSite->Attach(GetSafeHwnd(), rcMarker, NULL);
m_pControlSite->SetPosition(rcMarker);
// Set up an event sink
CIUnkPtr spUnkObject;
m_pControlSite->GetControlUnknown(&spUnkObject);
IID iid = DIID_DWebBrowserEvents2;
CIPtr(IConnectionPointContainer) spICPContainer = spUnkObject;
if (spICPContainer)
{
CIPtr(IConnectionPoint) spICP;
spICPContainer->FindConnectionPoint(iid, &spICP);
if (spICP)
{
spICP->Advise(pEventSink, &m_dwCookie);
}
}
return S_OK;
}
HRESULT CBrowseDlg::DestroyWebBrowser()
{
// TODO unsubscribe web event sink
return S_OK;
}
// If you add a minimize button to your dialog, you will need the code below
@ -309,6 +355,7 @@ TestResult CBrowseDlg::RunTest(Test *pTest)
cInfo.pIUnknown = NULL;
cInfo.pBrowseDlg = this;
cInfo.szTestURL = m_szTestURL;
cInfo.szTestCGI = m_szTestCGI;
if (cInfo.pControlSite)
{
cInfo.pControlSite->GetControlUnknown(&cInfo.pIUnknown);

Просмотреть файл

@ -22,7 +22,10 @@ public:
static CBrowseDlg *m_pBrowseDlg;
HRESULT CreateWebBrowser();
HRESULT DestroyWebBrowser();
HRESULT GetWebBrowser(IWebBrowser **pWebBrowser);
void RunTestSet(TestSet *pTestSet);
TestResult RunTest(Test *pTest);
void UpdateTest(HTREEITEM hItem, TestResult nResult);
@ -51,6 +54,8 @@ protected:
HICON m_hIcon;
CImageList m_cImageList;
CString m_szTestURL;
CString m_szTestCGI;
DWORD m_dwCookie;
// Generated message map functions
//{{AFX_MSG(CBrowseDlg)

Просмотреть файл

@ -14,19 +14,20 @@ typedef enum
trPartial
} TestResult;
[
object,
uuid(95AF1AB1-FA66-11D2-A284-000000000000),
dual,
helpstring("DITestScriptHelper Interface"),
pointer_default(unique)
]
interface DITestScriptHelper : IDispatch
{
[id(1), helpstring("method OutputString")] HRESULT OutputString(BSTR bstrMessage);
[propget, id(2), helpstring("property WebBrowser")] HRESULT WebBrowser([out, retval] LPDISPATCH *pVal);
[propput, id(3), helpstring("property Result")] HRESULT Result([in] TestResult newVal);
};
[
object,
uuid(95AF1AB1-FA66-11D2-A284-000000000000),
dual,
helpstring("DITestScriptHelper Interface"),
pointer_default(unique)
]
interface DITestScriptHelper : IDispatch
{
[id(1), helpstring("method OutputString")] HRESULT OutputString(BSTR bstrMessage);
[propget, id(2), helpstring("property WebBrowser")] HRESULT WebBrowser([out, retval] LPDISPATCH *pVal);
[propput, id(3), helpstring("property Result")] HRESULT Result([in] TestResult newVal);
[propget, id(4), helpstring("property TestURL")] HRESULT TestURL([out, retval] BSTR *pVal);
};
[
@ -46,6 +47,14 @@ library CbrowseLib
{
[default] interface DITestScriptHelper;
};
[
uuid(31204F42-FCE8-11D2-A289-000000000000),
helpstring("ControlEventSink Class")
]
coclass ControlEventSink
{
[default] interface IDispatch;
};
};

Просмотреть файл

@ -41,11 +41,13 @@ CPickerDlg::CPickerDlg(CWnd* pParent /*=NULL*/)
{
//{{AFX_DATA_INIT(CPickerDlg)
m_szTestURL = _T("");
m_szTestCGI = _T("");
//}}AFX_DATA_INIT
m_clsid = CLSID_NULL;
CWinApp *pApp = AfxGetApp();
m_szTestURL = pApp->GetProfileString(SECTION_TEST, KEY_TESTURL, KEY_TESTURL_DEFAULTVALUE);
m_szTestCGI = pApp->GetProfileString(SECTION_TEST, KEY_TESTCGI, KEY_TESTCGI_DEFAULTVALUE);
}
@ -55,6 +57,7 @@ void CPickerDlg::DoDataExchange(CDataExchange* pDX)
//{{AFX_DATA_MAP(CPickerDlg)
DDX_Control(pDX, IDC_LISTBROWSER, m_lbPicker);
DDX_Text(pDX, IDC_TESTURL, m_szTestURL);
DDX_Text(pDX, IDC_TESTCGI, m_szTestCGI);
//}}AFX_DATA_MAP
}
@ -98,6 +101,7 @@ void CPickerDlg::OnOk()
CWinApp *pApp = AfxGetApp();
pApp->WriteProfileString(SECTION_TEST, KEY_TESTURL, m_szTestURL);
pApp->WriteProfileString(SECTION_TEST, KEY_TESTCGI, m_szTestCGI);
EndDialog(IDOK);
}

Просмотреть файл

@ -21,6 +21,7 @@ public:
enum { IDD = IDD_PICKBROWSER };
CListBox m_lbPicker;
CString m_szTestURL;
CString m_szTestCGI;
//}}AFX_DATA
CLSID m_clsid;

Просмотреть файл

@ -59,7 +59,9 @@ extern CBrowseModule _Module;
#define SECTION_TEST _T("Test")
#define KEY_TESTURL _T("TestURL")
#define KEY_TESTCGI _T("TestCGI")
#define KEY_TESTURL_DEFAULTVALUE _T("http://www.mozilla.org")
#define KEY_TESTCGI_DEFAULTVALUE _T("http://www.mozilla.org")

Просмотреть файл

@ -58,3 +58,20 @@ STDMETHODIMP CTestScriptHelper::put_Result(TestResult newVal)
return S_OK;
}
STDMETHODIMP CTestScriptHelper::get_TestURL(BSTR *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (pVal == NULL)
{
return E_INVALIDARG;
}
if (m_pBrowserInfo)
{
USES_CONVERSION;
*pVal = SysAllocString(T2OLE(m_pBrowserInfo->szTestURL));
}
return S_OK;
}

Просмотреть файл

@ -31,6 +31,7 @@ END_COM_MAP()
// DITestScriptHelper
public:
STDMETHOD(get_TestURL)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Result)(/*[in]*/ TestResult newVal);
STDMETHOD(get_WebBrowser)(/*[out, retval]*/ LPDISPATCH *pVal);
STDMETHOD(OutputString)(BSTR bstrMessage);

Просмотреть файл

@ -69,6 +69,21 @@ HRESULT BrowserInfo::GetDocument(IHTMLDocument2 **pDocument)
///////////////////////////////////////////////////////////////////////////////
struct InterfaceInfo
{
const IID *piid;
const TCHAR *szName;
};
static InterfaceInfo aDocIIDs[] =
{
{ &IID_IOleCommandTarget, _T("IOleCommandTarget") },
{ &IID_IHTMLDocument, _T("IHTMLDocument") },
{ &IID_IHTMLDocument2, _T("IHTMLDocument2") },
{ &IID_IHTMLElementCollection, _T("IHTMLElementCollection") },
{ &IID_IHTMLElement, _T("IHTMLElement") }
};
TestResult __cdecl tstDocument(BrowserInfo &cInfo)
{
CIPtr(IHTMLDocument2) cpDocElement;
@ -79,6 +94,21 @@ TestResult __cdecl tstDocument(BrowserInfo &cInfo)
return trFailed;
}
// Dump out all the interfaces supported by the document element
for (int i = 0; i < sizeof(aDocIIDs) / sizeof(aDocIIDs[0]); i++)
{
IUnknown *pUnkI = NULL;
if (SUCCEEDED(cpDocElement->QueryInterface(*(aDocIIDs[i].piid), (void **) &pUnkI)))
{
cInfo.OutputString(_T("Info: Document supports interface %s"), aDocIIDs[i].szName);
pUnkI->Release();
}
else
{
cInfo.OutputString(_T("Info: Document doesn't support interface %s"), aDocIIDs[i].szName);
}
}
return trPassed;
}

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@ -18,9 +18,7 @@
#ifndef TESTS_H
#define TESTS_H
#define CIPtr(iface) \
CComQIPtr< iface, &IID_ ## iface >
#include "CBrowse_i.h"
class CBrowseDlg;
struct Test;
@ -35,6 +33,7 @@ public:
CLSID clsid;
CBrowseDlg *pBrowseDlg;
CString szTestURL;
CString szTestCGI;
void OutputString(const TCHAR *szMessage, ...);
HRESULT GetWebBrowser(IWebBrowserApp **pWebBrowser);

Просмотреть файл

@ -8,6 +8,7 @@
#include <initguid.h>
#include "Cbrowse_i.c"
#include "TestScriptHelper.h"
#include "ControlEventSink.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -104,6 +105,7 @@ CBrowseModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_TestScriptHelper, CTestScriptHelper)
// OBJECT_ENTRY(CLSID_ControlEventSink, CControlEventSink)
END_OBJECT_MAP()
LONG CBrowseModule::Unlock()

Просмотреть файл

@ -65,6 +65,7 @@ LINK32=link.exe
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
@ -111,6 +112,10 @@ SOURCE=.\CBrowseDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\ControlEventSink.cpp
# End Source File
# Begin Source File
SOURCE=..\..\ControlSite.cpp
# End Source File
# Begin Source File
@ -160,6 +165,10 @@ SOURCE=.\CBrowseDlg.h
# End Source File
# Begin Source File
SOURCE=.\ControlEventSink.h
# End Source File
# Begin Source File
SOURCE=..\..\ControlSite.h
# End Source File
# Begin Source File
@ -237,6 +246,10 @@ SOURCE=.\Cbrowse.rgs
# End Source File
# Begin Source File
SOURCE=.\ControlEventSink.rgs
# End Source File
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# Begin Source File

Просмотреть файл

@ -197,6 +197,7 @@ END
IDR_CBROWSE REGISTRY DISCARDABLE "Cbrowse.rgs"
IDR_TESTSCRIPTHELPER REGISTRY DISCARDABLE "TestScriptHelper.rgs"
IDR_CONTROLEVENTSINK REGISTRY DISCARDABLE "ControlEventSink.rgs"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
@ -224,7 +225,7 @@ IDI_TEST ICON DISCARDABLE "res\\test.ico"
// Dialog
//
IDD_PICKBROWSER DIALOG DISCARDABLE 0, 0, 284, 157
IDD_PICKBROWSER DIALOG DISCARDABLE 0, 0, 284, 185
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Welcome to CBrowse!"
FONT 8, "MS Sans Serif"
@ -238,9 +239,12 @@ BEGIN
WS_VSCROLL | WS_TABSTOP
LTEXT "Some of the tests require a test URL. You may change the default one if you want. Ensure that the URL is valid otherwise the tests might fail!",
IDC_STATIC,7,108,213,25
EDITTEXT IDC_TESTURL,7,137,213,13,ES_AUTOHSCROLL
EDITTEXT IDC_TESTURL,7,136,213,13,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,227,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,227,24,50,14
LTEXT "Some tests also need a CGI URL, enter that here:",
IDC_STATIC,7,154,157,8
EDITTEXT IDC_TESTCGI,7,165,213,13,ES_AUTOHSCROLL
END
@ -257,7 +261,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 277
TOPMARGIN, 7
BOTTOMMARGIN, 150
BOTTOMMARGIN, 178
END
END
#endif // APSTUDIO_INVOKED

Просмотреть файл

@ -6,6 +6,7 @@
#define IDD_CBROWSE_DIALOG 102
#define IDR_CBROWSE 103
#define IDR_TESTSCRIPTHELPER 104
#define IDR_CONTROLEVENTSINK 105
#define IDR_MAINFRAME 128
#define IDD_PICKBROWSER 129
#define IDI_CLOSEDFOLDER 130
@ -25,6 +26,7 @@
#define IDC_TESTDESCRIPTION 1010
#define IDC_TESTURL 1011
#define IDC_DOMLIST 1012
#define IDC_TESTCGI 1012
#define IDC_REFRESHDOM 1013
// Next default values for new objects
@ -34,6 +36,6 @@
#define _APS_NEXT_RESOURCE_VALUE 135
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 105
#define _APS_NEXT_SYMED_VALUE 106
#endif
#endif