WTL 9.0的变化 - atlctrls.h

本文详细介绍了atlctrls.h文件中CRichEditCtrlT类的修改,包括封装函数、模板类CImageList、新增查找函数FindItem、获取工具栏上下拉框矩形大小函数GetItemDropDownRect、添加分隔线函数InsertSeparator和AddSeparator、RichEdit控件宏定义变化、新增RichEdit8相关函数等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

atlctrls.h中是对控件的封装。

第1249行增加:

void GetMargins(UINT& nLeft, UINT& nRight) const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L);
    nLeft = LOWORD(dwRet);
    nRight = HIWORD(dwRet);
  }

没什么好说的,原来的函数是以返回值的方式获取:

DWORD GetMargins() const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L);
  }

第1858行,CImageList变成了模板类,增加了自动销毁模板开头:

// forward declarations
template <bool t_bManaged> class CImageListT;
typedef CImageListT<false>   CImageList;
typedef CImageListT<true>    CImageListManaged;


template <bool t_bManaged>
class CImageListT
{
public:
// Data members
  HIMAGELIST m_hImageList;

// Constructor/destructor/operators
  CImageListT(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList)
  { }

  ~CImageListT()
  {
    if(t_bManaged && (m_hImageList != NULL))
      Destroy();
  }

第3706行,CListViewCtrlT.FindItem 增加了一个重载:

int FindItem(LPCTSTR lpstrFind, bool bPartial = true, bool bWrap = false, int nStart = -1) const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    LVFINDINFO lvfi = { 0 };
    lvfi.flags = LVFI_STRING | (bWrap ? LVFI_WRAP : 0) | (bPartial ? LVFI_PARTIAL : 0);
    lvfi.psz = lpstrFind;
    return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi);
  }

查找ListView item时不用费劲地填结构体了。

第5819行,CToolBarCtrlT增加GetItemDropDownRect:

void GetItemDropDownRect(int nIndex, LPRECT lpRect) const
  {
#ifndef TB_GETITEMDROPDOWNRECT
    const int TB_GETITEMDROPDOWNRECT = WM_USER + 103;
#endif
    ATLASSERT(::IsWindow(m_hWnd));
    BOOL bRet = (BOOL)::SendMessage(m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect);
    bRet;   // avoid level 4 warning
    ATLASSERT(bRet != FALSE);
  }

用来获取工具栏上下拉框的窗口矩形大小。(_WIN32_WINNT >= 0x0600)

第5934行,CToolBarCtrlT增加:

BOOL InsertSeparator(int nIndex, int cxWidth = 8)
  {
    return InsertButton(nIndex, 0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0);
  }

  BOOL AddSeparator(int cxWidth = 8)
  {
    return AddButton(0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0);
  }

用来添加工具栏上的分隔线。

第6397行,GetToolTips、SetToolTips中的tips由小写变成了大写Tips……。

第6656行,CTrackBarCtrlT.SetSelStart 和接下来的SetSelEnd、SetSelection增加了bRedraw参数:

void SetSelStart(int nMin, BOOL bRedraw = FALSE)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    ::SendMessage(m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin);
  }

第7291行,增加了RichEdit 5的宏定义:

#if !defined(_UNICODE) && (_RICHEDIT_VER >= 0x0500)
  #undef MSFTEDIT_CLASS
  #define MSFTEDIT_CLASS	"RICHEDIT50W"
#endif

这影响到CRichEditCtrlT调用的是哪个版本的RichEdit控件。

static LPCTSTR GetLibraryName()
  {
#if (_RICHEDIT_VER >= 0x0500)
    return _T("MSFTEDIT.DLL");
#elif (_RICHEDIT_VER >= 0x0200)
    return _T("RICHED20.DLL");
#else
    return _T("RICHED32.DLL");
#endif
  }

第7825行,增加CRichEditCtrlT.GetWordBreakProc 和CRichEditCtrlT.SetWordBreakProc :

EDITWORDBREAKPROC GetWordBreakProc() const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L);
  }

  void SetWordBreakProc(EDITWORDBREAKPROC ewbprc)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc);
  }

第8160行,为RichEdit 8增加的代码:

#if (_RICHEDIT_VER >= 0x0800)
  AutoCorrectProc GetAutoCorrectProc() const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (AutoCorrectProc)::SendMessage(m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L);
  }

  BOOL SetAutoCorrectProc(AutoCorrectProc pfn)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L);
  }

  BOOL CallAutoCorrectProc(WCHAR ch)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L);
  }

  DWORD GetEditStyleEx() const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (DWORD)::SendMessage(m_hWnd, EM_GETEDITSTYLEEX, 0, 0L);
  }

  DWORD SetEditStyleEx(DWORD dwStyleEx, DWORD dwMask)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (DWORD)::SendMessage(m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask);
  }

  DWORD GetStoryType(int nStoryIndex) const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (DWORD)::SendMessage(m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L);
  }

  DWORD SetStoryType(int nStoryIndex, DWORD dwStoryType)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (DWORD)::SendMessage(m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType);
  }

  DWORD GetEllipsisMode() const
  {
    ATLASSERT(::IsWindow(m_hWnd));

    DWORD dwMode = 0;
    BOOL bRet = (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode);
    bRet;   // avoid level 4 warning
    ATLASSERT(bRet != FALSE);

    return dwMode;
  }

  BOOL SetEllipsisMode(DWORD dwEllipsisMode)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode);
  }

  BOOL GetEllipsisState() const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_GETELLIPSISSTATE, 0, 0L);
  }

  BOOL GetTouchOptions(int nTouchOptions) const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L);
  }

  void SetTouchOptions(int nTouchOptions, BOOL bEnable)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    ::SendMessage(m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable);
  }

  HRESULT InsertTable(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (HRESULT)::SendMessage(m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams);
  }

  HRESULT GetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) const
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (HRESULT)::SendMessage(m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams);
  }

  HRESULT SetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (HRESULT)::SendMessage(m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams);
  }

  HRESULT InsertImage(RICHEDIT_IMAGE_PARAMETERS* pParams)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (HRESULT)::SendMessage(m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams);
  }

  BOOL SetUiaName(LPCTSTR lpstrName)
  {
    ATLASSERT(::IsWindow(m_hWnd));
    return (BOOL)::SendMessage(m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName);
  }
#endif // (_RICHEDIT_VER >= 0x0800)

总体来说,atlctrls.h中最大的更改就属CRichEditCtrlT了。

WTL版本为v9.0 (build 4060 @ 3-1-2014),并做了以下的改动: 1. 编辑了.rc文件,使控件具有原生的中文字符支持 2. 增加了UICC及VS2010安装脚本(环境变量添加,UICC拷贝及.props文件路径添加),在SDK v7.0A的v100工具链下也可以编译.xml文件并使用ribbon, 脚本执行后默认工程可自动包含WTL include 目录。 3. 美化了.ico图标和toolbar.bmp,新图标和位图具有Alpha通道。 4. 为winCE和winMobile添加setup100.js安装文件,使其支持VS2010。 5. VS2010外其它平台需要手工修改InstallWTL.bat。 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Changes ======================================== 1. Add InstallWTL.bat and &#39;setup100.js&#39;(for CE & Mobile) 2. Add &#39;uicc&#39; for ribbon compilation. 3. Replace the old icon and bitmap resources. 4. Modify &#39;rc&#39; file to use default &#39;Chinese (Simplified)&#39; resources. About the Files Added ======================================== a> IntallWTL.bat (must be runned as administrator; install in current folder) O- Create environment variable &#39;WTL_INC&#39;, integrating it into the include directory of VS2010 default project. O- Place &#39;uicc.exe&#39; into &#39;Windows SDK 7.0A&#39; folder. O- Execute setup.js & setup100.js. b> uicc.exe (dispense the need for installing &#39;Windows SDK 7.1&#39; on visual studio 2010) O- Extracted from &#39;Windows SDK 7.1&#39; O- Enable &#39;Ribbon&#39; compilation using VS2010 &#39;v100&#39; platform toolset. Issues (Questions & Answers) ======================================== Q: Error in &#39;VS2010&#39; saying “An error has occurred in the script on the page" A: This is a security problem. The wizard files are marked as unsecure. Solution: compress the wtl zip, unzip it (e.g. 7zip) and install the AppWiz again. Do not copy & paste the "*.js" files to the new destination. This will mark the file as unsecure. You see this with right-click properties on the file. At the bottom of the first page you see “The file came from another computer. Access is blocked possibly for security reasons”.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值