向窗口中动态加控件, ctrl.create => this->SetClient, 通用的方法
WTL::CAppModule g_WtlAppModule;
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
ATLASSERT(SUCCEEDED(hRes));
// fnTest();
::DefWindowProc(NULL, 0, 0, 0L);
WTL::AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_WIN95_CLASSES);
// Init the common controls, then load the rich edit DLL.
LoadLibrary(WTL::CRichEditCtrl::GetLibraryName()); ///< !
/// @file LsPaneContainerPeNodeDesc.h
#ifndef __LS_PANECONTAINER_PENODEDESC_H__
#define __LS_PANECONTAINER_PENODEDESC_H__
#include "LsPaneContainer.h"
#include "LsRichEdit.h"
class CLsPaneContainerPeNodeDesc :
public CLsPaneContainer
{
public:
CLsPaneContainerPeNodeDesc(void);
virtual ~CLsPaneContainerPeNodeDesc(void);
BEGIN_MSG_MAP(CLsPaneContainerPeNodeDesc)
CHAIN_MSG_MAP(CLsPaneContainer)
REFLECT_NOTIFICATIONS()
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
HWND Create(
HWND hWndParent,
LPCTSTR lpstrTitle = NULL,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
DWORD dwExStyle = 0,
UINT nID = 0,
LPVOID lpCreateParam = NULL);
private:
CLsRichEdit /*WTL::CRichEditCtrl*/ m_RichEdit;
};
#endif // #ifndef __LS_PANECONTAINER_PENODEDESC_H__
/// @file LsPaneContainerPeNodeDesc.cpp
#include "stdafx.h"
#include "LsPaneContainerPeNodeDesc.h"
CLsPaneContainerPeNodeDesc::CLsPaneContainerPeNodeDesc(void)
{
}
CLsPaneContainerPeNodeDesc::~CLsPaneContainerPeNodeDesc(void)
{
}
HWND CLsPaneContainerPeNodeDesc::Create(
HWND hWndParent,
LPCTSTR lpstrTitle,
DWORD dwStyle,
DWORD dwExStyle,
UINT nID,
LPVOID lpCreateParam)
{
HWND hWnd = NULL;
HWND hWndCtrl = NULL;
const DWORD dwRichEditStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
WS_HSCROLL | WS_VSCROLL | /*WS_BORDER |*/
/*ES_READONLY | */ ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE;
hWnd = CLsPaneContainer::Create(
hWndParent,
lpstrTitle,
dwStyle,
dwExStyle,
nID,
lpCreateParam);
/// 向窗口中动态加控件, ctrl.create => this->SetClient, 通用的方法
hWndCtrl = m_RichEdit.Create(
m_hWnd,
rcDefault,
NULL,
dwRichEditStyle,
WS_EX_CLIENTEDGE);
this->SetClient(hWndCtrl); ///< !
return hWnd;
}
/// @file lsRichEdit.h
#ifndef __LS_RICHEDIT_H__
#define __LS_RICHEDIT_H__
#include "stdafx.h"
typedef CWinTraitsOR<
WS_BORDER> CRichEditCtrlTraits;
/// 自己继承一个类出来,方便写重载方法.
class CLsRichEdit :
public ATL::CWindowImpl<CLsRichEdit, WTL::CRichEditCtrl, CRichEditCtrlTraits>,
public WTL::CCustomDraw<CLsRichEdit>
{
public:
CLsRichEdit();
virtual ~CLsRichEdit();
BEGIN_MSG_MAP(CLsRichEdit)
CHAIN_MSG_MAP(WTL::CCustomDraw<CLsRichEdit>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP() ///< 末尾有() ! else "fatal error C1075: end of file found before the left brace"
};
#endif // #ifndef __LS_RICHEDIT_H__
/// @file LsRichEdit.cpp
#include "LsRichEdit.h"
CLsRichEdit::CLsRichEdit()
{
}
CLsRichEdit::~CLsRichEdit()
{
}