Fixed a problem with the default impl of GetClientSite

Added basic printer support
This commit is contained in:
locka@iol.ie
1999-01-06 22:38:24 +00:00
parent 8f73524059
commit daa045d1eb
3 changed files with 62 additions and 5 deletions
+53 -3
View File
@@ -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<CMozillaBrowser>::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" },
+8 -2
View File
@@ -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<CMozillaBrowser>
@@ -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);
+1
View File
@@ -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"