Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / ATL

ATL COM EXE Server with MFC support

Rate me:
Please Sign up or sign in to vote.
3.33/5 (6 votes)
17 Mar 20052 min read 186.5K   1.5K   29  
Adding MFC support to the ATL COM EXE Server.
// MFCWindowObject.cpp : Implementation of CATLMFCCOMServerApp and DLL registration.

#include "stdafx.h"
#include "ATLMFCCOMServer.h"
#include "MFCWindowObject.h"
#include "MFCWnd.h"

/////////////////////////////////////////////////////////////////////////////
//

STDMETHODIMP MFCWindowObject::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IMFCWindowObject,
	};

	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

STDMETHODIMP MFCWindowObject::CreateMFCWindow(long hWnd)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	CWnd aWnd;
	aWnd.Attach((HWND)hWnd);
	m_pWnd = new CMFCWnd;
	m_pWnd->Create(NULL, _T("MFCWindow"), 
		WS_CHILD | WS_VISIBLE | WS_EX_CLIENTEDGE, 
		CRect(0, 0, 100, 100), 
		&aWnd, 
		1000
	);

	aWnd.Detach();

	return S_OK;
}

STDMETHODIMP MFCWindowObject::Update()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	m_pWnd->Invalidate();
	return S_OK;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
He got Master degree of Theory and Application of Automatic Control from Tsinghua university(Beijing,China) in 1997,from then on he has been working for Tsinghua TongFang Software Co.Ltd,Beijing China.

Comments and Discussions