diff --git a/webshell/embed/ActiveX/MozillaBrowser.cpp b/webshell/embed/ActiveX/MozillaBrowser.cpp index 083e93b2a86c..c894f7ee2ecf 100644 --- a/webshell/embed/ActiveX/MozillaBrowser.cpp +++ b/webshell/embed/ActiveX/MozillaBrowser.cpp @@ -144,10 +144,29 @@ LRESULT CMozillaBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b } +LRESULT CMozillaBrowser::OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + MessageBox(_T("No page setup yet!"), _T("Control Message"), MB_OK); + // TODO show the page setup dialog + return 0; +} + + LRESULT CMozillaBrowser::OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { - MessageBox(_T("Control doesn't print yet!"), _T("Control Message"), MB_OK); - // TODO print the current page + // TODO show a print dialog + + // Print the contents + if (m_pIWebShell) + { + nsIContentViewer *pContentViewer = nsnull; + m_pIWebShell->GetContentViewer(pContentViewer); + if (nsnull != pContentViewer) + { + pContentViewer->Print(); + NS_RELEASE(pContentViewer); + } + } return 0; } @@ -186,6 +205,11 @@ HRESULT CMozillaBrowser::CreateWebShell() RECT rcLocation; GetClientRect(&rcLocation); + if (IsRectEmpty(&rcLocation)) + { + rcLocation.bottom++; + rcLocation.top++; + } nsresult rv; @@ -242,6 +266,32 @@ HRESULT CMozillaBrowser::CreateWebShell() return S_OK; } + +///////////////////////////////////////////////////////////////////////////// +// IOleObject overrides + + +HRESULT STDMETHODCALLTYPE CMozillaBrowser::GetClientSite(IOleClientSite **ppClientSite) +{ + NG_ASSERT(ppClientSite); + + // This fixes a problem in the base class which asserts if the client + // site has not been set when this method is called. + + HRESULT hRes = E_POINTER; + if (ppClientSite != NULL) + { + *ppClientSite = NULL; + if (m_spClientSite == NULL) + { + return S_OK; + } + } + + return IOleObjectImpl::GetClientSite(ppClientSite); +} + + ///////////////////////////////////////////////////////////////////////////// // IWebBrowser @@ -1569,7 +1619,7 @@ static OleCommandInfo s_aSupportedCommands[] = { { OLECMDID_PRINT, ID_PRINT, L"Print", L"Print the page" }, { OLECMDID_SAVEAS, 0, L"SaveAs", L"Save the page" }, - { OLECMDID_PAGESETUP, 0, L"Page Setup", L"Page Setup" }, + { OLECMDID_PAGESETUP, ID_PAGESETUP, L"Page Setup", L"Page Setup" }, { OLECMDID_PROPERTIES, 0, L"Properties", L"Show page properties" }, { OLECMDID_CUT, 0, L"Cut", L"Cut selection" }, { OLECMDID_COPY, 0, L"Copy", L"Copy selection" }, diff --git a/webshell/embed/ActiveX/MozillaBrowser.h b/webshell/embed/ActiveX/MozillaBrowser.h index 82fa94e5d2f6..44257cf0fc09 100644 --- a/webshell/embed/ActiveX/MozillaBrowser.h +++ b/webshell/embed/ActiveX/MozillaBrowser.h @@ -53,7 +53,8 @@ int operator ==(const Property&, const Property&); class CWebShellContainer; // Commands sent via WM_COMMAND -#define ID_PRINT 1 +#define ID_PRINT 1 +#define ID_PAGESETUP 2 // Some definitions which are used to make firing events easier #define CDWebBrowserEvents1 CProxyDWebBrowserEvents @@ -138,8 +139,8 @@ BEGIN_MSG_MAP(CMozillaBrowser) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) - COMMAND_ID_HANDLER(ID_PRINT, OnPrint) + COMMAND_ID_HANDLER(ID_PAGESETUP, OnPageSetup) END_MSG_MAP() // Windows message handlers @@ -147,6 +148,7 @@ END_MSG_MAP() LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); @@ -180,6 +182,10 @@ protected: virtual BOOL IsValid(); public: +// IOleObject overrides + virtual HRESULT STDMETHODCALLTYPE CMozillaBrowser::GetClientSite(IOleClientSite **ppClientSite); + + // IWebBrowser implementation virtual HRESULT STDMETHODCALLTYPE GoBack(void); virtual HRESULT STDMETHODCALLTYPE GoForward(void); diff --git a/webshell/embed/ActiveX/StdAfx.h b/webshell/embed/ActiveX/StdAfx.h index e04929cb7839..7bafa2a43235 100644 --- a/webshell/embed/ActiveX/StdAfx.h +++ b/webshell/embed/ActiveX/StdAfx.h @@ -74,6 +74,7 @@ typedef long int32; #include "nsGlobalVariables.h" #include "nsIWebShell.h" +#include "nsIContentViewer.h" #include "nsIPresContext.h" #include "nsIDocument.h" #include "nsIDocumentObserver.h"