程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> WTL 9.0的變化

WTL 9.0的變化

編輯:C++入門知識

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了。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved