Click here to Skip to main content
15,896,269 members
Articles / Desktop Programming / WTL

Add a WTL MDI window into an ATL Control

Rate me:
Please Sign up or sign in to vote.
4.77/5 (12 votes)
11 Sep 20031 min read 68.4K   1.6K   20  
This article will show you how to make MDI window of WTL into ATL control by using a real world example.
// MdiControl.cpp : Implementation of DLL Exports.

#include "stdafx.h"
#include "resource.h"
#include "MdiControl.h"
/*
class CMdiControlModule : public CAtlDllModuleT< CMdiControlModule >
{
public :
	DECLARE_LIBID(LIBID_MdiControlLib)
	DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MDICONTROL, "{DA155D37-087A-4865-BD60-A88A95F21C4B}")
};

CMdiControlModule _AtlModule;
*/

YF_DECLARE_LIBID(LIBID_MdiControlLib)
YF_DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MDICONTROL, "{DA155D37-087A-4865-BD60-A88A95F21C4B}")

#define _AtlModule _Module

// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	hInstance;
    return _AtlModule.DllMain(dwReason, lpReserved); 
}


// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
    return _AtlModule.DllCanUnloadNow();
}


// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}


// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib
    HRESULT hr = _AtlModule.DllRegisterServer();
	return hr;
}


// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
	HRESULT hr = _AtlModule.DllUnregisterServer();
	return hr;
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions