summaryrefslogtreecommitdiffstats
path: root/private/oleutest/simpcntr
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/oleutest/simpcntr
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/oleutest/simpcntr')
-rw-r--r--private/oleutest/simpcntr/app.cpp1060
-rw-r--r--private/oleutest/simpcntr/app.h76
-rw-r--r--private/oleutest/simpcntr/daytona/makefile6
-rw-r--r--private/oleutest/simpcntr/daytona/sources43
-rw-r--r--private/oleutest/simpcntr/dirs3
-rw-r--r--private/oleutest/simpcntr/doc.cpp628
-rw-r--r--private/oleutest/simpcntr/doc.h55
-rw-r--r--private/oleutest/simpcntr/ias.cpp304
-rw-r--r--private/oleutest/simpcntr/ias.h44
-rw-r--r--private/oleutest/simpcntr/iocs.cpp368
-rw-r--r--private/oleutest/simpcntr/iocs.h44
-rw-r--r--private/oleutest/simpcntr/ioipf.cpp641
-rw-r--r--private/oleutest/simpcntr/ioipf.h51
-rw-r--r--private/oleutest/simpcntr/ioips.cpp615
-rw-r--r--private/oleutest/simpcntr/ioips.h53
-rw-r--r--private/oleutest/simpcntr/pre.cpp9
-rw-r--r--private/oleutest/simpcntr/pre.h32
-rw-r--r--private/oleutest/simpcntr/readme.txt31
-rw-r--r--private/oleutest/simpcntr/resource.h32
-rw-r--r--private/oleutest/simpcntr/simpcntr.cpp523
-rw-r--r--private/oleutest/simpcntr/simpcntr.def26
-rw-r--r--private/oleutest/simpcntr/simpcntr.h40
-rw-r--r--private/oleutest/simpcntr/simpcntr.icobin0 -> 766 bytes
-rw-r--r--private/oleutest/simpcntr/simpcntr.rc114
-rw-r--r--private/oleutest/simpcntr/site.cpp637
-rw-r--r--private/oleutest/simpcntr/site.h53
-rw-r--r--private/oleutest/simpcntr/tests.cpp202
-rw-r--r--private/oleutest/simpcntr/tests.h8
-rw-r--r--private/oleutest/simpcntr/utaccel.h7
29 files changed, 5705 insertions, 0 deletions
diff --git a/private/oleutest/simpcntr/app.cpp b/private/oleutest/simpcntr/app.cpp
new file mode 100644
index 000000000..37f4a91aa
--- /dev/null
+++ b/private/oleutest/simpcntr/app.cpp
@@ -0,0 +1,1060 @@
+//**********************************************************************
+// File name: app.cpp
+//
+// Implementation file for the CSimpleApp Class
+//
+// Functions:
+//
+// See app.h for a list of member functions.
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+#include <testmess.h>
+
+extern void DeactivateIfActive(HWND hWnd);
+
+#ifdef WIN32
+extern BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam,
+ LPARAM lParam);
+#endif
+
+
+//**********************************************************************
+//
+// CSimpleApp::CSimpleApp()
+//
+// Purpose:
+//
+// Constructor for CSimpleApp
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// SetRectEmpty Windows API
+//
+// Comments:
+//
+// CSimpleApp has a contained COleInPlaceFrame. On construction
+// of CSimpleApp, we explicitly call the constructor of this
+// contained class and pass a copy of the this pointer, so that
+// COleInPlaceFrame can refer back to this class
+//
+//********************************************************************
+#pragma warning(disable : 4355) // turn off this warning. This warning
+ // tells us that we are passing this in
+ // an initializer, before "this" is through
+ // initializing. This is ok, because
+ // we just store the ptr in the other
+ // constructor
+
+CSimpleApp::CSimpleApp() : m_OleInPlaceFrame(this)
+#pragma warning (default : 4355) // Turn the warning back on
+{
+ TestDebugOut(TEXT("In CSimpleApp's Constructor \r\n"));
+
+ // Set Ref Count
+ m_nCount = 0;
+
+ // clear members
+ m_hAppWnd = NULL;
+ m_hInst = NULL;
+ m_lpDoc = NULL;
+
+ // Make sure we don't think we are deactivating
+ m_fDeactivating = FALSE;
+
+ // We haven't got a unit test accelerator so ...
+ m_fGotUtestAccelerator = FALSE;
+
+ // clear flags
+ m_fInitialized = FALSE;
+ m_fCSHMode = FALSE;
+ m_fMenuMode = FALSE;
+
+ // used for inplace
+ SetRectEmpty(&nullRect);
+}
+
+//**********************************************************************
+//
+// CSimpleApp::~CSimpleApp()
+//
+// Purpose:
+//
+// Destructor for CSimpleApp Class.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// DeleteObject Windows API
+// OleUninitialize OLE API
+//
+//
+//********************************************************************
+
+CSimpleApp::~CSimpleApp()
+{
+ TestDebugOut(TEXT("In CSimpleApp's Destructor\r\n"));
+
+ if (m_hStdPal)
+ DeleteObject(m_hStdPal);
+
+ // need to uninit the library...
+ if (m_fInitialized)
+ OleUninitialize();
+}
+
+//**********************************************************************
+//
+// CSimpleApp::DestroyDocs()
+//
+// Purpose:
+//
+// Destroys all of the open documents in the application (Only one
+// since this is an SDI app, but could easily be modified to
+// support MDI).
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+// CSimpDoc::Close DOC.CPP
+//
+//
+//********************************************************************
+
+void CSimpleApp::DestroyDocs()
+{
+ m_lpDoc->Close(); // we have only 1 document
+}
+
+//**********************************************************************
+//
+// CSimpleApp::QueryInterface
+//
+// Purpose:
+//
+// Used for interface negotiation at the application level.
+//
+// Parameters:
+//
+// REFIID riid - A reference to the interface that is
+// being queried.
+//
+// LPVOID FAR* ppvObj - An out parameter to return a pointer to
+// the interface.
+//
+// Return Value:
+//
+// S_OK - The interface is supported.
+// E_NOINTERFACE - The interface is not supported
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IsEqualIID OLE API
+// ResultFromScode OLE API
+// COleInPlaceFrame::AddRef IOIPF.CPP
+// CSimpleApp::AddRef APP.CPP
+//
+// Comments:
+//
+// Note that this QueryInterface is associated with the frame.
+// Since the application could potentially have multiple documents
+// and multiple objects, a lot of the interfaces are ambiguous.
+// (ie. which IOleObject is returned?). For this reason, only
+// pointers to interfaces associated with the frame are returned.
+// In this implementation, Only IOleInPlaceFrame (or one of the
+// interfaces it is derived from) can be returned.
+//
+//********************************************************************
+
+STDMETHODIMP CSimpleApp::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In CSimpleApp::QueryInterface\r\n"));
+
+ *ppvObj = NULL; // must set out pointer parameters to NULL
+
+ // looking for IUnknown
+ if ( IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppvObj = this;
+ return ResultFromScode(S_OK);
+ }
+
+ // looking for IOleWindow
+ if ( IsEqualIID(riid, IID_IOleWindow))
+ {
+ m_OleInPlaceFrame.AddRef();
+ *ppvObj=&m_OleInPlaceFrame;
+ return ResultFromScode(S_OK);
+ }
+
+ // looking for IOleInPlaceUIWindow
+ if ( IsEqualIID(riid, IID_IOleInPlaceUIWindow))
+ {
+ m_OleInPlaceFrame.AddRef();
+ *ppvObj=&m_OleInPlaceFrame;
+ return ResultFromScode(S_OK);
+ }
+
+ // looking for IOleInPlaceFrame
+ if ( IsEqualIID(riid, IID_IOleInPlaceFrame))
+ {
+ m_OleInPlaceFrame.AddRef();
+ *ppvObj=&m_OleInPlaceFrame;
+ return ResultFromScode(S_OK);
+ }
+
+ // Not a supported interface
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+//**********************************************************************
+//
+// CSimpleApp::AddRef
+//
+// Purpose:
+//
+// Adds to the reference count at the Application level.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of the application.
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+// Comments:
+//
+// Due to the reference counting model that is used in this
+// implementation, this reference count is the sum of the
+// reference counts on all interfaces of all objects open
+// in the application.
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleApp::AddRef()
+{
+ TestDebugOut(TEXT("In CSimpleApp::AddRef\r\n"));
+ return ++m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleApp::Release
+//
+// Purpose:
+//
+// Decrements the reference count at this level
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of the application.
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleApp::Release()
+{
+ TestDebugOut(TEXT("In CSimpleApp::Release\r\n"));
+
+ if (--m_nCount == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleApp::fInitApplication
+//
+// Purpose:
+//
+// Initializes the application
+//
+// Parameters:
+//
+// HANDLE hInstance - Instance handle of the application.
+//
+// Return Value:
+//
+// TRUE - Application was successfully initialized.
+// FALSE - Application could not be initialized
+//
+// Function Calls:
+// Function Location
+//
+// LoadIcon Windows API
+// LoadCursor Windows API
+// GetStockObject Windows API
+// RegisterClass Windows API
+//
+//
+//********************************************************************
+
+BOOL CSimpleApp::fInitApplication(HANDLE hInstance)
+{
+ // Initialize our accelerator table
+ if ((m_hAccel = LoadAccelerators((HINSTANCE) hInstance,
+ TEXT("SimpcntrAccel"))) == NULL)
+ {
+ // Load failed so abort
+ TestDebugOut(TEXT("ERROR: Accelerator Table Load FAILED\r\n"));
+ return FALSE;
+ }
+
+ WNDCLASS wc;
+
+ // Fill in window class structure with parameters that describe the
+ // main window.
+
+ wc.style = NULL; // Class style(s).
+ wc.lpfnWndProc = MainWndProc; // Function to retrieve messages for
+ // windows of this class.
+ wc.cbClsExtra = 0; // No per-class extra data.
+ wc.cbWndExtra = 0; // No per-window extra data.
+ wc.hInstance = (HINSTANCE) hInstance; // Application that owns the
+ // class.
+ wc.hIcon = LoadIcon((HINSTANCE) hInstance, TEXT("SimpCntr"));
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = TEXT("SIMPLEMENU"); // Name of menu resource in
+ // .RC file.
+ wc.lpszClassName = TEXT("SimpCntrAppWClass"); // Name used in
+ // CreateWindow call
+
+ if (!RegisterClass(&wc))
+ return FALSE;
+
+ wc.style = CS_DBLCLKS; // Class style(s). allow DBLCLK's
+ wc.lpfnWndProc = DocWndProc; // Function to retrieve messages for
+ // windows of this class.
+ wc.cbClsExtra = 0; // No per-class extra data.
+ wc.cbWndExtra = 0; // No per-window extra data.
+ wc.hInstance = (HINSTANCE) hInstance; // Application that owns
+ // the class.
+ wc.hIcon = NULL;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = TEXT("SimpCntrDocWClass"); // Name used in
+ // CreateWindow call.
+
+ // Register the window class and return success/failure code.
+
+ return (RegisterClass(&wc));
+}
+
+//**********************************************************************
+//
+// CSimpleApp::fInitInstance
+//
+// Purpose:
+//
+// Instance initialization.
+//
+// Parameters:
+//
+// HANDLE hInstance - App. Instance Handle.
+//
+// int nCmdShow - Show parameter from WinMain
+//
+// Return Value:
+//
+// TRUE - Initialization Successful
+// FALSE - Initialization Failed.
+//
+//
+// Function Calls:
+// Function Location
+//
+// CreateWindow Windows API
+// ShowWindow Windows API
+// UpdateWindow Windows API
+// OleBuildVersion OLE API
+// OleInitialize OLE API
+//
+// Comments:
+//
+// Note that successful Initalization of the OLE libraries
+// is remembered so the UnInit is only called if needed.
+//
+//********************************************************************
+
+BOOL CSimpleApp::fInitInstance (HANDLE hInstance, int nCmdShow)
+{
+ LPMALLOC lpMalloc = NULL;
+
+#ifndef WIN32
+ /* Since OLE is part of the operating system in Win32, we don't need to
+ * check the version number in Win32.
+ */
+ DWORD dwVer = OleBuildVersion();
+
+ // check to see if we are compatible with this version of the libraries
+ if (HIWORD(dwVer) != rmm || LOWORD(dwVer) < rup)
+ {
+#ifdef _DEBUG
+ TestDebugOut(TEXT("WARNING:Incompatible OLE library version\r\n"));
+#else
+ return FALSE;
+#endif
+ }
+#endif // WIN32
+
+#if defined( _DEBUG )
+ /* OLE2NOTE: Use a special debug allocator to help track down
+ ** memory leaks.
+ */
+ OleStdCreateDbAlloc(0, &lpMalloc);
+#endif
+
+ // We try passing in our own allocator first - if that fails we
+ // try without overriding the allocator.
+
+ if (SUCCEEDED(OleInitialize(lpMalloc)) ||
+ SUCCEEDED(OleInitialize(NULL)))
+ {
+ m_fInitialized = TRUE;
+ }
+
+#if defined( _DEBUG )
+ /* OLE2NOTE: release the special debug allocator so that only OLE is
+ ** holding on to it. later when OleUninitialize is called, then
+ ** the debug allocator object will be destroyed. when the debug
+ ** allocator object is destoyed, it will report (to the Output
+ ** Debug Terminal) whether there are any memory leaks.
+ */
+ if (lpMalloc) lpMalloc->Release();
+#endif
+
+ m_hInst = (HINSTANCE) hInstance;
+
+ // Create the "application" windows
+ m_hAppWnd = CreateWindow (TEXT("SimpCntrAppWClass"),
+ TEXT("Simple OLE 2.0 In-Place Container"),
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ NULL,
+ NULL,
+ (HINSTANCE) hInstance,
+ NULL);
+
+ if (!m_hAppWnd)
+ return FALSE;
+
+ m_hStdPal = OleStdCreateStandardPalette();
+
+ ShowWindow (m_hAppWnd, nCmdShow);
+ UpdateWindow (m_hAppWnd);
+
+ // if we have been launched by the test driver, tell it our window handle
+ if( m_hDriverWnd )
+ {
+ PostMessage(m_hDriverWnd, WM_TESTREG, (WPARAM)m_hAppWnd, 0);
+ }
+
+
+
+ return m_fInitialized;
+}
+
+//**********************************************************************
+//
+// CSimpleApp::lCommandHandler
+//
+// Purpose:
+//
+// Handles the processing of WM_COMMAND.
+//
+// Parameters:
+//
+// HWND hWnd - Handle to the application Window
+//
+// UINT message - message (always WM_COMMAND)
+//
+// WPARAM wParam - Same as passed to the WndProc
+//
+// LPARAM lParam - Same as passed to the WndProc
+//
+// Return Value:
+//
+// NULL
+//
+// Function Calls:
+// Function Location
+//
+// IOleInPlaceActiveObject::QueryInterface Object
+// IOleInPlaceObject::ContextSensitiveHelp Object
+// IOleInPlaceObject::Release Object
+// IOleObject::DoVerb Object
+// MessageBox Windows API
+// DialogBox Windows API
+// MakeProcInstance Windows API
+// FreeProcInstance Windows API
+// SendMessage Windows API
+// DefWindowProc Windows API
+// CSimpleDoc::InsertObject DOC.CPP
+// CSimpleSite::GetObjRect SITE.CPP
+// CSimpleApp::lCreateDoc APP.CPP
+//
+//
+//********************************************************************
+
+long CSimpleApp::lCommandHandler (HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ RECT rect;
+
+ // Win32 uses high word to tell were command came from so we dump it.
+ wParam = LOWORD(wParam);
+
+ // context sensitive help...
+ if (m_fMenuMode || m_fCSHMode)
+ {
+ if (m_fCSHMode)
+ {
+ // clear context sensitive help flag
+ m_fCSHMode = FALSE;
+
+ // if there is an InPlace active object, call its context
+ // sensitive help method with the FALSE parameter to bring the
+ // object out of the csh state. See the technotes for details.
+ if (m_lpDoc->m_lpActiveObject)
+ {
+ LPOLEINPLACEOBJECT lpInPlaceObject;
+ m_lpDoc->m_lpActiveObject->QueryInterface(
+ IID_IOleInPlaceObject,
+ (LPVOID FAR *)&lpInPlaceObject);
+ lpInPlaceObject->ContextSensitiveHelp(FALSE);
+ lpInPlaceObject->Release();
+ }
+ }
+
+ // see the technotes for details on implementing context sensitive
+ // help
+ if (m_fMenuMode)
+ {
+ m_fMenuMode = FALSE;
+
+ if (m_lpDoc->m_lpActiveObject)
+ m_lpDoc->m_lpActiveObject->ContextSensitiveHelp(FALSE);
+ }
+ // if we provided help, we would do it here...
+ MessageBox (hWnd, TEXT("Help"), TEXT("Help"), MB_OK);
+
+ return NULL;
+ }
+
+ // see if the command is a verb selections
+ if (wParam >= IDM_VERB0)
+ {
+ // get the rectangle of the object
+ m_lpDoc->m_lpSite->GetObjRect(&rect);
+
+ m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(wParam - IDM_VERB0, NULL,
+ &m_lpDoc->m_lpSite->m_OleClientSite,
+ -1, m_lpDoc->m_hDocWnd, &rect);
+ }
+ else
+ {
+ switch (wParam)
+ {
+ // bring up the About box
+ case IDM_ABOUT:
+ {
+#ifdef WIN32
+ DialogBox(m_hInst, // current instance
+ TEXT("AboutBox"), // resource to use
+ m_hAppWnd, // parent handle
+ About); // About() instance address
+#else
+ FARPROC lpProcAbout = MakeProcInstance((FARPROC)About,
+ m_hInst);
+
+ DialogBox(m_hInst, // current instance
+ TEXT("AboutBox"), // resource to use
+ m_hAppWnd, // parent handle
+ lpProcAbout); // About() instance address
+
+ FreeProcInstance(lpProcAbout);
+#endif
+
+ break;
+ }
+
+ // bring up the InsertObject Dialog
+ case IDM_INSERTOBJECT:
+ m_lpDoc->InsertObject();
+ break;
+
+ // exit the application
+ case IDM_EXIT:
+ SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
+ break;
+
+ case IDM_NEW:
+ m_lpDoc->Close();
+ m_lpDoc = NULL;
+ lCreateDoc(hWnd, 0, 0, 0);
+ break;
+
+ case IDM_DEACTIVATE:
+ DeactivateIfActive(hWnd);
+ break;
+
+ case IDM_UTEST:
+ m_fGotUtestAccelerator = TRUE;
+ break;
+
+ default:
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+ } // end of switch
+ } // end of else
+ return NULL;
+}
+
+//**********************************************************************
+//
+// CSimpleApp::lSizeHandler
+//
+// Purpose:
+//
+// Handles the WM_SIZE message
+//
+// Parameters:
+//
+// HWND hWnd - Handle to the application Window
+//
+// UINT message - message (always WM_SIZE)
+//
+// WPARAM wParam - Same as passed to the WndProc
+//
+// LPARAM lParam - Same as passed to the WndProc
+//
+// Return Value:
+//
+// LONG - returned from the "document" resizing
+//
+// Function Calls:
+// Function Location
+//
+// GetClientRect Windows API
+// CSimpleDoc::lResizeDoc DOC.CPP
+//
+//
+//********************************************************************
+
+long CSimpleApp::lSizeHandler (HWND hWnd, UINT message, WPARAM wParam,
+ LPARAM lParam)
+{
+ RECT rect;
+
+ GetClientRect(m_hAppWnd, &rect);
+ return m_lpDoc->lResizeDoc(&rect);
+}
+
+//**********************************************************************
+//
+// CSimpleApp::lCreateDoc
+//
+// Purpose:
+//
+// Handles the creation of a document.
+//
+// Parameters:
+//
+// HWND hWnd - Handle to the application Window
+//
+// UINT message - message (always WM_CREATE)
+//
+// WPARAM wParam - Same as passed to the WndProc
+//
+// LPARAM lParam - Same as passed to the WndProc
+//
+// Return Value:
+//
+// NULL
+//
+// Function Calls:
+// Function Location
+//
+// GetClientRect Windows API
+// CSimpleDoc::CSimpleDoc DOC.CPP
+//
+//
+//********************************************************************
+
+long CSimpleApp::lCreateDoc (HWND hWnd, UINT message, WPARAM wParam,
+ LPARAM lParam)
+{
+ RECT rect;
+
+ GetClientRect(hWnd, &rect);
+
+ m_lpDoc = CSimpleDoc::Create(this, &rect, hWnd);
+
+ return NULL;
+}
+
+//**********************************************************************
+//
+// CSimpleApp::AddFrameLevelUI
+//
+// Purpose:
+//
+// Used during InPlace negotiation.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// COleInPlaceFrame::SetMenu IOIPF.CPP
+// CSimpleApp::AddFrameLevelTools APP.CPP
+//
+// Comments:
+//
+// Be sure to read the Technotes included in the OLE 2.0 toolkit
+//
+//********************************************************************
+
+void CSimpleApp::AddFrameLevelUI()
+{
+ m_OleInPlaceFrame.SetMenu(NULL, NULL, NULL);
+ AddFrameLevelTools();
+}
+
+//**********************************************************************
+//
+// CSimpleApp::AddFrameLevelTools
+//
+// Purpose:
+//
+// Used during InPlace negotiation.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// COleInPlaceFrame::SetBorderSpace IOIPF.CPP
+// InvalidateRect Windows API
+//
+// Comments:
+//
+// Be sure to read the Technotes included in the OLE 2.0 toolkit
+//
+//********************************************************************
+
+void CSimpleApp::AddFrameLevelTools()
+{
+ m_OleInPlaceFrame.SetBorderSpace(&nullRect);
+ InvalidateRect(m_hAppWnd, NULL, TRUE);
+}
+
+//**********************************************************************
+//
+// CSimpleApp::HandleAccelerators
+//
+// Purpose:
+//
+// To properly handle accelerators in the Message Loop
+//
+// Parameters:
+//
+// LPMSG lpMsg - A pointer to the message structure.
+//
+// Return Value:
+//
+// TRUE - The accelerator was handled
+// FALSE - The accelerator was not handled
+//
+// Function Calls:
+// Function Location
+//
+// IOleInPlaceActiveObject::TranslateAccelerator Object
+//
+// Comments:
+//
+// If an object is InPlace active, it gets the first shot at
+// handling the accelerators.
+//
+//********************************************************************
+
+BOOL CSimpleApp::HandleAccelerators(LPMSG lpMsg)
+{
+ HRESULT hResult;
+ BOOL retval = FALSE;
+
+ // The following is what you would do if this were an inproc DLL.
+ // A local server will be passing us commands to process
+#if 0
+ // if we have an InPlace Active Object
+ if (m_lpDoc->m_lpActiveObject)
+ {
+ // Pass the accelerator on...
+ hResult = m_lpDoc->m_lpActiveObject->TranslateAccelerator(lpMsg);
+ if (hResult == NOERROR)
+ retval = TRUE;
+ }
+#endif
+
+ // We process our accelerators
+ return TranslateAccelerator(m_hAppWnd, m_hAccel, lpMsg);
+}
+
+//**********************************************************************
+//
+// CSimpleApp::PaintApp
+//
+// Purpose:
+//
+// Handles the painting of the doc window.
+//
+//
+// Parameters:
+//
+// HDC hDC - hDC to the Doc Window.
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleDoc::PaintDoc DOC.CPP
+//
+// Comments:
+//
+// This is an app level function in case we want to do palette
+// management.
+//
+//********************************************************************
+
+void CSimpleApp::PaintApp (HDC hDC)
+{
+ // at this level, we could enumerate through all of the
+ // visible objects in the application, so that a palette
+ // that best fits all of the objects can be built.
+
+ // This app is designed to take on the same palette
+ // functionality that was provided in OLE 1.0, the palette
+ // of the last object drawn is realized. Since we only
+ // support one object at a time, it shouldn't be a big
+ // deal.
+
+ // if we supported multiple documents, we would enumerate
+ // through each of the open documents and call paint.
+
+ if (m_lpDoc)
+ m_lpDoc->PaintDoc(hDC);
+
+}
+
+//**********************************************************************
+//
+// CSimpleApp::ContextSensitiveHelp
+//
+// Purpose:
+// Used in supporting context sensitive help at the app level.
+//
+//
+// Parameters:
+//
+// BOOL fEnterMode - Entering/Exiting Context Sensitive
+// help mode.
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// IOleInPlaceActiveObject::QueryInterface Object
+// IOleInPlaceObject::ContextSensitiveHelp Object
+// IOleInPlaceObject::Release Object
+//
+// Comments:
+//
+// This function isn't used because we don't support Shift+F1
+// context sensitive help. Be sure to look at the technotes
+// in the OLE 2.0 toolkit.
+//
+//********************************************************************
+
+void CSimpleApp::ContextSensitiveHelp (BOOL fEnterMode)
+{
+ if (m_fCSHMode != fEnterMode)
+ {
+ m_fCSHMode = fEnterMode;
+
+ // this code "trickles" the context sensitive help via shift+f1
+ // to the inplace active object. See the technotes for implementation
+ // details.
+ if (m_lpDoc->m_lpActiveObject)
+ {
+ LPOLEINPLACEOBJECT lpInPlaceObject;
+ m_lpDoc->m_lpActiveObject->QueryInterface(IID_IOleInPlaceObject,
+ (LPVOID FAR *)&lpInPlaceObject);
+ lpInPlaceObject->ContextSensitiveHelp(fEnterMode);
+ lpInPlaceObject->Release();
+ }
+ }
+}
+
+/* OLE2NOTE: forward the WM_QUERYNEWPALETTE message (via
+** SendMessage) to UIActive in-place object if there is one.
+** this gives the UIActive object the opportunity to select
+** and realize its color palette as the FOREGROUND palette.
+** this is optional for in-place containers. if a container
+** prefers to force its color palette as the foreground
+** palette then it should NOT forward the this message. or
+** the container can give the UIActive object priority; if
+** the UIActive object returns 0 from the WM_QUERYNEWPALETTE
+** message (ie. it did not realize its own palette), then
+** the container can realize its palette.
+** (see ContainerDoc_ForwardPaletteChangedMsg for more info)
+**
+** (It is a good idea for containers to use the standard
+** palette even if they do not use colors themselves. this
+** will allow embedded object to get a good distribution of
+** colors when they are being drawn by the container)
+**
+*/
+
+//**********************************************************************
+//
+// CSimpleApp::QueryNewPalette
+//
+// Purpose:
+// See above
+//
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// 0 if the handle to palette (m_hStdPal) is NULL,
+// 1 otherwise
+//
+// Function Calls:
+// Function Location
+//
+// SendMessage Windows API
+//
+//
+//********************************************************************
+
+LRESULT CSimpleApp::QueryNewPalette(void)
+{
+ if (m_hwndUIActiveObj)
+ {
+ if (SendMessage(m_hwndUIActiveObj, WM_QUERYNEWPALETTE,
+ (WPARAM)0, (LPARAM)0))
+ {
+ /* Object selected its palette as foreground palette */
+ return (LRESULT)1;
+ }
+ }
+
+ return wSelectPalette(m_hAppWnd, m_hStdPal, FALSE/*fBackground*/);
+}
+
+
+/* This is just a helper routine */
+
+LRESULT wSelectPalette(HWND hWnd, HPALETTE hPal, BOOL fBackground)
+{
+ HDC hdc;
+ HPALETTE hOldPal;
+ UINT iPalChg = 0;
+
+ if (hPal == 0)
+ return (LRESULT)0;
+
+ hdc = GetDC(hWnd);
+ hOldPal = SelectPalette(hdc, hPal, fBackground);
+ iPalChg = RealizePalette(hdc);
+ SelectPalette(hdc, hOldPal, TRUE /*fBackground*/);
+ ReleaseDC(hWnd, hdc);
+
+ if (iPalChg > 0)
+ InvalidateRect(hWnd, NULL, TRUE);
+
+ return (LRESULT)1;
+}
+
+
diff --git a/private/oleutest/simpcntr/app.h b/private/oleutest/simpcntr/app.h
new file mode 100644
index 000000000..c00bcc3d7
--- /dev/null
+++ b/private/oleutest/simpcntr/app.h
@@ -0,0 +1,76 @@
+//**********************************************************************
+// File name: app.h
+//
+// Definition of CSimpleApp
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#if !defined( _APP_H_)
+#define _APP_H_
+
+#include <ole2.h>
+#include "ioipf.h"
+
+class CSimpleDoc;
+
+class CSimpleApp : public IUnknown
+{
+public:
+
+ int m_nCount; // reference count
+ HWND m_hAppWnd; // main window handle
+ HACCEL m_hAccel; // Handle to accelerator table
+ HINSTANCE m_hInst; // application instance
+
+ COleInPlaceFrame m_OleInPlaceFrame; // IOleInPlaceFrame Implementation
+
+ CSimpleDoc FAR * m_lpDoc; // pointer to document object
+ BOOL m_fInitialized; // OLE initialization flag
+ BOOL m_fCSHMode;
+ BOOL m_fMenuMode;
+ HWND m_hwndUIActiveObj; // HWND of UIActive Object
+ HPALETTE m_hStdPal; // Color palette used by container
+ BOOL m_fAppActive; // TRUE if app is active
+
+ BOOL m_fDeactivating; // TRUE if we are in the process of deactivating
+ // an inplace object.
+
+ BOOL m_fGotUtestAccelerator;// Received a unit test accelerator
+
+ HWND m_hDriverWnd; // Window of test driver
+
+ CSimpleApp(); // Constructor
+ ~CSimpleApp(); // Destructor
+ RECT nullRect;
+
+
+ // IUnknown Interfaces
+ STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ // Initialization methods
+
+ BOOL fInitApplication (HANDLE hInstance);
+ BOOL fInitInstance (HANDLE hInstance, int nCmdShow);
+
+ // Message handling methods
+
+ long lCommandHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ long lSizeHandler (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ long lCreateDoc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ BOOL HandleAccelerators (LPMSG lpMsg);
+ void PaintApp(HDC hDC);
+ void DestroyDocs();
+
+ // In-Place support functions
+ void AddFrameLevelUI();
+ void AddFrameLevelTools();
+ void ContextSensitiveHelp (BOOL fEnterMode);
+ LRESULT QueryNewPalette(void);
+};
+
+LRESULT wSelectPalette(HWND hWnd, HPALETTE hPal, BOOL fBackground);
+
+#endif
diff --git a/private/oleutest/simpcntr/daytona/makefile b/private/oleutest/simpcntr/daytona/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/oleutest/simpcntr/daytona/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/simpcntr/daytona/sources b/private/oleutest/simpcntr/daytona/sources
new file mode 100644
index 000000000..7755e3eff
--- /dev/null
+++ b/private/oleutest/simpcntr/daytona/sources
@@ -0,0 +1,43 @@
+TARGETNAME=SIMPCNTR
+TARGETTYPE=PROGRAM
+TARGETPATH=OBJ
+TARGETLIBS= \
+ $(GUI32_LIBS) \
+ $(WIN32_LIBS) \
+ $(CRT_LIBS) \
+ $(NT_CRT) \
+ $(LIBRARY_PATH)\ole32.lib \
+ $(LIBRARY_PATH)\shell32.lib \
+ $(LIBRARY_PATH)\comdlg32.lib \
+ ..\..\letest\ole2ui\daytona\obj\*\ole2u32a.lib \
+ $(LIBRARY_PATH)\uuid.lib
+
+# BUGBUG (2/14/94) - Change above to $(LIBRARY_PATH)\uuid.lib when types
+# project # adds IViewObject2 and IExternalConnections to its uuid.lib
+
+BLDCRT=1
+UMTYPE=windows
+UMENTRY=winmain
+#UMLIBS= \
+# ..\..\libs\daytona\*\common.lib
+
+INCLUDES=..;..\oletest;..\..\letest\ole2ui;..\..\inc
+
+C_DEFINES=-DWIN32 -DDEBUG -DCLIENT -DWINDOWS
+
+NTDEBUG=ntsd
+NTDEBUGTYPE=both
+MSC_OPTIMIZATION=/Od
+
+SOURCES= \
+..\APP.CPP \
+..\DOC.CPP \
+..\IAS.CPP \
+..\ioipf.cpp \
+..\ioips.cpp \
+..\IOCS.CPP \
+..\PRE.CPP \
+..\SIMPCNTR.CPP \
+..\SITE.CPP \
+..\SIMPCNTR.RC \
+..\TESTS.CPP
diff --git a/private/oleutest/simpcntr/dirs b/private/oleutest/simpcntr/dirs
new file mode 100644
index 000000000..e0e16d167
--- /dev/null
+++ b/private/oleutest/simpcntr/dirs
@@ -0,0 +1,3 @@
+DIRS=
+OPTIONAL_DIRS= \
+ daytona
diff --git a/private/oleutest/simpcntr/doc.cpp b/private/oleutest/simpcntr/doc.cpp
new file mode 100644
index 000000000..5d16dea5c
--- /dev/null
+++ b/private/oleutest/simpcntr/doc.cpp
@@ -0,0 +1,628 @@
+//**********************************************************************
+// File name: DOC.CPP
+//
+// Implementation file for CSimpleDoc.
+//
+// Functions:
+//
+// See DOC.H for Class Definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+//**********************************************************************
+//
+// CSimpleDoc::Create
+//
+// Purpose:
+//
+// Creation for the CSimpleDoc Class
+//
+// Parameters:
+//
+// CSimpleApp FAR * lpApp - Pointer to the CSimpleApp Class
+//
+// LPRECT lpRect - Client area rect of "frame" window
+//
+// HWND hWnd - Window Handle of "frame" window
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// StgCreateDocfile OLE API
+// CreateWindow Windows API
+// ShowWindow Windows API
+// UpdateWindow Windows API
+// EnableMenuItem Windows API
+//
+// Comments:
+//
+// This routine was added so that failure could be returned
+// from object creation.
+//
+//********************************************************************
+
+CSimpleDoc FAR * CSimpleDoc::Create(CSimpleApp FAR *lpApp, LPRECT lpRect,
+ HWND hWnd)
+{
+ CSimpleDoc FAR * lpTemp = new CSimpleDoc(lpApp, hWnd);
+
+ if (!lpTemp)
+ return NULL;
+
+ // create storage for the doc.
+ HRESULT hErr = StgCreateDocfile (NULL,
+ STGM_READWRITE | STGM_TRANSACTED |
+ STGM_SHARE_EXCLUSIVE,
+ 0, &lpTemp->m_lpStorage);
+
+ if (hErr != NOERROR)
+ goto error;
+
+ // create the document Window
+ lpTemp->m_hDocWnd = CreateWindow(
+ TEXT("SimpCntrDocWClass"),
+ NULL,
+ WS_CHILD | WS_CLIPCHILDREN,
+ lpRect->left,
+ lpRect->top,
+ lpRect->right,
+ lpRect->bottom,
+ hWnd,
+ NULL,
+ lpApp->m_hInst,
+ NULL);
+
+ if (!lpTemp->m_hDocWnd)
+ goto error;
+
+ ShowWindow(lpTemp->m_hDocWnd, SW_SHOWNORMAL); // Show the window
+ UpdateWindow(lpTemp->m_hDocWnd); // Sends WM_PAINT message
+
+ // Ensable InsertObject menu choice
+ EnableMenuItem( lpTemp->m_hEditMenu, 0, MF_BYPOSITION | MF_ENABLED);
+
+ // we will add one ref count on our document. later in CSimpleDoc::Close
+ // we will release this ref count. when the document's ref count goes
+ // to 0, the document will be deleted.
+ lpTemp->AddRef();
+
+ return (lpTemp);
+
+error:
+ delete (lpTemp);
+ return NULL;
+
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::Close
+//
+// Purpose:
+//
+// Close CSimpleDoc object.
+// when the document's reference count goes to 0, the document
+// will be destroyed.
+//
+// Parameters:
+// None
+//
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::CloseOleObject SITE.CPP
+// ShowWindow Windows API
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+void CSimpleDoc::Close(void)
+{
+ TestDebugOut(TEXT("In CSimpleDoc::Close\r\n"));
+
+ ShowWindow(m_hDocWnd, SW_HIDE); // Hide the window
+
+ // Close the OLE object in our document
+ if (m_lpSite)
+ m_lpSite->CloseOleObject();
+
+ // Release the ref count added in CSimpleDoc::Create. this will make
+ // the document's ref count go to 0, and the document will be deleted.
+ Release();
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::CSimpleDoc
+//
+// Purpose:
+//
+// Constructor for the CSimpleDoc Class
+//
+// Parameters:
+//
+// CSimpleApp FAR * lpApp - Pointer to the CSimpleApp Class
+//
+// HWND hWnd - Window Handle of "frame" window
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// GetMenu Windows API
+// GetSubMenu Windows API
+//
+//
+//********************************************************************
+
+CSimpleDoc::CSimpleDoc(CSimpleApp FAR * lpApp,HWND hWnd)
+{
+ TestDebugOut(TEXT("In CSimpleDoc's Constructor\r\n"));
+ m_lpApp = lpApp;
+ m_lpSite = NULL;
+ m_nCount = 0;
+ // set up menu handles
+ m_hMainMenu = GetMenu(hWnd);
+ m_hFileMenu = GetSubMenu(m_hMainMenu, 0);
+ m_hEditMenu = GetSubMenu(m_hMainMenu, 1);
+ m_hHelpMenu = GetSubMenu(m_hMainMenu, 2);
+ m_hCascadeMenu = NULL;
+
+ m_lpActiveObject = NULL;
+
+ // flags
+ m_fInPlaceActive = FALSE;
+ m_fAddMyUI = FALSE;
+ m_fModifiedMenu = FALSE;
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::~CSimpleDoc
+//
+// Purpose:
+//
+// Destructor for CSimpleDoc
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::UnloadOleObject SITE.CPP
+// CSimpleSite::Release SITE.CPP
+// IStorage::Release OLE API
+// GetMenuItemCount Windows API
+// RemoveMenu Windows API
+// DestroyMenu Windows API
+// DestroyWindows Windows API
+//
+//
+//********************************************************************
+
+CSimpleDoc::~CSimpleDoc()
+{
+ TestDebugOut(TEXT("In CSimpleDoc's Destructor\r\n"));
+
+ // Release all pointers we hold to the OLE object. also release
+ // the ref count added in CSimpleSite::Create. this will make
+ // the Site's ref count go to 0, and the Site will be deleted.
+ if (m_lpSite)
+ {
+ m_lpSite->UnloadOleObject();
+ m_lpSite->Release();
+ m_lpSite = NULL;
+ }
+
+ // Release the Storage
+ if (m_lpStorage)
+ {
+ m_lpStorage->Release();
+ m_lpStorage = NULL;
+ }
+
+ // if the edit menu was modified, remove the menu item and
+ // destroy the popup if it exists
+ if (m_fModifiedMenu)
+ {
+ int nCount = GetMenuItemCount(m_hEditMenu);
+ RemoveMenu(m_hEditMenu, nCount-1, MF_BYPOSITION);
+ if (m_hCascadeMenu)
+ DestroyMenu(m_hCascadeMenu);
+ }
+
+ DestroyWindow(m_hDocWnd);
+}
+
+
+//**********************************************************************
+//
+// CSimpleDoc::QueryInterface
+//
+// Purpose:
+//
+// interface negotiation at document level
+//
+// Parameters:
+//
+// REFIID riid - ID of interface to be returned
+// LPVOID FAR* ppvObj - Location to return the interface
+//
+// Return Value:
+//
+// E_NOINTERFACE - Always
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+// Comments:
+//
+// In this implementation, there are no doc level interfaces.
+// In an MDI application, there would be an IOleInPlaceUIWindow
+// associated with the document to provide document level tool
+// space negotiation.
+//
+//********************************************************************
+
+STDMETHODIMP CSimpleDoc::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In CSimpleDoc::QueryInterface\r\n"));
+
+ *ppvObj = NULL; // must set out pointer parameters to NULL
+
+ // Not a supported interface
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::AddRef
+//
+// Purpose:
+//
+// Increments the document reference count
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// UINT - The new reference count of CSimpleDoc
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleDoc::AddRef()
+{
+ TestDebugOut(TEXT("In CSimpleDoc::AddRef\r\n"));
+ return ++m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::Release
+//
+// Purpose:
+//
+// Decrements the document reference count
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// UINT - The new reference count of CSimpleDoc
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleDoc::Release()
+{
+ TestDebugOut(TEXT("In CSimpleDoc::Release\r\n"));
+
+ if (--m_nCount == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::InsertObject
+//
+// Purpose:
+//
+// Inserts a new object to this document
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::CSimpleSite SITE.CPP
+// CSimpleSite::InitObject SITE.CPP
+// CSimpleSite::Release SITE.CPP
+// memset C Runtime
+// OleUIInsertObject OLE2UI function
+// CSimpleDoc::DisableInsertObject DOC.CPP
+// IStorage::Revert OLE API
+//
+// Comments:
+//
+// This implementation only allows one object to be inserted
+// into a document. Once the object has been inserted, then
+// the Insert Object menu choice is greyed out, to prevent
+// the user from inserting another.
+//
+//********************************************************************
+
+void CSimpleDoc::InsertObject()
+{
+ OLEUIINSERTOBJECT io;
+ UINT iret;
+ TCHAR szFile[OLEUI_CCHPATHMAX];
+
+ m_lpSite = CSimpleSite::Create(this);
+
+ if (!m_lpSite)
+ {
+ /* memory allocation problem! cannot carry on.
+ */
+ TestDebugOut(TEXT("Memory allocation error!\n"));
+ return;
+ }
+
+ // clear the structure
+ _fmemset(&io, 0, sizeof(OLEUIINSERTOBJECT));
+
+ // fill the structure
+ io.cbStruct = sizeof(OLEUIINSERTOBJECT);
+ io.dwFlags = IOF_SELECTCREATENEW | IOF_DISABLELINK |
+ IOF_DISABLEDISPLAYASICON | IOF_CREATENEWOBJECT |
+ IOF_CREATEFILEOBJECT;
+ io.hWndOwner = m_hDocWnd;
+ io.lpszCaption = (LPTSTR) TEXT("Insert Object");
+ io.iid = IID_IOleObject;
+ io.oleRender = OLERENDER_DRAW;
+ io.lpIOleClientSite = &m_lpSite->m_OleClientSite;
+ io.lpIStorage = m_lpSite->m_lpObjStorage;
+ io.ppvObj = (LPVOID FAR *)&m_lpSite->m_lpOleObject;
+ io.lpszFile = szFile;
+ io.cchFile = sizeof(szFile)/sizeof(TCHAR);
+ // cchFile is the number of characters of szFile
+ _fmemset((LPTSTR)szFile, 0, sizeof(szFile));
+
+ // call OUTLUI to do all the hard work
+ iret = OleUIInsertObject(&io);
+
+ if (iret == OLEUI_OK)
+ {
+ m_lpSite->InitObject((BOOL)(io.dwFlags & IOF_SELECTCREATENEW));
+ // disable Insert Object menu item
+ DisableInsertObject();
+ }
+ else
+ {
+ m_lpSite->Release();
+ m_lpSite = NULL;
+ m_lpStorage->Revert();
+ }
+
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::lResizeDoc
+//
+// Purpose:
+//
+// Resizes the document
+//
+// Parameters:
+//
+// LPRECT lpRect - The size of the client are of the "frame"
+// Window.
+//
+// Return Value:
+//
+// NULL
+//
+// Function Calls:
+// Function Location
+//
+// IOleInPlaceActiveObject::ResizeBorder Object
+// MoveWindow Windows API
+//
+//
+//********************************************************************
+
+long CSimpleDoc::lResizeDoc(LPRECT lpRect)
+{
+ // if we are InPlace, then call ResizeBorder on the object, otherwise
+ // just move the document window.
+ if (m_fInPlaceActive)
+ m_lpActiveObject->ResizeBorder(lpRect, &m_lpApp->m_OleInPlaceFrame,
+ TRUE);
+ else
+ MoveWindow(m_hDocWnd, lpRect->left, lpRect->top, lpRect->right,
+ lpRect->bottom, TRUE);
+
+ return NULL;
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::lAddVerbs
+//
+// Purpose:
+//
+// Adds the objects verbs to the edit menu.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// NULL
+//
+// Function Calls:
+// Function Location
+//
+// GetMenuItemCount Windows API
+// OleUIAddVerbMenu OLE2UI function
+//
+//
+//********************************************************************
+
+long CSimpleDoc::lAddVerbs(void)
+{
+ // m_fModifiedMenu is TRUE if the menu has already been modified
+ // once. Since we only support one obect every time the application
+ // is run, then once the menu is modified, it doesn't have
+ // to be done again.
+ if (m_lpSite && !m_fInPlaceActive && !m_fModifiedMenu)
+ {
+ int nCount = GetMenuItemCount(m_hEditMenu);
+
+ if (!OleUIAddVerbMenu ( m_lpSite->m_lpOleObject,
+ NULL,
+ m_hEditMenu,
+ nCount + 1,
+ IDM_VERB0,
+ 0, // no maximum verb IDM enforced
+ FALSE,
+ 0,
+ &m_hCascadeMenu))
+ {
+ TestDebugOut(TEXT("Fail in OleUIAddVerbMenu"));
+ }
+
+ m_fModifiedMenu = TRUE;
+ }
+ return (NULL);
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::PaintDoc
+//
+// Purpose:
+//
+// Paints the Document
+//
+// Parameters:
+//
+// HDC hDC - hDC of the document Window
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::PaintObj SITE.CPP
+//
+//
+//********************************************************************
+
+void CSimpleDoc::PaintDoc (HDC hDC)
+{
+ // if we supported multiple objects, then we would enumerate
+ // the objects and call paint on each of them from here.
+
+ if (m_lpSite)
+ m_lpSite->PaintObj(hDC);
+
+}
+
+//**********************************************************************
+//
+// CSimpleDoc::DisableInsertObject
+//
+// Purpose:
+//
+// Disable the ability to insert a new object in this document.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// EnableMenuItem Windows API
+//
+// Comments:
+//
+// This implementation only allows one object to be inserted
+// into a document. Once the object has been inserted, then
+// the Insert Object menu choice is greyed out, to prevent
+// the user from inserting another.
+//
+//********************************************************************
+
+void CSimpleDoc::DisableInsertObject(void)
+{
+ // Disable InsertObject menu choice
+ EnableMenuItem( m_hEditMenu, 0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
+}
diff --git a/private/oleutest/simpcntr/doc.h b/private/oleutest/simpcntr/doc.h
new file mode 100644
index 000000000..40aab5d1a
--- /dev/null
+++ b/private/oleutest/simpcntr/doc.h
@@ -0,0 +1,55 @@
+//**********************************************************************
+// File name: doc.h
+//
+// Definition of CSimpleDoc
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#if !defined( _DOC_H_ )
+#define _DOC_H_
+
+class CSimpleSite;
+class CSimpleApp;
+
+class CSimpleDoc : public IUnknown
+{
+public:
+ int m_nCount;
+ LPSTORAGE m_lpStorage;
+ HMENU m_hMainMenu;
+ HMENU m_hFileMenu;
+ HMENU m_hEditMenu;
+ HMENU m_hHelpMenu;
+ HMENU m_hCascadeMenu;
+ LPOLEINPLACEACTIVEOBJECT m_lpActiveObject;
+ BOOL m_fInPlaceActive;
+ BOOL m_fAddMyUI;
+ BOOL m_fModifiedMenu;
+
+ CSimpleSite FAR * m_lpSite;
+ CSimpleApp FAR * m_lpApp;
+
+ HWND m_hDocWnd;
+
+ static CSimpleDoc FAR * Create(CSimpleApp FAR *lpApp, LPRECT lpRect,HWND hWnd);
+
+ void Close(void);
+
+ CSimpleDoc();
+ CSimpleDoc(CSimpleApp FAR *lpApp, HWND hWnd);
+ ~CSimpleDoc();
+
+ // IUnknown Interface
+ STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ void InsertObject(void);
+ void DisableInsertObject(void);
+ long lResizeDoc(LPRECT lpRect);
+ long lAddVerbs(void);
+ void PaintDoc(HDC hDC);
+};
+
+#endif
diff --git a/private/oleutest/simpcntr/ias.cpp b/private/oleutest/simpcntr/ias.cpp
new file mode 100644
index 000000000..749bdef7b
--- /dev/null
+++ b/private/oleutest/simpcntr/ias.cpp
@@ -0,0 +1,304 @@
+//**********************************************************************
+// File name: IAS.CPP
+//
+// Implementation file of CAdviseSink
+//
+//
+// Functions:
+//
+// See IAS.H for Class Definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+//**********************************************************************
+//
+// CAdviseSink::QueryInterface
+//
+// Purpose:
+//
+// used for interface negotiation
+//
+// Parameters:
+//
+// REFIID riid - The requested interface
+//
+// LPVOID FAR* ppvObj - Place to return the interface
+//
+// Return Value:
+//
+// HRESULT from CSimpleSite::QueryInterface
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::QueryInterface SITE.CPP
+// TestDebugOut Windows API
+//
+// Comments:
+//
+// This function simply delegates to the Object class, which is
+// aware of the supported interfaces.
+//
+//********************************************************************
+
+STDMETHODIMP CAdviseSink::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In IAS::QueryInterface\r\n"));
+
+ // delegate to the document Object
+ return m_pSite->QueryInterface(riid, ppvObj);
+}
+
+//**********************************************************************
+//
+// CAdviseSink::AddRef
+//
+// Purpose:
+//
+// Increments the reference count of CSimpleSite. Since CAdviseSink is
+// a nested class of CSimpleSite, we don't need to have a separate
+// reference count for CAdviseSink. We can safely use the reference
+// count of CSimpleSite.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::AddReff SITE.CPP
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CAdviseSink::AddRef()
+{
+ TestDebugOut(TEXT("In IAS::AddRef\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->AddRef();
+}
+
+//**********************************************************************
+//
+// CAdviseSink::Release
+//
+// Purpose:
+//
+// Decrements the reference count of CSimpleSite. Since CAdviseSink is
+// a nested class of CSimpleSite, we don't need to have a separate
+// reference count for CAdviseSink. We can safely use the reference
+// count of CSimpleSite.
+//
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::Release SITE.CPP
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CAdviseSink::Release()
+{
+ TestDebugOut(TEXT("In IAS::Release\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->Release();
+}
+
+//**********************************************************************
+//
+// CAdviseSink::OnDataChange
+//
+// Purpose:
+//
+// Not Implemented (needs to be stubbed out)
+//
+// Parameters:
+//
+// FORMATETC pFormatetc - data format info that was originally set up
+// STGMEDIUM pStgmed - storage medium which data is passed
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(void) CAdviseSink::OnDataChange (FORMATETC FAR* pFormatetc,
+ STGMEDIUM FAR* pStgmed)
+{
+ TestDebugOut(TEXT("In IAS::OnDataChange\r\n"));
+}
+
+//**********************************************************************
+//
+// CAdviseSink::OnViewChange
+//
+// Purpose:
+//
+// Notifies us that the view has changed and needs to be updated.
+//
+// Parameters:
+//
+// DWORD dwAspect - Aspect that has changed
+//
+// LONG lindex - Index that has changed
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// InvalidateRect Windows API
+// IOleObject::QueryInterface Object
+// IViewObject2::GetExtent Object
+// IViewObject2::Release Object
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(void) CAdviseSink::OnViewChange (DWORD dwAspect, LONG lindex)
+{
+ LPVIEWOBJECT2 lpViewObject2;
+
+ TestDebugOut(TEXT("In IAS::OnViewChange\r\n"));
+
+ // get a pointer to IViewObject2
+ HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(
+ IID_IViewObject2,(LPVOID FAR *)&lpViewObject2);
+
+ if (hErr == NOERROR)
+ {
+ // get extent of the object
+ // NOTE: this method will never be remoted; it can be called w/i
+ // this async method
+ lpViewObject2->GetExtent(DVASPECT_CONTENT, -1 , NULL,
+ &m_pSite->m_sizel);
+ lpViewObject2->Release();
+ }
+
+ InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
+}
+
+//**********************************************************************
+//
+// CAdviseSink::OnRename
+//
+// Purpose:
+//
+// Not Implemented (needs to be stubbed out)
+//
+// Parameters:
+//
+// LPMONIKER pmk - new name of the object
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(void) CAdviseSink::OnRename (LPMONIKER pmk)
+{
+ TestDebugOut(TEXT("In IAS::OnRename\r\n"));
+}
+
+//**********************************************************************
+//
+// CAdviseSink::OnSave
+//
+// Purpose:
+//
+// Not Implemented (needs to be stubbed out)
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(void) CAdviseSink::OnSave ()
+{
+ TestDebugOut(TEXT("In IAS::OnSave\r\n"));
+}
+
+//**********************************************************************
+//
+// CAdviseSink::OnClose
+//
+// Purpose:
+//
+// Not Implemented (needs to be stubbed out)
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(void) CAdviseSink::OnClose()
+{
+ TestDebugOut(TEXT("In IAS::OnClose\r\n"));
+}
diff --git a/private/oleutest/simpcntr/ias.h b/private/oleutest/simpcntr/ias.h
new file mode 100644
index 000000000..cd15e5bb3
--- /dev/null
+++ b/private/oleutest/simpcntr/ias.h
@@ -0,0 +1,44 @@
+//**********************************************************************
+// File name: IAS.H
+//
+// Definition of CAdviseSink
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#if !defined( _IAS_H_ )
+#define _IAS_H_
+
+#include <assert.h>
+
+class CSimpleSite;
+
+interface CAdviseSink : public IAdviseSink
+{
+ CSimpleSite FAR * m_pSite;
+
+ CAdviseSink(CSimpleSite FAR * pSite)
+ {
+ TestDebugOut(TEXT("In IAS's constructor\r\n"));
+ m_pSite = pSite;
+ };
+
+ ~CAdviseSink()
+ {
+ TestDebugOut(TEXT("In IAS's destructor\r\n"));
+ } ;
+
+ STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
+ STDMETHODIMP_(ULONG) AddRef ();
+ STDMETHODIMP_(ULONG) Release ();
+
+ // *** IAdviseSink methods ***
+ STDMETHODIMP_(void) OnDataChange (FORMATETC FAR* pFormatetc,
+ STGMEDIUM FAR* pStgmed);
+ STDMETHODIMP_(void) OnViewChange (DWORD dwAspect, LONG lindex);
+ STDMETHODIMP_(void) OnRename (LPMONIKER pmk);
+ STDMETHODIMP_(void) OnSave ();
+ STDMETHODIMP_(void) OnClose ();
+};
+
+
+#endif
diff --git a/private/oleutest/simpcntr/iocs.cpp b/private/oleutest/simpcntr/iocs.cpp
new file mode 100644
index 000000000..d11754290
--- /dev/null
+++ b/private/oleutest/simpcntr/iocs.cpp
@@ -0,0 +1,368 @@
+//**********************************************************************
+// File name: IOCS.CPP
+//
+// Implementation file for COleClientSite
+//
+// Functions:
+//
+// See IOCS.H for class definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+
+//**********************************************************************
+//
+// COleClientSite::QueryInterface
+//
+// Purpose:
+//
+// Used for interface negotiation
+//
+// Parameters:
+//
+// REFIID riid - A reference to the interface that is
+// being queried.
+//
+// LPVOID FAR* ppvObj - An out parameter to return a pointer to
+// the interface.
+//
+// Return Value:
+//
+// S_OK - The interface is supported.
+// E_NOINTERFACE - The interface is not supported
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::QueryInterface SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In IOCS::QueryInterface\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->QueryInterface(riid, ppvObj);
+}
+
+//**********************************************************************
+//
+// COleClientSite::AddRef
+//
+// Purpose:
+//
+// Increments the reference count of CSimpleSite. Since COleClientSite
+// is a nested class of CSimpleSite, we don't need to have a separate
+// reference count for COleClientSite. We can safely use the reference
+// count of CSimpleSite.
+//
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::AddRef SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleClientSite::AddRef()
+{
+ TestDebugOut(TEXT("In IOCS::AddRef\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->AddRef();
+}
+
+
+//**********************************************************************
+//
+// COleClientSite::Release
+//
+// Purpose:
+//
+// Decrements the reference count of CSimpleSite. Since COleClientSite
+// is a nested class of CSimpleSite, we don't need to have a separate
+// reference count for COleClientSite. We can safely use the reference
+// count of CSimpleSite.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::Release SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleClientSite::Release()
+{
+ TestDebugOut(TEXT("In IOCS::Release\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->Release();
+}
+
+//**********************************************************************
+//
+// COleClientSite::SaveObject
+//
+// Purpose:
+//
+// Called by the object when it wants to be saved to persistant
+// storage
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IOleObject::QueryInterface Object
+// IPersistStorage::SaveCompleted Object
+// IPersistStorage::Release Object
+// OleSave OLE API
+// GetScode OLE API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::SaveObject()
+{
+ LPPERSISTSTORAGE lpPS;
+ SCODE sc = E_FAIL;
+
+ TestDebugOut(TEXT("In IOCS::SaveObject\r\n"));
+
+ // get a pointer to IPersistStorage
+ HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(IID_IPersistStorage,
+ (LPVOID FAR *)&lpPS);
+
+ // save the object
+ if (hErr == NOERROR)
+ {
+ sc = GetScode( OleSave(lpPS, m_pSite->m_lpObjStorage, TRUE) );
+ lpPS->SaveCompleted(NULL);
+ lpPS->Release();
+ }
+
+ return ResultFromScode(sc);
+}
+
+//**********************************************************************
+//
+// COleClientSite::GetMoniker
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// DWORD dwAssign - type of moniker to return
+// DWORD dwWhichMoniker - which moniker to return
+//
+// Return Value:
+// E_NOTIMPL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+// Comments:
+//
+// This function is not implemented because we don't support
+// linking.
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER FAR* ppmk)
+{
+ TestDebugOut(TEXT("In IOCS::GetMoniker\r\n"));
+
+ // need to null the out pointer
+ *ppmk = NULL;
+
+ return ResultFromScode(E_NOTIMPL);
+}
+
+//**********************************************************************
+//
+// COleClientSite::GetContainer
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// LPOLECONTAINER FAR * ppContainer - where IOleContainer interface
+// pointer to be returned
+//
+// Return Value:
+//
+// E_NOTIMPL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
+{
+ TestDebugOut(TEXT("In IOCS::GetContainer\r\n"));
+
+ // NULL the out pointer
+ *ppContainer = NULL;
+
+ return ResultFromScode(E_NOTIMPL);
+}
+
+//**********************************************************************
+//
+// COleClientSite::ShowObject
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// NOERROR
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+// Comments:
+//
+// This function is not implemented because we don't support
+// linking.
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::ShowObject()
+{
+ TestDebugOut(TEXT("In IOCS::ShowObject\r\n"));
+ return NOERROR;
+}
+
+//**********************************************************************
+//
+// COleClientSite::OnShowWindow
+//
+// Purpose:
+//
+// Object calls this method when it is opening/closing non-InPlace
+// Window
+//
+// Parameters:
+//
+// BOOL fShow - TRUE if Window is opening, FALSE if closing
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// InvalidateRect Windows API
+// BringWindowToTop Windows API
+// SetFocus Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::OnShowWindow(BOOL fShow)
+{
+ TestDebugOut(TEXT("In IOCS::OnShowWindow\r\n"));
+ m_pSite->m_fObjectOpen = fShow;
+ InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
+
+ // if object window is closing, then bring container window to top
+ if (! fShow)
+ {
+ BringWindowToTop(m_pSite->m_lpDoc->m_hDocWnd);
+ SetFocus(m_pSite->m_lpDoc->m_hDocWnd);
+ }
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleClientSite::RequestNewObjectLayout
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// E_NOTIMPL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleClientSite::RequestNewObjectLayout()
+{
+ TestDebugOut(TEXT("In IOCS::RequestNewObjectLayout\r\n"));
+ return ResultFromScode(E_NOTIMPL);
+}
diff --git a/private/oleutest/simpcntr/iocs.h b/private/oleutest/simpcntr/iocs.h
new file mode 100644
index 000000000..1bd9f66b5
--- /dev/null
+++ b/private/oleutest/simpcntr/iocs.h
@@ -0,0 +1,44 @@
+//**********************************************************************
+// File name: IOCS.H
+//
+// Definition of COleClientSite
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#if !defined( _IOCS_H_ )
+#define _IOCS_H_
+
+#include <assert.h>
+
+class CSimpleSite;
+
+interface COleClientSite : public IOleClientSite
+{
+ CSimpleSite FAR * m_pSite;
+
+ COleClientSite(CSimpleSite FAR * pSite)
+ {
+ TestDebugOut(TEXT("In IOCS's constructor\r\n"));
+ m_pSite = pSite;
+ }
+
+ ~COleClientSite()
+ {
+ TestDebugOut(TEXT("In IOCS's destructor\r\n"));
+ }
+
+ STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ // *** IOleClientSite methods ***
+ STDMETHODIMP SaveObject();
+ STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
+ LPMONIKER FAR* ppmk);
+ STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
+ STDMETHODIMP ShowObject();
+ STDMETHODIMP OnShowWindow(BOOL fShow);
+ STDMETHODIMP RequestNewObjectLayout();
+};
+
+#endif
diff --git a/private/oleutest/simpcntr/ioipf.cpp b/private/oleutest/simpcntr/ioipf.cpp
new file mode 100644
index 000000000..ca4a0d9af
--- /dev/null
+++ b/private/oleutest/simpcntr/ioipf.cpp
@@ -0,0 +1,641 @@
+//**********************************************************************
+// File name: IOIPF.CPP
+//
+// Implementation file for COleInPlaceFrame
+//
+// Functions:
+//
+// See IOIPF.H for class definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+
+//**********************************************************************
+//
+// COleInPlaceFrame::QueryInterface
+//
+// Purpose:
+//
+// Used for interface negotiation
+//
+// Parameters:
+//
+// REFIID riid - A reference to the interface that is
+// being queried.
+//
+// LPVOID FAR* ppvObj - An out parameter to return a pointer to
+// the interface.
+//
+// Return Value:
+//
+// S_OK - The interface is supported.
+// E_NOINTERFACE - The interface is not supported
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleApp::QueryInterface APP.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In IOIPF::QueryInterface\r\n"));
+
+ // delegate to the application Object
+ return m_pApp->QueryInterface(riid, ppvObj);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::AddRef
+//
+// Purpose:
+//
+// Increments the reference count of the CSimpleApp. Since
+// COleInPlaceFrame is a nested class of CSimpleApp, we don't need an
+// extra reference count for COleInPlaceFrame. We can safely use the
+// reference count of CSimpleApp.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of the CSimpleApp
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleApp::AddRef APP.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleInPlaceFrame::AddRef()
+{
+ TestDebugOut(TEXT("In IOIPF::AddRef\r\n"));
+
+ // delegate to the application Object
+ return m_pApp->AddRef();
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::Release
+//
+// Purpose:
+//
+// Decrements the reference count of the CSimpleApp. Since
+// COleInPlaceFrame is a nested class of CSimpleApp, we don't need an
+// extra reference count for COleInPlaceFrame. We can safely use the
+// reference count of CSimpleApp.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of CSimpleApp.
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleApp::Release APP.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleInPlaceFrame::Release()
+{
+ TestDebugOut(TEXT("In IOIPF::Release\r\n"));
+
+ // delegate to the document object
+ return m_pApp->Release();
+
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::GetWindow
+//
+// Purpose:
+//
+// Returns the frame window handle
+//
+// Parameters:
+//
+// HWND FAR* lphwnd - Location to return the window handle
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::GetWindow (HWND FAR* lphwnd)
+{
+ TestDebugOut(TEXT("In IOIPF::GetWindow\r\n"));
+ *lphwnd = m_pApp->m_hAppWnd;
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::ContextSensitiveHelp
+//
+// Purpose:
+//
+// Used in implementing Context sensitive help
+//
+// Parameters:
+//
+// BOOL fEnterMode - TRUE if starting Context Sensitive help mode
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+// Comments:
+//
+// Be sure to read the technotes in the OLE toolkit.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::ContextSensitiveHelp (BOOL fEnterMode)
+{
+ TestDebugOut(TEXT("In IOIPF::ContextSensitiveHelp\r\n"));
+
+ m_pApp->m_fMenuMode = fEnterMode;
+
+ return ResultFromScode(S_OK);
+}
+//**********************************************************************
+//
+// COleInPlaceFrame::GetBorder
+//
+// Purpose:
+//
+// Returns the outermost border that frame adornments can be attached
+// during InPlace Activation.
+//
+// Parameters:
+//
+// LPRECT lprectBorder - return parameter to contain the outermost
+// rect for frame adornments
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// GetClientRect Windows API
+// CopyRect Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::GetBorder (LPRECT lprectBorder)
+{
+ RECT rect;
+
+ TestDebugOut(TEXT("In IOIPF::GetBorder\r\n"));
+
+ // get the rect for the entire frame.
+ GetClientRect(m_pApp->m_hAppWnd, &rect);
+
+ CopyRect(lprectBorder, &rect);
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::RequestBorderSpace
+//
+// Purpose:
+//
+// Approves/Denies requests for border space during InPlace
+// negotiation.
+//
+// Parameters:
+//
+// LPCBORDERWIDTHS lpborderwidths - The width in pixels needed on
+// each side of the frame.
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+// Comments:
+//
+// This implementation doesn't care about how much border space
+// is used. It always returns S_OK.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::RequestBorderSpace (LPCBORDERWIDTHS
+ lpborderwidths)
+{
+ TestDebugOut(TEXT("In IOIPF::RequestBorderSpace\r\n"));
+
+ // always approve the request
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::SetBorderSpace
+//
+// Purpose:
+//
+// The object calls this method when it is actually going to
+// start using the border space.
+//
+// Parameters:
+//
+// LPCBORDERWIDTHS lpborderwidths - Border space actually being used
+// by the object
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleApp::AddFrameLevelTools APP.CPP
+// TestDebugOut Windows API
+// GetClientRect Windows API
+// MoveWindow Windows API
+// ResultFromScode Windows API
+//
+// Comments:
+//
+// This routine could be a little smarter and check to see if
+// the object is requesting the entire client area of the
+// window.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::SetBorderSpace (LPCBORDERWIDTHS lpborderwidths)
+{
+
+ TestDebugOut(TEXT("In IOIPF::SetBorderSpace\r\n"));
+
+ if (lpborderwidths == NULL)
+ m_pApp->AddFrameLevelTools();
+ else
+ {
+ RECT rect;
+
+ GetClientRect(m_pApp->m_hAppWnd, &rect);
+
+ MoveWindow( m_pApp->m_lpDoc->m_hDocWnd,
+ rect.left + lpborderwidths->left,
+ rect.top + lpborderwidths->top,
+ rect.right - lpborderwidths->right - lpborderwidths->left,
+ rect.bottom - lpborderwidths->bottom - lpborderwidths->top,
+ TRUE);
+ }
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::SetActiveObject
+//
+// Purpose:
+// install the object being activated in-place
+//
+//
+// Parameters:
+//
+// LPOLEINPLACEACTIVEOBJECT lpActiveObject - Pointer to the
+// objects
+// IOleInPlaceActiveObject
+// interface
+//
+// LPCOLESTR lpszObjName - Name of the object
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IOleInPlaceActiveObject::AddRef Object
+// IOleInPlaceActiveObject::Release Object
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::SetActiveObject (LPOLEINPLACEACTIVEOBJECT
+ lpActiveObject, LPCOLESTR lpszObjName)
+{
+
+ TestDebugOut(TEXT("In IOIPF::SetActiveObject\r\n"));
+
+ // AddRef() it and save it...
+ if (lpActiveObject)
+ {
+ lpActiveObject->AddRef();
+
+ lpActiveObject->GetWindow(&m_pApp->m_hwndUIActiveObj);
+ if (m_pApp->m_hwndUIActiveObj)
+ SendMessage(m_pApp->m_hwndUIActiveObj, WM_QUERYNEWPALETTE, 0, 0L);
+ }
+ else
+ {
+ if (m_pApp->m_lpDoc->m_lpActiveObject)
+ m_pApp->m_lpDoc->m_lpActiveObject->Release();
+ m_pApp->m_hwndUIActiveObj = NULL;
+ }
+
+ // in an MDI app, this method really shouldn't be called,
+ // this method associated with the doc is called instead.
+
+ m_pApp->m_lpDoc->m_lpActiveObject = lpActiveObject;
+ // should set window title here
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::InsertMenus
+//
+// Purpose:
+//
+// Inserts the container menu into the combined menu
+//
+// Parameters:
+//
+// HMENU hmenuShared - Menu Handle to be set.
+// LPOLEMENUGROUPWIDTHS lpMenuWidths - Width of menus
+//
+// Return Value:
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// AppendMenu Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::InsertMenus (HMENU hmenuShared,
+ LPOLEMENUGROUPWIDTHS lpMenuWidths)
+{
+ TestDebugOut(TEXT("In IOIPF::InsertMenus\r\n"));
+
+ AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP,
+ (UINT) m_pApp->m_lpDoc->m_hFileMenu, TEXT("&File"));
+ AppendMenu(hmenuShared, MF_BYPOSITION | MF_POPUP,
+ (UINT) m_pApp->m_lpDoc->m_hHelpMenu, TEXT("&Other"));
+
+ lpMenuWidths->width[0] = 1;
+ lpMenuWidths->width[2] = 0;
+ lpMenuWidths->width[4] = 1;
+
+ return ResultFromScode(S_OK);
+}
+
+
+//**********************************************************************
+//
+// COleInPlaceFrame::SetMenu
+//
+// Purpose:
+//
+// Sets the application menu to the combined menu
+//
+// Parameters:
+//
+// HMENU hmenuShared - The combined menu
+//
+// HOLEMENU holemenu - Used by OLE
+//
+// HWND hwndActiveObject - Used by OLE
+//
+// Return Value:
+//
+// S_OK - if menu was correctly installed
+// E_FAIL - otherwise
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// SetMenu Windows API
+// OleSetMenuDescriptor OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::SetMenu (HMENU hmenuShared, HOLEMENU holemenu,
+ HWND hwndActiveObject)
+{
+
+ TestDebugOut(TEXT("In IOIPF::SetMenu\r\n"));
+
+ HMENU hMenu = m_pApp->m_lpDoc->m_hMainMenu;
+
+ if (holemenu)
+ hMenu = hmenuShared;
+
+ // call the windows api, not this method
+ ::SetMenu (m_pApp->m_hAppWnd, hMenu);
+
+ HRESULT hRes = OleSetMenuDescriptor(holemenu, m_pApp->m_hAppWnd,
+ hwndActiveObject, this,
+ m_pApp->m_lpDoc->m_lpActiveObject);
+
+ return hRes;
+}
+
+
+//**********************************************************************
+//
+// COleInPlaceFrame::RemoveMenus
+//
+// Purpose:
+//
+// Removes the container menus from the combined menu
+//
+// Parameters:
+//
+// HMENU hmenuShared - Handle to the combined menu.
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// GetMenuItemCount Windows API
+// RemoveMenu Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::RemoveMenus (HMENU hmenuShared)
+{
+ int retval;
+
+ TestDebugOut(TEXT("In IOIPF::RemoveMenus\r\n"));
+
+ while ((retval = GetMenuItemCount(hmenuShared)) && (retval != -1))
+ RemoveMenu(hmenuShared, 0, MF_BYPOSITION);
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::SetStatusText
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// LPCOLESTR lpszStatusText - character string containing the message
+//
+// Return Value:
+//
+// E_FAIL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+// Comments:
+//
+// This function is not implemented due to the fact
+// that this application does not have a status bar.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::SetStatusText (LPCOLESTR lpszStatusText)
+{
+ TestDebugOut(TEXT("In IOIPF::SetStatusText\r\n"));
+ return ResultFromScode(E_FAIL);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::EnableModeless
+//
+// Purpose:
+//
+// Enables/Disables container modeless dialogs
+//
+// Parameters:
+//
+// BOOL fEnable - Enable/Disable
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+// Comments:
+//
+// There are no modeless dialogs in this application, so the
+// implementation of this method is trivial.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::EnableModeless (BOOL fEnable)
+{
+ TestDebugOut(TEXT("In IOIPF::EnableModeless\r\n"));
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceFrame::TranslateAccelerator
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// LPMSG lpmsg - structure containing keystroke message
+// WORD wID - identifier value corresponding to the keystroke
+//
+// Return Value:
+//
+// S_FALSE
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceFrame::TranslateAccelerator (LPMSG lpmsg, WORD wID)
+{
+ TestDebugOut(TEXT("In IOIPF::TranslateAccelerator\r\n"));
+ return ::TranslateAccelerator(m_pApp->m_hAppWnd, m_pApp->m_hAccel, lpmsg)
+ ? ResultFromScode(S_OK)
+ : ResultFromScode(S_FALSE);
+}
diff --git a/private/oleutest/simpcntr/ioipf.h b/private/oleutest/simpcntr/ioipf.h
new file mode 100644
index 000000000..e32edcca5
--- /dev/null
+++ b/private/oleutest/simpcntr/ioipf.h
@@ -0,0 +1,51 @@
+//**********************************************************************
+// File name: IOIPF.H
+//
+// Definition of COleInPlaceFrame
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#if !defined( _IOIPF_H_ )
+#define _IOIPF_H_
+
+
+class CSimpleApp;
+
+interface COleInPlaceFrame : public IOleInPlaceFrame
+{
+ CSimpleApp FAR * m_pApp;
+
+ COleInPlaceFrame(CSimpleApp FAR * pApp)
+ {
+ TestDebugOut(TEXT("In IOIPF's constructor\r\n"));
+ m_pApp = pApp;
+ };
+
+ ~COleInPlaceFrame()
+ {
+ TestDebugOut(TEXT("In IOIPFS's destructor\r\n"));
+ };
+
+ STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
+ STDMETHODIMP_(ULONG) AddRef ();
+ STDMETHODIMP_(ULONG) Release ();
+
+ STDMETHODIMP GetWindow (HWND FAR* lphwnd);
+ STDMETHODIMP ContextSensitiveHelp (BOOL fEnterMode);
+
+ // *** IOleInPlaceUIWindow methods ***
+ STDMETHODIMP GetBorder (LPRECT lprectBorder);
+ STDMETHODIMP RequestBorderSpace (LPCBORDERWIDTHS lpborderwidths);
+ STDMETHODIMP SetBorderSpace (LPCBORDERWIDTHS lpborderwidths);
+ STDMETHODIMP SetActiveObject (LPOLEINPLACEACTIVEOBJECT lpActiveObject,LPCOLESTR lpszObjName);
+
+ // *** IOleInPlaceFrame methods ***
+ STDMETHODIMP InsertMenus (HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
+ STDMETHODIMP SetMenu (HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
+ STDMETHODIMP RemoveMenus (HMENU hmenuShared);
+ STDMETHODIMP SetStatusText (LPCOLESTR lpszStatusText);
+ STDMETHODIMP EnableModeless (BOOL fEnable);
+ STDMETHODIMP TranslateAccelerator (LPMSG lpmsg, WORD wID);
+};
+
+#endif
diff --git a/private/oleutest/simpcntr/ioips.cpp b/private/oleutest/simpcntr/ioips.cpp
new file mode 100644
index 000000000..f8a97be22
--- /dev/null
+++ b/private/oleutest/simpcntr/ioips.cpp
@@ -0,0 +1,615 @@
+//**********************************************************************
+// File name: IOIPS.CPP
+//
+// Implementation file for COleInPlaceSite
+//
+// Functions:
+//
+// See IOIPS.H for class Definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+//**********************************************************************
+//
+// COleInPlaceSite::QueryInterface
+//
+// Purpose:
+//
+// Used for interface negotiation
+//
+// Parameters:
+//
+// REFIID riid - A reference to the interface that is
+// being queried.
+//
+// LPVOID FAR* ppvObj - An out parameter to return a pointer to
+// the interface.
+//
+// Return Value:
+//
+// S_OK - The interface is supported.
+// S_FALSE - The interface is not supported
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::QueryInterface SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In IOIPS::QueryInterface\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->QueryInterface(riid, ppvObj);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::AddRef
+//
+// Purpose:
+//
+// Increments the reference count of the CSimpleSite. Since
+// COleInPlaceSite is a nested class of CSimpleSite, we don't need an
+// extra reference count for COleInPlaceSite. We can safely use the
+// reference count of CSimpleSite.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::QueryInterface SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleInPlaceSite::AddRef()
+{
+ TestDebugOut(TEXT("In IOIPS::AddRef\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->AddRef();
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::Release
+//
+// Purpose:
+//
+// Decrements the reference count of the CSimpleSite. Since
+// COleInPlaceSite is a nested class of CSimpleSite, we don't need an
+// extra reference count for COleInPlaceSite. We can safely use the
+// reference count of CSimpleSite.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of CSimpleSite
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::Release SITE.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) COleInPlaceSite::Release()
+{
+ TestDebugOut(TEXT("In IOIPS::Release\r\n"));
+
+ // delegate to the container Site
+ return m_pSite->Release();
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::GetWindow
+//
+// Purpose:
+//
+// Returns the Window Handle of the client site
+//
+// Parameters:
+//
+// HWND FAR* lphwnd - place to return the handle
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::GetWindow (HWND FAR* lphwnd)
+{
+ TestDebugOut(TEXT("In IOIPS::GetWindow\r\n"));
+
+ // return the handle to our editing window.
+ *lphwnd = m_pSite->m_lpDoc->m_hDocWnd;
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::ContextSensitiveHelp
+//
+// Purpose:
+// set/reset context sensitive help mode
+//
+// Parameters:
+//
+// BOOL fEnterMode - TRUE for entering Context Sensitive help mode
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+// Comments:
+//
+// Be sure to read the technotes included with the OLE toolkit.
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::ContextSensitiveHelp (BOOL fEnterMode)
+{
+ TestDebugOut(TEXT("In IOIPS::ContextSensitiveHelp\r\n"));
+
+ if (m_pSite->m_lpDoc->m_lpApp->m_fCSHMode != fEnterMode)
+ m_pSite->m_lpDoc->m_lpApp->m_fCSHMode = fEnterMode;
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::CanInPlaceActivate
+//
+// Purpose:
+//
+// Object calls to find out if the container can InPlace activate
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::CanInPlaceActivate ()
+{
+ TestDebugOut(TEXT("In IOIPS::CanInPlaceActivate\r\n"));
+
+ // return S_OK to indicate we can in-place activate
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::OnInPlaceActivate
+//
+// Purpose:
+//
+// Called by the object on InPlace Activation
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// S_OK - if the interface can be found
+// E_FAIL - otherwise
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+// IOleObject::QueryInterface Object
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::OnInPlaceActivate ()
+{
+ HRESULT hrErr;
+ TestDebugOut(TEXT("In IOIPS::OnInPlaceActivate\r\n"));
+
+ hrErr = m_pSite->m_lpOleObject->QueryInterface(
+ IID_IOleInPlaceObject, (LPVOID FAR *)&m_pSite->m_lpInPlaceObject);
+ if (hrErr != NOERROR)
+ return ResultFromScode(E_FAIL);
+
+ // return S_OK to indicate we can in-place activate.
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::OnUIActivate
+//
+// Purpose:
+//
+// Object calls this method when it displays it's UI.
+//
+// Parameters:
+//
+// None.
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+// IOleInPlaceObject::GetWindow Object
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::OnUIActivate ()
+{
+ TestDebugOut(TEXT("In IOIPS::OnUIActivate\r\n"));
+
+ m_pSite->m_lpDoc->m_fAddMyUI=FALSE;
+ m_pSite->m_lpDoc->m_fInPlaceActive = TRUE;
+ m_pSite->m_fInPlaceActive = TRUE;
+
+ m_pSite->m_lpInPlaceObject->GetWindow((HWND FAR*)&m_pSite->m_hwndIPObj);
+
+ // return S_OK to continue in-place activation
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::GetWindowContext
+//
+// Purpose:
+//
+// Called by the object to get information for InPlace Negotiation.
+//
+// Parameters:
+//
+// LPOLEINPLACEFRAME FAR* lplpFrame - Location to return a pointer
+// to IOleInPlaceFrame.
+//
+// LPOLEINPLACEUIWINDOW FAR* lplpDoc - Location to return a pointer
+// to IOleInPlaceUIWindow.
+//
+// LPRECT lprcPosRect - The rect that the object
+// occupies
+//
+// LPRECT lprcClipRect - The clipping rect
+//
+// LPOLEINPLACEFRAMEINFO lpFrameInfo - Pointer to FRAMEINFO
+//
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// COleInPlaceFrame::AddRef IOIPF.CPP
+// CSimpleSite::GetObjRect SITE.CPP
+// TestDebugOut Windows API
+// CopyRect Windows API
+// GetClientRect Windows API
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::GetWindowContext (
+ LPOLEINPLACEFRAME FAR* lplpFrame,
+ LPOLEINPLACEUIWINDOW FAR* lplpDoc,
+ LPRECT lprcPosRect,
+ LPRECT lprcClipRect,
+ LPOLEINPLACEFRAMEINFO lpFrameInfo)
+{
+ RECT rect;
+
+ TestDebugOut(TEXT("In IOIPS::GetWindowContext\r\n"));
+
+ // the frame is associated with the application object.
+ // need to AddRef() it...
+ m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame.AddRef();
+ *lplpFrame = &m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame;
+ *lplpDoc = NULL; // must be NULL, cause we're SDI.
+
+ // get the size of the object in pixels
+ m_pSite->GetObjRect(&rect);
+
+ // Copy this to the passed buffer
+ CopyRect(lprcPosRect, &rect);
+
+ // fill the clipping region
+ GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
+ CopyRect(lprcClipRect, &rect);
+
+ // fill the FRAMEINFO
+ if (sizeof(OLEINPLACEFRAMEINFO) != lpFrameInfo->cb)
+ {
+ TestDebugOut(TEXT("WARNING IOIPS::GetWindowContext "
+ "lpFrameInfo->cb size may be incorrect\r\n"));
+ }
+
+ lpFrameInfo->fMDIApp = FALSE;
+ lpFrameInfo->hwndFrame = m_pSite->m_lpDoc->m_lpApp->m_hAppWnd;
+ lpFrameInfo->haccel = m_pSite->m_lpDoc->m_lpApp->m_hAccel;
+ lpFrameInfo->cAccelEntries = SIMPCNTR_ACCEL_CNT;
+
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::Scroll
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// SIZE scrollExtent - number of pixels scrolled in X and Y direction
+//
+// Return Value:
+//
+// E_FAIL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::Scroll (SIZE scrollExtent)
+{
+ TestDebugOut(TEXT("In IOIPS::Scroll\r\n"));
+ return ResultFromScode(E_FAIL);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::OnUIDeactivate
+//
+// Purpose:
+//
+// Called by the object when its UI goes away
+//
+// Parameters:
+//
+// BOOL fUndoable
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleAPP::QueryNewPalette APP.CPP
+// CSimpleAPP::AddFrameLevelUI APP.CPP
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::OnUIDeactivate (BOOL fUndoable)
+{
+ TestDebugOut(TEXT("In IOIPS::OnUIDeactivate\r\n"));
+
+ // need to clear this flag first
+ m_pSite->m_lpDoc->m_fInPlaceActive = FALSE;
+ m_pSite->m_fInPlaceActive = FALSE;
+
+ m_pSite->m_lpDoc->m_lpApp->QueryNewPalette();
+ m_pSite->m_lpDoc->m_lpApp->AddFrameLevelUI();
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::OnInPlaceDeactivate
+//
+// Purpose:
+//
+// Called when the inplace session is over
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// ResultFromScode OLE API
+// IOleInPlaceObject::Release Object
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::OnInPlaceDeactivate ()
+{
+ TestDebugOut(TEXT("In IOIPS::OnInPlaceDeactivate\r\n"));
+
+ if (m_pSite->m_lpInPlaceObject)
+ {
+ m_pSite->m_lpInPlaceObject->Release();
+ m_pSite->m_lpInPlaceObject = NULL;
+ }
+ return ResultFromScode(S_OK);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::DiscardUndoState
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// E_FAIL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::DiscardUndoState ()
+{
+ TestDebugOut(TEXT("In IOIPS::DiscardUndoState\r\n"));
+ return ResultFromScode(E_FAIL);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::DeactivateAndUndo
+//
+// Purpose:
+//
+// Not Implemented
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// E_FAIL
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::DeactivateAndUndo ()
+{
+ TestDebugOut(TEXT("In IOIPS::DeactivateAndUndo\r\n"));
+ return ResultFromScode(E_FAIL);
+}
+
+//**********************************************************************
+//
+// COleInPlaceSite::OnPosRectChange
+//
+// Purpose:
+//
+// The object calls this method when it's size changes during an
+// InPlace Session
+//
+// Parameters:
+//
+// LPCRECT lprcPosRect - The new object rect
+//
+// Return Value:
+//
+// S_OK
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// GetClientRect Windows API
+// IOleObject::GetExtent Object
+// IOleInPlaceObject::SetObjectRects Object
+// ResultFromScode OLE API
+//
+//
+//********************************************************************
+
+STDMETHODIMP COleInPlaceSite::OnPosRectChange (LPCRECT lprcPosRect)
+{
+ TestDebugOut(TEXT("In IOIPS::OnPosRectChange\r\n"));
+
+ // update the size in the document object
+ // NOTE: here we must call IOleObject::GetExtent to get actual extents
+ // of the running object. IViewObject2::GetExtent returns the
+ // last cached extents.
+ m_pSite->m_lpOleObject->GetExtent(DVASPECT_CONTENT, &m_pSite->m_sizel);
+ RECT rect;
+ GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
+
+ // tell the object its new size
+ m_pSite->m_lpInPlaceObject->SetObjectRects(lprcPosRect, &rect);
+
+ return ResultFromScode(S_OK);
+}
+
diff --git a/private/oleutest/simpcntr/ioips.h b/private/oleutest/simpcntr/ioips.h
new file mode 100644
index 000000000..3fdbf2385
--- /dev/null
+++ b/private/oleutest/simpcntr/ioips.h
@@ -0,0 +1,53 @@
+//**********************************************************************
+// File name: IOIPS.H
+//
+// Definition of COleInPlaceSite
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#if !defined( _IOIPS_H_ )
+#define _IOIPS_H_
+
+
+class CSimpleSite;
+
+interface COleInPlaceSite : public IOleInPlaceSite
+{
+ CSimpleSite FAR * m_pSite;
+
+ COleInPlaceSite(CSimpleSite FAR *pSite)
+ {
+ TestDebugOut(TEXT("In IOIPS's constructor\r\n"));
+ m_pSite = pSite;
+ };
+
+ ~COleInPlaceSite()
+ {
+ TestDebugOut(TEXT("In IOIPS;s destructor\r\n"));
+ };
+
+ STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
+ STDMETHODIMP_(ULONG) AddRef ();
+ STDMETHODIMP_(ULONG) Release ();
+
+ STDMETHODIMP GetWindow (HWND FAR* lphwnd);
+ STDMETHODIMP ContextSensitiveHelp (BOOL fEnterMode);
+
+ // *** IOleInPlaceSite methods ***
+ STDMETHODIMP CanInPlaceActivate ();
+ STDMETHODIMP OnInPlaceActivate ();
+ STDMETHODIMP OnUIActivate ();
+ STDMETHODIMP GetWindowContext (LPOLEINPLACEFRAME FAR* lplpFrame,
+ LPOLEINPLACEUIWINDOW FAR* lplpDoc,
+ LPRECT lprcPosRect,
+ LPRECT lprcClipRect,
+ LPOLEINPLACEFRAMEINFO lpFrameInfo);
+ STDMETHODIMP Scroll (SIZE scrollExtent);
+ STDMETHODIMP OnUIDeactivate (BOOL fUndoable);
+ STDMETHODIMP OnInPlaceDeactivate ();
+ STDMETHODIMP DiscardUndoState ();
+ STDMETHODIMP DeactivateAndUndo ();
+ STDMETHODIMP OnPosRectChange (LPCRECT lprcPosRect);
+};
+
+#endif
diff --git a/private/oleutest/simpcntr/pre.cpp b/private/oleutest/simpcntr/pre.cpp
new file mode 100644
index 000000000..9603f4089
--- /dev/null
+++ b/private/oleutest/simpcntr/pre.cpp
@@ -0,0 +1,9 @@
+//**********************************************************************
+// File name: pre.cpp
+//
+// Used for precompiled headers
+//
+// Copyright (c) 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
diff --git a/private/oleutest/simpcntr/pre.h b/private/oleutest/simpcntr/pre.h
new file mode 100644
index 000000000..6c1fdd23d
--- /dev/null
+++ b/private/oleutest/simpcntr/pre.h
@@ -0,0 +1,32 @@
+//**********************************************************************
+// File name: pre.h
+//
+// Used for precompiled headers
+//
+// Copyright (c) 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#if !defined( _PRE_H_)
+#define _PRE_H_
+
+#include <windows.h>
+#include <ole2.h>
+#include <ole2ui.h>
+#include <assert.h>
+#include <string.h>
+#include "simpcntr.h"
+#include "resource.h"
+
+extern "C" void TestDebugOut(LPSTR psz);
+
+
+
+#ifndef WIN32
+/* Since OLE is part of the operating system in Win32, we don't need to
+ * check the version number in Win32.
+ */
+#include <ole2ver.h>
+#endif // WIN32
+
+
+#endif
diff --git a/private/oleutest/simpcntr/readme.txt b/private/oleutest/simpcntr/readme.txt
new file mode 100644
index 000000000..9c1947d0f
--- /dev/null
+++ b/private/oleutest/simpcntr/readme.txt
@@ -0,0 +1,31 @@
+Simpcntr
+--------
+This sample is the simplest OLE 2.0 container that can be written and
+still support the visual editing feature. The sample has no native
+file format, and can only support one OLE object at a time. The
+Insert Object command is used to create an object.
+
+See the MAKEFILE for compilation instructions.
+
+
+Simple Container Objects Overview :
+-----------------------------------
+Simple Container consists of three main objects. The top level is CSimpleApp,
+under which is CSimpleDoc, and the innermost level is CSimpleSite. CSimpleApp
+is used to hold the main window information. (eg. handle to the main window,
+handle to the UI Active Object) CSimpleApp always exists as long as the
+simple container application is alive. It demonstrates the implementation of
+IOleInPlaceFrame, in its nested class COleInPlaceFrame.
+
+The next level object is CSimpleDoc object. It is instantiated by CSimpleApp
+when a new document is created. It is used to hold the handles to the main
+menus and the submenus and manipulate changes to these menus.
+
+The CSimpleDoc object instantiates CSimpleSite object as the user chooses to
+insert a new object into the document. CSimpleSite demonstrates the
+implementation of IAdviseSink, IOleInPlaceSite and IOleClientSite through
+its nested classes. These interfaces are implemented as CAdviseSink,
+COleInPlaceSite and COleClientSite accordingly. CSimpleSite acts as a client
+site to communicate to a remote server.
+
+ \ No newline at end of file
diff --git a/private/oleutest/simpcntr/resource.h b/private/oleutest/simpcntr/resource.h
new file mode 100644
index 000000000..0f20f416d
--- /dev/null
+++ b/private/oleutest/simpcntr/resource.h
@@ -0,0 +1,32 @@
+//{{NO_DEPENDENCIES}}
+// App Studio generated include file.
+// Used by SIMPCNTR.RC
+//
+#define IDM_OPEN 102
+#define IDM_SAVE 103
+#define IDM_SAVEAS 104
+#define IDM_PRINT 105
+#define IDM_EXIT 106
+#define IDM_UNDO 107
+#define IDM_CUT 108
+#define IDM_COPY 109
+#define IDM_PASTE 110
+#define ID_EDIT_INSERTOBJECT 111
+#define IDM_INSERTOBJECT 111
+#define IDM_NEW 112
+#define IDM_DEACTIVATE 113
+#define IDM_UTEST 998
+
+#define SIMPCNTR_ACCEL_CNT 3
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 113
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/private/oleutest/simpcntr/simpcntr.cpp b/private/oleutest/simpcntr/simpcntr.cpp
new file mode 100644
index 000000000..5b9f5adc8
--- /dev/null
+++ b/private/oleutest/simpcntr/simpcntr.cpp
@@ -0,0 +1,523 @@
+//**********************************************************************
+// File name: Simple.cpp
+//
+// Main source file for the Simple OLE 2.0 object container
+//
+// Functions:
+//
+// WinMain - Program entry point
+// MainWndProc - Processes messages for the frame window
+// About - Processes messages for the about dialog
+// DocWndProc - Processes messages for the doc window
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+#include "tests.h"
+
+// This line is needed for the debug utilities in OLE2UI
+extern "C" {
+ OLEDBGDATA_MAIN(TEXT("SIMPCNTR"))
+}
+
+CSimpleApp FAR * lpCSimpleApp;
+
+void DeactivateIfActive(HWND hWnd)
+{
+ LPOLEINPLACEOBJECT lpObject;
+ MSG msg;
+ msg.message = WM_LBUTTONDOWN;
+
+
+ if (lpCSimpleApp->m_lpDoc->m_fInPlaceActive)
+ {
+ // We are in the process of deactiving the in place object
+ lpCSimpleApp->m_fDeactivating = TRUE;
+
+ lpCSimpleApp->m_lpDoc->m_lpSite->m_lpOleObject->QueryInterface(
+ IID_IOleInPlaceObject, (LPVOID FAR *)&lpObject);
+ lpObject->UIDeactivate();
+
+ // this code is needed because we don't support inside out.
+ RECT rect;
+ lpCSimpleApp->m_lpDoc->m_lpSite->GetObjRect(&rect);
+ lpCSimpleApp->m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(
+ OLEIVERB_HIDE,
+ &msg,
+ &lpCSimpleApp->m_lpDoc->m_lpSite->m_OleClientSite,
+ -1, hWnd, &rect);
+
+ lpObject->Release();
+
+ // We are done deactiving
+ lpCSimpleApp->m_fDeactivating = FALSE;
+ }
+
+}
+
+
+BOOL fBeVerbose = FALSE;
+extern "C"
+void TestDebugOut(LPSTR psz)
+{
+ if (fBeVerbose)
+ {
+ OutputDebugStringA(psz);
+ }
+}
+
+
+//**********************************************************************
+//
+// WinMain
+//
+// Purpose:
+//
+// Program entry point
+//
+// Parameters:
+//
+// HANDLE hInstance - Instance handle for this instance
+//
+// HANDLE hPrevInstance - Instance handle for the last instance
+//
+// LPSTR lpCmdLine - Pointer to the command line
+//
+// int nCmdShow - Window State
+//
+// Return Value:
+//
+// msg.wParam
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleApp::CSimpleApp APP.CPP
+// CSimpleApp::AddRef APP.CPP
+// CSimpleApp::Release APP.CPP
+// CSimpleApp::fInitApplication APP.CPP
+// CSimpleApp::fInitInstance APP.CPP
+// CSimpleApp::HandleAccelerators APP.CPP
+// CSimpleApp::~CSimpleApp APP.CPP
+// OleUIInitialize OLE2UI
+// OleUIUninitialize OLE2UI
+// GetMessage Windows API
+// TranslateMessage Windows API
+// DispatchMessage Windows API
+//
+//********************************************************************
+int PASCAL WinMain
+#ifdef WIN32
+ (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
+#else
+ (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+#endif
+{
+ MSG msg;
+
+ // needed for LRPC to work properly...
+ SetMessageQueue(96);
+
+ lpCSimpleApp = new CSimpleApp;
+ fBeVerbose = GetProfileInt("OLEUTEST","BeVerbose",0);
+
+ if(fBeVerbose == 0)
+ {
+ fBeVerbose = GetProfileInt("OLEUTEST","simpcntr",0);
+ }
+
+ if (!lpCSimpleApp)
+ {
+ /* memory allocation error. cannot carry on.
+ */
+ return(FALSE);
+ }
+
+ // we will add one ref count on our App. later when we want to destroy
+ // the App object we will release this ref count. when the App's ref
+ // count goes to 0, it will be deleted.
+ lpCSimpleApp->AddRef();
+
+ char *pszTemp;
+
+ // process the command line
+ if( (pszTemp = strstr(lpCmdLine, "-driver")) )
+ {
+ //we were launched by the test driver
+ lpCSimpleApp->m_hDriverWnd = (HWND)strtoul(pszTemp+8, NULL, 10);
+ }
+
+ // app initialization
+ if (!hPrevInstance)
+ if (!lpCSimpleApp->fInitApplication(hInstance))
+ {
+ lpCSimpleApp->Release();
+ return (FALSE);
+ }
+
+ // instance initialization
+ if (!lpCSimpleApp->fInitInstance(hInstance, nCmdShow))
+ {
+ lpCSimpleApp->Release();
+ return (FALSE);
+ }
+
+ /* Initialization required for OLE 2 UI library. This call is
+ ** needed ONLY if we are using the static link version of the UI
+ ** library. If we are using the DLL version, we should NOT call
+ ** this function in our application.
+ ** The 3rd and 4th parameters passed the OleUIInitialize
+ ** function are strings which are used to name two custom
+ ** control classes used by the OLE2UI library. These strings
+ ** must be unique for each application that uses the OLE2UI
+ ** library. These strings are typically composed by combining
+ ** the APPNAME with a suffix in order to be unique for a
+ ** particular application. The special symbols "SZCLASSICONBOX"
+ ** and "SZCLASSRESULTIMAGE" are used define these strings. These
+ ** symbols must be defined in a header file that is included
+ ** both in this file AND the resource file that included the
+ ** "OLE2UI.RC" resoure file. These symbols should be used in the
+ ** call to OleUIInitialize and are referenced in the INSOBJ.DLG
+ ** and PASTESPL.DLG resouce files of the OLE2UI library.
+ */
+#if 0 // We use the DLL form of OLE2U32A
+ if (!OleUIInitialize(hInstance, hPrevInstance, TEXT(SZCLASSICONBOX),
+ TEXT(SZCLASSRESULTIMAGE)))
+ {
+ OleDbgOut(TEXT("Could not initialize OLEUI library\n"));
+ lpCSimpleApp->Release();
+ return FALSE;
+ }
+#endif
+
+ // message loop
+ while (GetMessage(&msg, NULL, NULL, NULL))
+ if (!lpCSimpleApp->HandleAccelerators(&msg))
+ {
+ TranslateMessage(&msg); /* Translates virtual key codes */
+ DispatchMessage(&msg); /* Dispatches message to window */
+ }
+
+
+#if 0 // We use the DLL form of OLE2U32A
+ // De-initialization for UI libraries. Just like OleUIInitialize, this
+ // funciton is needed ONLY if we are using the static link version of the
+ // OLE UI library.
+ OleUIUninitialize();
+#endif
+
+ // Release the ref count added on the App above. this will make
+ // the App's ref count go to 0, and the App object will be deleted.
+ lpCSimpleApp->Release();
+
+ return (msg.wParam); /* Returns the value from PostQuitMessage */
+}
+
+
+//**********************************************************************
+//
+// MainWndProc
+//
+// Purpose:
+//
+// Processes messages for the frame window
+//
+// Parameters:
+//
+// HWND hWnd - Window handle for frame window
+//
+// UINT message - Message value
+//
+// WPARAM wParam - Message info
+//
+// LPARAM lParam - Message info
+//
+// Return Value:
+//
+// long
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleApp::lCommandHandler APP.CPP
+// CSimpleApp::DestroyDocs APP.CPP
+// CSimpleApp::lCreateDoc APP.CPP
+// CSimpleApp::lSizeHandler APP.CPP
+// CSimpleDoc::lAddVerbs DOC.CPP
+// CSimpleDoc::QueryNewPalette APP.CPP
+// SendMessage Windows API
+// PostQuitMessage Windows API
+// DefWindowProc Windows API
+//
+//
+//********************************************************************
+
+long FAR PASCAL EXPORT MainWndProc(HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+
+ switch (message)
+ {
+ case WM_CLOSE:
+ DestroyWindow(lpCSimpleApp->m_hAppWnd);
+ break;
+
+ case WM_TEST1:
+ // Do the unit test
+ Test1(lpCSimpleApp);
+ break;
+
+ case WM_SETFOCUS:
+ // If we have an inplace application it needs to get the focus
+ if (lpCSimpleApp->m_lpDoc->m_fInPlaceActive
+ && !lpCSimpleApp->m_fDeactivating)
+ {
+ SetFocus(lpCSimpleApp->m_hwndUIActiveObj);
+ break;
+ }
+
+ // Othewise default behavior is enough
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ case WM_COMMAND: // message: command from application menu
+ return lpCSimpleApp->lCommandHandler(hWnd, message,
+ wParam, lParam);
+ break;
+
+ case WM_CREATE:
+ return lpCSimpleApp->lCreateDoc(hWnd, message, wParam, lParam);
+ break;
+
+ case WM_DESTROY: // message: window being destroyed
+ lpCSimpleApp->DestroyDocs(); // need to destroy the doc...
+ PostQuitMessage(0);
+ break;
+
+ case WM_INITMENUPOPUP:
+ // is this the edit menu?
+ if ( LOWORD(lParam) == 1)
+ return lpCSimpleApp->m_lpDoc->lAddVerbs();
+
+ break;
+
+ // this code is needed for 256 color objects to work properly.
+ case WM_QUERYNEWPALETTE:
+ if (! lpCSimpleApp->m_fAppActive)
+ return 0L;
+
+ return lpCSimpleApp->QueryNewPalette();
+
+
+ case WM_PALETTECHANGED:
+ {
+ HWND hWndPalChg = (HWND) wParam;
+
+ if (hWnd != hWndPalChg)
+ wSelectPalette(hWnd, lpCSimpleApp->m_hStdPal,
+ TRUE/*fBackground*/);
+
+ /* OLE2NOTE: always forward the WM_PALETTECHANGED message (via
+ ** SendMessage) to any in-place objects that currently have
+ ** their window visible. this gives these objects the chance
+ ** to select their palettes. this is
+ ** REQUIRED by all in-place containers independent of
+ ** whether they use color palettes themselves--their objects
+ ** may use color palettes.
+ ** (see ContainerDoc_ForwardPaletteChangedMsg for more info)
+ */
+ if (lpCSimpleApp->m_lpDoc && lpCSimpleApp->m_lpDoc->m_lpSite &&
+ lpCSimpleApp->m_lpDoc->m_lpSite->m_hwndIPObj)
+ {
+ SendMessage(lpCSimpleApp->m_lpDoc->m_lpSite->m_hwndIPObj,
+ WM_PALETTECHANGED, wParam, lParam);
+ }
+
+ return 0L;
+ }
+
+ case WM_ACTIVATEAPP:
+ if ((lpCSimpleApp->m_fAppActive = (BOOL)wParam) == TRUE)
+ lpCSimpleApp->QueryNewPalette();
+
+ if (lpCSimpleApp->m_lpDoc->m_lpActiveObject)
+ {
+ lpCSimpleApp->m_lpDoc->m_lpActiveObject->OnFrameWindowActivate(
+ (BOOL)wParam);
+ }
+ break;
+
+ case WM_SIZE:
+ return lpCSimpleApp->lSizeHandler(hWnd, message, wParam, lParam);
+
+ default: // Passes it on if unproccessed
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+ }
+ return (NULL);
+}
+
+
+//**********************************************************************
+//
+// About
+//
+// Purpose:
+//
+// Processes dialog box messages
+//
+// Parameters:
+//
+// HWND hWnd - Window handle for dialog box
+//
+// UINT message - Message value
+//
+// WPARAM wParam - Message info
+//
+// LPARAM lParam - Message info
+//
+// Return Value:
+// TRUE if message processed, FALSE otherwise
+//
+// Function Calls:
+// Function Location
+//
+// EndDialog Windows API
+//
+//
+//********************************************************************
+
+BOOL FAR PASCAL EXPORT About(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
+
+{
+ switch (message)
+ {
+ case WM_INITDIALOG: /* message: initialize dialog box */
+ return (TRUE);
+
+ case WM_COMMAND: /* message: received a command */
+ if (wParam == IDOK /* "OK" box selected? */
+ || wParam == IDCANCEL) /* System menu close command? */
+ {
+ EndDialog(hDlg, TRUE); /* Exits the dialog box */
+ return (TRUE);
+ }
+ break;
+ }
+ return (FALSE); /* Didn't process a message */
+}
+
+//**********************************************************************
+//
+// DocWndProc
+//
+// Purpose:
+//
+// Processes dialog box messages
+//
+// Parameters:
+//
+// HWND hWnd - Window handle for doc window
+//
+// UINT message - Message value
+//
+// WPARAM wParam - Message info
+//
+// LPARAM lParam - Message info
+//
+// Return Value:
+// NULL
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleApp::PaintApp APP.CPP
+// BeginPaint Windows API
+// EndPaint Windows API
+// DefWindowProc Windows API
+// PtInRect Windows API
+// CSimpleSite::GetObjRect SITE.CPP
+// IOleObject::QueryInterface Object
+// IOleInPlaceObject::UIDeactivate Object
+// IOleObject::DoVerb Object
+// IOleInPlaceObject::Release Object
+//
+//
+//********************************************************************
+
+long FAR PASCAL EXPORT DocWndProc(HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ HDC hDC;
+ PAINTSTRUCT ps;
+
+ switch (message)
+ {
+ case WM_SETFOCUS:
+ // If we have an inplace application it needs to get the focus
+ if (lpCSimpleApp->m_lpDoc->m_fInPlaceActive
+ && !lpCSimpleApp->m_fDeactivating)
+ {
+ SetFocus(lpCSimpleApp->m_hwndUIActiveObj);
+ break;
+ }
+
+ // Otherwise default behavior is enough
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ case WM_PAINT:
+
+ hDC = BeginPaint(hWnd, &ps);
+
+ if (lpCSimpleApp)
+ lpCSimpleApp->PaintApp (hDC);
+
+ EndPaint(hWnd, &ps);
+ break;
+
+
+ case WM_LBUTTONDBLCLK:
+ {
+ POINT pt;
+
+ pt.x = (int)(short)LOWORD (lParam );
+ pt.y = (int)(short)HIWORD (lParam );
+
+ if (lpCSimpleApp->m_lpDoc->m_lpSite &&
+ lpCSimpleApp->m_lpDoc->m_lpSite->m_lpOleObject)
+ {
+ RECT rect;
+
+ lpCSimpleApp->m_lpDoc->m_lpSite->GetObjRect(&rect);
+
+ if ( PtInRect(&rect, pt) )
+ {
+ // Execute object's default verb
+ lpCSimpleApp->m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(
+ OLEIVERB_PRIMARY, (LPMSG)&message,
+ &lpCSimpleApp->m_lpDoc->m_lpSite->m_OleClientSite,
+ -1, hWnd, &rect);
+ }
+ }
+ }
+ break;
+
+ // no code is added to WM_LBUTTONDOWN for context sensitive help, because
+ // this app does not do context sensitive help.
+
+ case WM_LBUTTONDOWN:
+ DeactivateIfActive(hWnd);
+ break;
+
+ default: /* Passes it on if unproccessed */
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+ }
+ return (NULL);
+}
+
diff --git a/private/oleutest/simpcntr/simpcntr.def b/private/oleutest/simpcntr/simpcntr.def
new file mode 100644
index 000000000..d0dd19433
--- /dev/null
+++ b/private/oleutest/simpcntr/simpcntr.def
@@ -0,0 +1,26 @@
+; module-definition file for generic -- used by LINK.EXE
+
+NAME SIMPCNTR ; application's module name
+
+DESCRIPTION 'Sample Microsoft Windows Application'
+
+EXETYPE WINDOWS ; required for all Windows applications
+
+STUB 'WINSTUB.EXE' ; Generates error message if application
+ ; is run without Windows
+
+;CODE can be moved in memory and discarded/reloaded
+CODE PRELOAD MOVEABLE DISCARDABLE
+
+;DATA must be MULTIPLE if program can be invoked more than once
+DATA PRELOAD MOVEABLE MULTIPLE
+
+
+HEAPSIZE 1024
+STACKSIZE 16000
+
+
+; All functions that will be called by any Windows routine
+; MUST be exported.
+
+
diff --git a/private/oleutest/simpcntr/simpcntr.h b/private/oleutest/simpcntr/simpcntr.h
new file mode 100644
index 000000000..190e0c427
--- /dev/null
+++ b/private/oleutest/simpcntr/simpcntr.h
@@ -0,0 +1,40 @@
+//**********************************************************************
+// File name: simple.h
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#define IDM_ABOUT 100
+#define IDM_INSERT 101
+#define IDM_VERB0 1000
+
+int PASCAL WinMain
+#ifdef WIN32
+ (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
+#else
+ (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
+#endif
+
+BOOL InitApplication(HANDLE hInstance);
+BOOL InitInstance(HANDLE hInstance, int nCmdShow);
+long FAR PASCAL EXPORT MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+long FAR PASCAL EXPORT DocWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+#ifdef WIN32
+BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+#else
+BOOL FAR PASCAL EXPORT About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+#endif
+
+
+/* These strings are used to name two custom control classes used by
+** the OLE2UI library. These strings must be unique for each
+** application that uses the OLE2UI library. These strings should be
+** composed by combining the APPNAME with a suffix in order to be
+** unique for a particular application. The special symbols
+** "SZCLASSICONBOX" and "SZCLASSRESULTIMAGE" are used define these
+** strings. These symbols are passed in the OleUIInitialize call and
+** are referenced in the INSOBJ.DLG and PASTESPL.DLG resouce files
+** of the OLE2UI library.
+*/
+#define SZCLASSICONBOX "simpcntrIBClass"
+#define SZCLASSRESULTIMAGE "simpcntrRIClass"
diff --git a/private/oleutest/simpcntr/simpcntr.ico b/private/oleutest/simpcntr/simpcntr.ico
new file mode 100644
index 000000000..5450ff3f0
--- /dev/null
+++ b/private/oleutest/simpcntr/simpcntr.ico
Binary files differ
diff --git a/private/oleutest/simpcntr/simpcntr.rc b/private/oleutest/simpcntr/simpcntr.rc
new file mode 100644
index 000000000..732b496b2
--- /dev/null
+++ b/private/oleutest/simpcntr/simpcntr.rc
@@ -0,0 +1,114 @@
+//Microsoft App Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "simpcntr.h"
+#include "ole2ui.rc"
+
+/////////////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+SimpCntr icon simpcntr.ico
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+SIMPLEMENU MENU DISCARDABLE
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&New", IDM_NEW
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", IDM_EXIT
+ END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "&Insert Object...", IDM_INSERTOBJECT
+ END
+ POPUP "&Other"
+ BEGIN
+ MENUITEM "&Deactivate Inplace", IDM_DEACTIVATE
+ MENUITEM "&About Simple...", IDM_ABOUT
+ END
+END
+
+
+SimpcntrAccel ACCELERATORS
+ BEGIN
+ "^a", IDM_UTEST
+ VK_F10, IDM_DEACTIVATE, VIRTKEY, CONTROL
+ VK_F11, IDM_ABOUT, VIRTKEY, CONTROL
+ END
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+ABOUTBOX DIALOG DISCARDABLE 22, 17, 144, 75
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "About SimpCntr"
+FONT 8, "System"
+BEGIN
+ CTEXT "Simple OLE 2.0",-1,0,5,144,8
+ CTEXT "In-Place Container Application",-1,0,14,144,8
+ CTEXT "Version 2.01",-1,0,34,144,8
+ DEFPUSHBUTTON "OK",IDOK,53,59,32,14,WS_GROUP
+END
+
+#ifdef APSTUDIO_INVOKED
+//////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""simpcntr.h""\r\n"
+ "#include ""..\\ole2ui\\resource\\usa\\strings.rc""\r\n"
+ "#include ""..\\ole2ui\\resource\\usa\\insobj.dlg""\r\n"
+ "\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+/////////////////////////////////////////////////////////////////////////////////////
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef APSTUDIO_INVOKED
+////////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
+
diff --git a/private/oleutest/simpcntr/site.cpp b/private/oleutest/simpcntr/site.cpp
new file mode 100644
index 000000000..70f828a83
--- /dev/null
+++ b/private/oleutest/simpcntr/site.cpp
@@ -0,0 +1,637 @@
+//**********************************************************************
+// File name: SITE.CPP
+//
+// Implementation file for CSimpleSite
+//
+// Functions:
+//
+// See SITE.H for class definition
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+
+//**********************************************************************
+//
+// CSimpleSite::Create
+//
+// Purpose:
+//
+// Creation routine for CSimpleSite
+//
+// Parameters:
+//
+// CSimpleDoc FAR *lpDoc - Pointer to CSimpleDoc
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::CSimpleSite SITE.CPP
+// IStorage::CreateStorage OLE API
+// CSimpleSite::AddRef SITE.CPP
+// assert C Runtime
+//
+//
+//********************************************************************
+
+CSimpleSite FAR * CSimpleSite::Create(CSimpleDoc FAR *lpDoc)
+{
+ CSimpleSite FAR * lpTemp = new CSimpleSite(lpDoc);
+
+ if (!lpTemp)
+ return NULL;
+
+ // create a sub-storage for the object
+ HRESULT hErr = lpDoc->m_lpStorage->CreateStorage( OLESTR("Object"),
+ STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
+ 0,
+ 0,
+ &lpTemp->m_lpObjStorage);
+
+ assert(hErr == NOERROR);
+
+ if (hErr != NOERROR)
+ {
+ delete lpTemp;
+ return NULL;
+ }
+
+ // we will add one ref count on our Site. later when we want to destroy
+ // the Site object we will release this ref count. when the Site's ref
+ // count goes to 0, it will be deleted.
+ lpTemp->AddRef();
+
+ return lpTemp;
+}
+
+//**********************************************************************
+//
+// CSimpleSite::CSimpleSite
+//
+// Purpose:
+//
+// Constructor for CSimpleSite
+//
+// Parameters:
+//
+// CSimpleDoc FAR *lpDoc - Pointer to CSimpleDoc
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+//
+//********************************************************************
+#pragma warning(disable : 4355) // turn off this warning. This warning
+ // tells us that we are passing this in
+ // an initializer, before "this" is through
+ // initializing. This is ok, because
+ // we just store the ptr in the other
+ // constructors
+
+CSimpleSite::CSimpleSite (CSimpleDoc FAR *lpDoc) : m_OleClientSite(this),
+ m_AdviseSink(this),
+ m_OleInPlaceSite(this)
+#pragma warning (default : 4355) // Turn the warning back on
+{
+ TestDebugOut (TEXT("In CSimpleSite's Constructor \r\n"));
+
+ // remember the pointer to the doc
+ m_lpDoc = lpDoc;
+
+ // clear the reference count
+ m_nCount = 0;
+
+ m_dwDrawAspect = DVASPECT_CONTENT;
+ m_lpOleObject = NULL;
+ m_lpInPlaceObject = NULL;
+ m_hwndIPObj = NULL;
+ m_fInPlaceActive = FALSE;
+ m_fObjectOpen = FALSE;
+}
+
+//**********************************************************************
+//
+// CSimpleSite::~CSimpleSite
+//
+// Purpose:
+//
+// Destructor for CSimpleSite
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IOleObject::Release Object
+// IStorage::Release OLE API
+//
+//
+//********************************************************************
+
+CSimpleSite::~CSimpleSite ()
+{
+ TestDebugOut (TEXT("In CSimpleSite's Destructor \r\n"));
+
+ if (m_lpOleObject)
+ m_lpOleObject->Release();
+
+ if (m_lpObjStorage)
+ m_lpObjStorage->Release();
+}
+
+
+//**********************************************************************
+//
+// CSimpleSite::CloseOleObject
+//
+// Purpose:
+//
+// Call IOleObject::Close on the object of the CSimpleSite
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IOleObject::QueryInterface Object
+// IOleObject::Close Object
+// IOleInPlaceObject::UIDeactivate Object
+// IOleInPlaceObject::InPlaceDeactivate Object
+// IOleInPlaceObject::Release Object
+//
+//
+//********************************************************************
+
+void CSimpleSite::CloseOleObject (void)
+{
+ LPOLEINPLACEOBJECT lpObject;
+ LPVIEWOBJECT lpViewObject = NULL;
+
+ TestDebugOut (TEXT("In CSimpleSite::CloseOleObject \r\n"));
+
+ if (m_lpOleObject)
+ {
+ if (m_fInPlaceActive)
+ {
+ m_lpOleObject->QueryInterface(IID_IOleInPlaceObject,
+ (LPVOID FAR *)&lpObject);
+ lpObject->UIDeactivate();
+ // don't need to worry about inside-out because the object
+ // is going away.
+ lpObject->InPlaceDeactivate();
+ lpObject->Release();
+ }
+
+ m_lpOleObject->Close(OLECLOSE_NOSAVE);
+ }
+}
+
+
+//**********************************************************************
+//
+// CSimpleSite::UnloadOleObject
+//
+// Purpose:
+//
+// Close and release all pointers to the object of the CSimpleSite
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// CSimpleSite::CloseOleObject SITE.CPP
+// IOleObject::QueryInterface Object
+// IOleObject::Release Object
+// IViewObject::SetAdvise Object
+// IViewObject::Release Object
+//
+//
+//********************************************************************
+
+void CSimpleSite::UnloadOleObject (void)
+{
+ TestDebugOut (TEXT("In CSimpleSite::UnloadOleObject \r\n"));
+
+ if (m_lpOleObject)
+ {
+ LPVIEWOBJECT lpViewObject;
+ CloseOleObject(); // ensure object is closed; NOP if already closed
+
+ m_lpOleObject->QueryInterface(IID_IViewObject,
+ (LPVOID FAR *)&lpViewObject);
+
+ if (lpViewObject)
+ {
+ // Remove the view advise
+ lpViewObject->SetAdvise(m_dwDrawAspect, 0, NULL);
+ lpViewObject->Release();
+ }
+
+ m_lpOleObject->Release();
+ m_lpOleObject = NULL;
+ }
+}
+
+
+//**********************************************************************
+//
+// CSimpleSite::QueryInterface
+//
+// Purpose:
+//
+// Used for interface negotiation of the container Site.
+//
+// Parameters:
+//
+// REFIID riid - A reference to the interface that is
+// being queried.
+//
+// LPVOID FAR* ppvObj - An out parameter to return a pointer to
+// the interface.
+//
+// Return Value:
+//
+// S_OK - The interface is supported.
+// E_NOINTERFACE - The interface is not supported
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+// IsEqualIID OLE API
+// ResultFromScode OLE API
+// CSimpleSite::AddRef OBJ.CPP
+// COleClientSite::AddRef IOCS.CPP
+// CAdviseSink::AddRef IAS.CPP
+// COleInPlaceSite::AddRef IOIPS.CPP
+//
+//
+//********************************************************************
+
+STDMETHODIMP CSimpleSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+ TestDebugOut(TEXT("In CSimpleSite::QueryInterface\r\n"));
+
+ *ppvObj = NULL; // must set out pointer parameters to NULL
+
+ if ( IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppvObj = this;
+ return ResultFromScode(S_OK);
+ }
+
+ if ( IsEqualIID(riid, IID_IOleClientSite))
+ {
+ m_OleClientSite.AddRef();
+ *ppvObj = &m_OleClientSite;
+ return ResultFromScode(S_OK);
+ }
+
+ if ( IsEqualIID(riid, IID_IAdviseSink))
+ {
+ m_AdviseSink.AddRef();
+ *ppvObj = &m_AdviseSink;
+ return ResultFromScode(S_OK);
+ }
+
+ if ( IsEqualIID(riid, IID_IOleInPlaceSite))
+ {
+ m_OleInPlaceSite.AddRef();
+ *ppvObj = &m_OleInPlaceSite;
+ return ResultFromScode(S_OK);
+ }
+
+ // Not a supported interface
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+//**********************************************************************
+//
+// CSimpleSite::AddRef
+//
+// Purpose:
+//
+// Increments the reference count of the container Site.
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of the site.
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleSite::AddRef()
+{
+ TestDebugOut(TEXT("In CSimpleSite::AddRef\r\n"));
+
+ return ++m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleSite::Release
+//
+// Purpose:
+//
+// Decrements the reference count of the container Site
+//
+// Parameters:
+//
+// None
+//
+// Return Value:
+//
+// ULONG - The new reference count of the Site.
+//
+// Function Calls:
+// Function Location
+//
+// TestDebugOut Windows API
+//
+//
+//********************************************************************
+
+STDMETHODIMP_(ULONG) CSimpleSite::Release()
+{
+ TestDebugOut(TEXT("In CSimpleSite::Release\r\n"));
+
+ if (--m_nCount == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_nCount;
+}
+
+//**********************************************************************
+//
+// CSimpleSite::InitObject
+//
+// Purpose:
+//
+// Used to initialize a newly create object (can't be done in the
+// constructor).
+//
+// Parameters:
+//
+// BOOL fCreateNew - TRUE if insert NEW object
+// FALSE if create object FROM FILE
+//
+// Return Value:
+//
+// None
+//
+// Function Calls:
+// Function Location
+//
+// IOleObject::SetHostNames Object
+// IOleObject::QueryInterface Object
+// IViewObject2::GetExtent Object
+// IOleObject::DoVerb Object
+// IViewObject2::SetAdvise Object
+// IViewObject2::Release Object
+// GetClientRect Windows API
+// OleSetContainedObject OLE API
+//
+//
+//********************************************************************
+
+void CSimpleSite::InitObject(BOOL fCreateNew)
+{
+ LPVIEWOBJECT2 lpViewObject2;
+ RECT rect;
+
+ TestDebugOut(TEXT("In CSimpleSite::InitObject\r\n"));
+
+ // Set a View Advise
+ m_lpOleObject->QueryInterface(IID_IViewObject2,
+ (LPVOID FAR *)&lpViewObject2);
+ lpViewObject2->SetAdvise(m_dwDrawAspect, ADVF_PRIMEFIRST, &m_AdviseSink);
+
+ // get the initial size of the object
+ lpViewObject2->GetExtent(m_dwDrawAspect, -1 /*lindex*/, NULL /*ptd*/,
+ &m_sizel);
+ GetObjRect(&rect); // get the rectangle of the object in pixels
+ lpViewObject2->Release();
+
+ // give the object the name of the container app/document
+ m_lpOleObject->SetHostNames(OLESTR("Simple Application"),
+ OLESTR("Simple OLE 2.0 In-Place Container"));
+
+ // inform object handler/DLL object that it is used in the embedding
+ // container's context
+ HRESULT hRes;
+ if ((hRes = OleSetContainedObject(m_lpOleObject, TRUE))
+ != ResultFromScode(S_OK) )
+ {
+ TestDebugOut(TEXT("Fail in OleSetContainedObject\n"));
+ }
+
+ if (fCreateNew)
+ {
+ // force new object to save to guarantee valid object in our storage.
+ // OLE 1.0 objects may close w/o saving. this is NOT necessary if the
+ // object is created FROM FILE; its data in storage is already valid.
+ m_OleClientSite.SaveObject();
+
+ // we only want to DoVerb(SHOW) if this is an InsertNew object.
+ // we should NOT DoVerb(SHOW) if the object is created FromFile.
+ m_lpOleObject->DoVerb(
+ OLEIVERB_SHOW,
+ NULL,
+ &m_OleClientSite,
+ -1,
+ m_lpDoc->m_hDocWnd,
+ &rect);
+ }
+}
+
+//**********************************************************************
+//
+// CSimpleSite::PaintObj
+//
+// Purpose:
+//
+// Paints the object
+//
+// Parameters:
+//
+// HDC hDC - Device context of the document window
+//
+// Return Value:
+// None
+//
+// Function Calls:
+// Function Location
+//
+// CSimpleSite::GetObjRect SITE.CPP
+// IOleObject::QueryInterface Object
+// IViewObject::GetColorSet Object
+// IViewObject::Release Object
+// SetROP2 Windows API
+// Rectamgle Windows API
+// CreateHatchBrush Windows API
+// SelectObject Windows API
+// DeleteObject Windows API
+// CreatePalette Windows API
+// SelectPalette Windows API
+// RealizePalette Windows API
+// OleStdFree OLE2UI Function
+// OleDraw OLE API
+//
+//
+//********************************************************************
+
+void CSimpleSite::PaintObj(HDC hDC)
+{
+ RECT rect;
+
+ // need to check to make sure there is a valid object
+ // available. This is needed if there is a paint msg
+ // between the time that CSimpleSite is instantiated
+ // and OleUIInsertObject returns.
+ if (!m_lpOleObject)
+ return;
+
+ // convert it to pixels
+ GetObjRect(&rect);
+
+ LPLOGPALETTE pColorSet = NULL;
+ LPVIEWOBJECT lpView = NULL;
+
+ // get a pointer to IViewObject
+ m_lpOleObject->QueryInterface(IID_IViewObject,(LPVOID FAR *) &lpView);
+
+ // if the QI succeeds, get the LOGPALETTE for the object
+ if (lpView)
+ lpView->GetColorSet(m_dwDrawAspect, -1, NULL, NULL, NULL, &pColorSet);
+
+ HPALETTE hPal=NULL;
+ HPALETTE hOldPal=NULL;
+
+ // if a LOGPALETTE was returned (not guarateed), create the palette and
+ // realize it.NOTE:A smarter application would want to get the LOGPALETTE
+ // for each of its visible objects, and try to create a palette that
+ // satisfies all of the visible objects. ALSO: OleStdFree() is use to
+ // free the returned LOGPALETTE.
+ if ((pColorSet))
+ {
+ hPal = CreatePalette((const LPLOGPALETTE) pColorSet);
+ hOldPal = SelectPalette(hDC, hPal, FALSE);
+ RealizePalette(hDC);
+ OleStdFree(pColorSet);
+ }
+
+ // draw the object
+ HRESULT hRes;
+ hRes = OleDraw(m_lpOleObject, m_dwDrawAspect, hDC, &rect);
+ if ((hRes != ResultFromScode(S_OK)) &&
+ (hRes != ResultFromScode(OLE_E_BLANK)) &&
+ (hRes != ResultFromScode(DV_E_NOIVIEWOBJECT)))
+ {
+ TestDebugOut(TEXT("Fail in OleDraw\n"));
+ }
+
+ // if the object is open, draw a hatch rect.
+ if (m_fObjectOpen)
+ {
+ HBRUSH hBrush = CreateHatchBrush ( HS_BDIAGONAL, RGB(0,0,0) );
+ HBRUSH hOldBrush = (HBRUSH) SelectObject (hDC, hBrush);
+ SetROP2(hDC, R2_MASKPEN);
+ Rectangle (hDC, rect.left, rect.top, rect.right, rect.bottom);
+ SelectObject(hDC, hOldBrush);
+ DeleteObject(hBrush);
+ }
+
+ // if we created a palette, restore the old one, and destroy
+ // the object.
+ if (hPal)
+ {
+ SelectPalette(hDC,hOldPal,FALSE);
+ DeleteObject(hPal);
+ }
+
+ // if a view pointer was successfully returned, it needs to be released.
+ if (lpView)
+ lpView->Release();
+}
+
+//**********************************************************************
+//
+// CSimpleSite::GetObjRect
+//
+// Purpose:
+//
+// Retrieves the rect of the object in pixels
+//
+// Parameters:
+//
+// LPRECT lpRect - Rect structure filled with object's rect in pixels
+//
+// Return Value:
+// None
+//
+// Function Calls:
+// Function Location
+//
+// XformWidthInHimetricToPixels OLE2UI Function
+// XformHeightInHimetricToPixels OLE2UI Function
+//
+//
+//********************************************************************
+
+void CSimpleSite::GetObjRect(LPRECT lpRect)
+{
+ // convert it to pixels
+ lpRect->left = lpRect->top = 0;
+ lpRect->right = XformWidthInHimetricToPixels(NULL,(int)m_sizel.cx);
+ lpRect->bottom = XformHeightInHimetricToPixels(NULL,(int)m_sizel.cy);
+}
diff --git a/private/oleutest/simpcntr/site.h b/private/oleutest/simpcntr/site.h
new file mode 100644
index 000000000..ada86bcae
--- /dev/null
+++ b/private/oleutest/simpcntr/site.h
@@ -0,0 +1,53 @@
+//**********************************************************************
+// File name: SITE.H
+//
+// Definition of CSimpleSite
+//
+// Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
+//**********************************************************************
+#if !defined( _SITE_H_ )
+#define _SITE_H_
+
+#include <ole2.h>
+#include "ias.h"
+#include "ioips.h"
+#include "iocs.h"
+
+class CSimpleDoc;
+
+class CSimpleSite : public IUnknown
+{
+public:
+ int m_nCount;
+ DWORD m_dwConnection;
+ LPOLEOBJECT m_lpOleObject;
+ LPOLEINPLACEOBJECT m_lpInPlaceObject;
+ HWND m_hwndIPObj;
+ DWORD m_dwDrawAspect;
+ SIZEL m_sizel;
+ BOOL m_fInPlaceActive;
+ BOOL m_fObjectOpen;
+ LPSTORAGE m_lpObjStorage;
+
+ CAdviseSink m_AdviseSink;
+ COleInPlaceSite m_OleInPlaceSite;
+ COleClientSite m_OleClientSite;
+
+ CSimpleDoc FAR * m_lpDoc;
+
+ // IUnknown Interfaces
+ STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ void InitObject(BOOL fCreateNew);
+ static CSimpleSite FAR * Create(CSimpleDoc FAR *lpDoc);
+ CSimpleSite(CSimpleDoc FAR *lpDoc);
+ ~CSimpleSite();
+ void PaintObj(HDC hDC);
+ void GetObjRect(LPRECT lpRect);
+ void CloseOleObject(void);
+ void UnloadOleObject(void);
+};
+
+#endif
diff --git a/private/oleutest/simpcntr/tests.cpp b/private/oleutest/simpcntr/tests.cpp
new file mode 100644
index 000000000..48a535d88
--- /dev/null
+++ b/private/oleutest/simpcntr/tests.cpp
@@ -0,0 +1,202 @@
+//+-------------------------------------------------------------------------
+//
+// Microsoft Windows
+// Copyright (C) Microsoft Corporation, 1992 - 1993.
+//
+// File: tests.cpp
+//
+// Contents: Implementations of the Upper Layer unit tests for Inplace
+//
+// Classes:
+//
+// Functions: Test1
+//
+// History: dd-mmm-yy Author Comment
+// 27-Apr-94 ricksa author
+//
+//--------------------------------------------------------------------------
+
+#include "pre.h"
+#include "iocs.h"
+#include "ias.h"
+#include "ioipf.h"
+#include "ioips.h"
+#include "app.h"
+#include "site.h"
+#include "doc.h"
+#include "tests.h"
+#include "utaccel.h"
+
+const CLSID CLSID_SimpleServer = {0xbcf6d4a0, 0xbe8c, 0x1068, { 0xb6, 0xd4,
+ 0x00, 0xdd, 0x01, 0x0c, 0x05, 0x09 }};
+
+const TCHAR *pszErrorTitle = TEXT("Unit Test FAILURE");
+
+//+-------------------------------------------------------------------------
+//
+// Function: TestMsgPostThread
+//
+// Synopsis: We use this thread to post messages to the inplace server
+//
+// Arguments: [pvApp] - application object
+//
+// Algorithm: Post key board message for the accelerator for the container
+// and wait 3 seconds to see if we get response. If we do, then
+// continue by posting an accelerator to the embeddinging and
+// waiting three seconds for a response. Finally post messages
+// to everyone telling them the test is over.
+//
+// History: dd-mmm-yy Author Comment
+// 02-May-94 ricksa author
+//
+// Notes:
+//
+//--------------------------------------------------------------------------
+extern "C" DWORD TestMsgPostThread(void *pvApp)
+{
+ CSimpleApp *pApp = (CSimpleApp *) pvApp;
+ HRESULT hr = ResultFromScode(E_UNEXPECTED);
+
+ // Send an accelerator bound for the container
+ PostMessage(pApp->m_hwndUIActiveObj, WM_CHAR, SIMPCNTR_UT_ACCEL, 1);
+
+ // Give 6 seconds for chance to process an accelerator
+ for (int i = 0; i < 6; i++)
+ {
+ // Get embedding and container a chance to process the accelerator
+ Sleep(1000);
+
+ // See if it got processed
+ if (pApp->m_fGotUtestAccelerator)
+ {
+ break;
+ }
+ }
+
+ if (pApp->m_fGotUtestAccelerator)
+ {
+ hr = S_OK;
+ }
+ else
+ {
+ // The container did not received the accelerator
+ MessageBox(pApp->m_hAppWnd,
+ TEXT("Container didn't recieve accelerator"),
+ pszErrorTitle, MB_OK);
+ }
+
+ PostMessage(pApp->m_hDriverWnd, WM_TESTEND,
+ SUCCEEDED(hr) ? TEST_SUCCESS : TEST_FAILURE, (LPARAM) hr);
+
+ PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
+
+ return 0;
+}
+
+
+
+
+//+-------------------------------------------------------------------------
+//
+// Function: Test1
+//
+// Synopsis: Inserts an inplace object into this container
+//
+// Arguments: pApp -- a pointer to the CSimpleApp that we're a part of
+//
+// Algorithm: Create a simple server object. Activate the simple server
+// object. Send the container an accelerator and confirm that
+// the accelerator worked. Send the object an accelerator and
+// make sure that that accelerator worked. Then return the
+// result of the test to the test driver.
+//
+// History: dd-mmm-yy Author Comment
+// 27-Apr-94 ricksa author
+//
+// Notes:
+//
+//--------------------------------------------------------------------------
+void Test1(CSimpleApp *pApp)
+{
+ // Create the inplace object
+ HRESULT hr;
+ static FORMATETC formatetc;
+
+ //insert the simple server object
+
+ formatetc.dwAspect = DVASPECT_CONTENT;
+ formatetc.cfFormat = NULL;
+ formatetc.lindex = -1;
+
+ //need to create the client site
+
+ pApp->m_lpDoc->m_lpSite = CSimpleSite::Create(pApp->m_lpDoc);
+
+ hr = OleCreate(
+ CLSID_SimpleServer,
+ IID_IOleObject,
+ OLERENDER_DRAW,
+ &formatetc,
+ &pApp->m_lpDoc->m_lpSite->m_OleClientSite,
+ pApp->m_lpDoc->m_lpSite->m_lpObjStorage,
+ (void **) &(pApp->m_lpDoc->m_lpSite->m_lpOleObject));
+
+ if(hr == NOERROR)
+ {
+ // Activate the inplace object
+ pApp->m_lpDoc->m_lpSite->InitObject(TRUE);
+
+ // Default to unexpected failure
+ hr = ResultFromScode(E_UNEXPECTED);
+
+ if (pApp->m_lpDoc->m_fInPlaceActive)
+ {
+ // Create thread to send windows messages to container and
+ // embedding
+ DWORD dwThreadId;
+
+ HANDLE hThread = CreateThread(
+ NULL, // Security attributes - default
+ 0, // Stack size - default
+ TestMsgPostThread, // Addresss of thread function
+ pApp, // Parameter to thread
+ 0, // Flags - run immediately
+ &dwThreadId); // Thread ID returned - unused.
+
+ if (hThread != NULL)
+ {
+ // Thread was created so tell routine & dump handle
+ // we won't use.
+ hr = S_OK;
+ CloseHandle(hThread);
+ }
+ else
+ {
+ // The container did not received the accelerator
+ MessageBox(pApp->m_hAppWnd,
+ TEXT("Could not create message sending thread"),
+ pszErrorTitle, MB_OK);
+ }
+ }
+ else
+ {
+ // The object did not get activated in place
+ MessageBox(pApp->m_hAppWnd, TEXT("Could not activate in place"),
+ pszErrorTitle, MB_OK);
+ }
+ }
+ else
+ {
+ // We could not create the object
+ MessageBox(pApp->m_hAppWnd, TEXT("Could not create embedding"),
+ pszErrorTitle, MB_OK);
+ }
+
+ if (FAILED(hr))
+ {
+ PostMessage(pApp->m_hDriverWnd, WM_TESTEND,
+ SUCCEEDED(hr) ? TEST_SUCCESS : TEST_FAILURE, (LPARAM) hr);
+ }
+
+ return;
+}
diff --git a/private/oleutest/simpcntr/tests.h b/private/oleutest/simpcntr/tests.h
new file mode 100644
index 000000000..c4183e7ec
--- /dev/null
+++ b/private/oleutest/simpcntr/tests.h
@@ -0,0 +1,8 @@
+#ifndef _TESTS_H_
+#define _TESTS_H_
+
+#include <testmess.h>
+
+void Test1(CSimpleApp *pApp);
+
+#endif // _TESTS_H_
diff --git a/private/oleutest/simpcntr/utaccel.h b/private/oleutest/simpcntr/utaccel.h
new file mode 100644
index 000000000..c40b4655b
--- /dev/null
+++ b/private/oleutest/simpcntr/utaccel.h
@@ -0,0 +1,7 @@
+#ifndef _UTACCEL_H_
+#define _UTACCEL_H_
+
+#define SIMPCNTR_UT_ACCEL 1
+#define SIMPSVR_UT_ACCEL 3
+
+#endif // _UTACCEL_H_