mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Updated to use CControlSite - a homegrown control site class
This commit is contained in:
parent
bac375ae27
commit
0b267cb551
@ -27,7 +27,7 @@ CBrowseDlg::CBrowseDlg(CWnd* pParent /*=NULL*/)
|
||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||
|
||||
m_sURL = _T("http://www.mozilla.com");
|
||||
m_pWndBrowser = NULL;
|
||||
m_pControlSite = NULL;
|
||||
}
|
||||
|
||||
void CBrowseDlg::DoDataExchange(CDataExchange* pDX)
|
||||
@ -63,10 +63,13 @@ BOOL CBrowseDlg::OnInitDialog()
|
||||
GetDlgItem(IDC_BROWSER_MARKER)->GetWindowRect(&rcMarker);
|
||||
ScreenToClient(rcMarker);
|
||||
|
||||
// Create the control
|
||||
m_pWndBrowser = new CWnd;
|
||||
m_pWndBrowser->CreateControl(clsidMozilla, _T("Blah"), WS_VISIBLE, rcMarker, this, 1000);
|
||||
|
||||
CControlSiteInstance::CreateInstance(&m_pControlSite);
|
||||
|
||||
if (m_pControlSite)
|
||||
{
|
||||
m_pControlSite->Attach(clsidMozilla, GetSafeHwnd(), rcMarker, NULL);
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
@ -112,9 +115,11 @@ void CBrowseDlg::OnGo()
|
||||
|
||||
// If there's a browser control, use it to navigate to the specified URL
|
||||
|
||||
if (m_pWndBrowser)
|
||||
if (m_pControlSite)
|
||||
{
|
||||
IUnknown *pIUnkBrowser = m_pWndBrowser->GetControlUnknown();
|
||||
IUnknown *pIUnkBrowser = NULL;
|
||||
|
||||
m_pControlSite->GetControlUnknown(&pIUnkBrowser);
|
||||
if (pIUnkBrowser)
|
||||
{
|
||||
IWebBrowser *pIWebBrowser = NULL;
|
||||
@ -126,6 +131,7 @@ void CBrowseDlg::OnGo()
|
||||
::SysFreeString(bstrURL);
|
||||
pIWebBrowser->Release();
|
||||
}
|
||||
pIUnkBrowser->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ class CBrowseDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CWnd *m_pWndBrowser;
|
||||
CControlSiteInstance *m_pControlSite;
|
||||
|
||||
CBrowseDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
|
@ -4,3 +4,6 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <atlimpl.cpp>
|
||||
#include <atlctl.cpp>
|
||||
#include <atlwin.cpp>
|
||||
|
@ -19,8 +19,18 @@
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
// ATL headers
|
||||
#include <atlbase.h>
|
||||
//You may derive a class from CComModule and use it if you want to override
|
||||
//something, but do not change the name of _Module
|
||||
extern CComModule _Module;
|
||||
#include <atlcom.h>
|
||||
#include <atlctl.h>
|
||||
|
||||
#include <exdisp.h>
|
||||
|
||||
#include "..\..\ControlSite.h"
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
CComModule _Module;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBrowseApp
|
||||
|
||||
@ -41,6 +43,11 @@ CBrowseApp theApp;
|
||||
|
||||
BOOL CBrowseApp::InitInstance()
|
||||
{
|
||||
// Initialize OLE libraries
|
||||
if (!AfxOleInit())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
AfxEnableControlContainer();
|
||||
|
||||
// Standard initialization
|
||||
|
@ -94,6 +94,13 @@ SOURCE=.\cbrowse.cpp
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cbrowse.rc
|
||||
|
||||
!IF "$(CFG)" == "cbrowse - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "cbrowse - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -101,6 +108,10 @@ SOURCE=.\CBrowseDlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\ControlSite.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
# End Source File
|
||||
@ -118,6 +129,10 @@ SOURCE=.\CBrowseDlg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\ControlSite.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -72,17 +72,17 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\cbrowse.ico"
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CBROWSE_DIALOG DIALOGEX 0, 0, 240, 141
|
||||
IDD_CBROWSE_DIALOG DIALOGEX 0, 0, 358, 226
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "CBrowse"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
RTEXT "Goto &URL:",IDC_STATIC,6,8,35,10
|
||||
EDITTEXT IDC_URL,45,5,130,15,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "&Go",IDC_GO,180,5,50,14
|
||||
CONTROL "",IDC_BROWSER_MARKER,"Static",SS_BLACKFRAME,3,24,232,
|
||||
114
|
||||
EDITTEXT IDC_URL,47,7,247,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "&Go",IDC_GO,301,7,50,12
|
||||
CONTROL "",IDC_BROWSER_MARKER,"Static",SS_BLACKFRAME,7,22,344,
|
||||
196
|
||||
END
|
||||
|
||||
|
||||
@ -140,9 +140,9 @@ BEGIN
|
||||
IDD_CBROWSE_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 233
|
||||
RIGHTMARGIN, 351
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 133
|
||||
BOTTOMMARGIN, 218
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
Loading…
Reference in New Issue
Block a user