WTL : Add RichEditCtrl To CPaneContainerImpl

向窗口中动态加控件, 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()
{

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值