Optimum window width for this document...

Windows Template Library (WTL 3.1) Quick Reference

Document version 1.0.6, 6/11/2002.

Table of Contents

  1. Alphabetical Class Locator
  2. Class Overview
  3. WTL Templates and Classes
    1. App/Module Support
    2. Frame Windows
    3. MDI Windows
    4. Update UI
    5. Standard Controls
    6. Common Controls
    7. Property Sheet & Page
    8. Common Dialogs
    9. User Support
    10. GDI support
    11. Enhanced Controls
    12. Additional UI Components
    13. Printing Support
    14. Miscellaneous
  4. Global Functions
  5. File Packing List
  6. To Do
  7. Document History
  8. Credits

Alphabetical Class Locator

A CAnimateCtrl, CAppModule, CAxPropertyPage, CAxPropertyPageImpl<> B CBitmap, CBitmapButton, CBitmapButtonImpl, CBrush, CButton C CCheckListViewCtrl, CCheckListViewCtrlImpl, CClientDC, CColorDialog, CColorDialogImpl<>, CComboBox, CComboBoxEx, CCommandBarCtrl, CCommandBarCtrlImpl, CCustomDraw<> D CDateTimePickerCtrl, CDC, CDevMode, CDialogResize<>, CDragListBox, CDragListNotifyImpl<> E CEdit, CEditCommands, CEnhMetaFile, CEnhMetaFileDC, CEnhMetaFileInfo F CFileDialog, CFileDialogImpl<>, CFindReplaceDialog, CFindReplaceDialogImpl<>, CFlatScrollBar, CFlatScrollBarImpl, CFolderDialog, CFolderDialogImpl<>, CFont, CFontDialog, CFontDialogImpl<>, CFrameWindowImpl<>, CFrameWindowImplBase H CHeaderCtrl, CHotKeyCtrl, CHyperLink, CHyperLinkImpl I CIdleHandler, CImageList, CIPAddressCtrl L CListBox, CListViewCtrl M CMapScrollImpl, CMapScrollWindowImpl, CMDIChildWindowImpl<>, CMDIFrameWindowImpl<>, CMDIWindow, CMenu, CMessageFilter, CMessageLoop, CMonthCalendarCtrl, CMultiPaneStatusBarCtrl, CMultiPaneStatusBarCtrlImpl O COwnerDraw<> P CPageSetupDialog, CPageSetupDialogImpl<>, CPaintDC, CPalette, CPaneContainer, CPaneContainerImpl<>, CPen, CPoint, CPrintDialog, CPrintDialogEx, CPrintDialogExImpl<>, CPrintDialogImpl<>, CPrinter, CPrinterDC, CPrinterInfo<>, CPrintJob, CPrintJobInfo, CPrintPreview, CPrintPreviewWindow, CPrintPreviewWindowImpl, CProgressBarCtrl, CPropertyPage, CPropertyPageImpl<>, CPropertyPageWindow, CPropertySheet, CPropertySheetImpl<>, CPropertySheetWindow R CReBarCtrl, CRecentDocumentList<>, CRecentDocumentListBase, CRect, CRgn, CRichEditCommands, CRichEditCtrl, CRichEditFontDialog, CRichEditFontDialogImpl<> S CScrollBar, CScrollImpl, CScrollWindowImpl, CServerAppModule, CSize, CSplitterImpl, CSplitterWindow, CSplitterWindowImpl, CStatic, CStatusBarCtrl, CString T CTabCtrl, CToolBarCtrl, CToolInfo, CToolTipCtrl, CTrackBarCtrl, CTreeItem, CTreeViewCtrl, CTreeViewCtrlEx U CUpdateUI<>, CUpdateUIBase, CUpDownCtrl W CWaitCursor, CWinDataExchange, CWindowDC


Class Overview

Usage:  mi base - a base class (multiple inheritance)
    client  - wrapper class for a handle
    impl    - implements a window (has WindowProc)
    as-is   - to be used directly
    helper  - a helper class
    base    - implementation base class
Class NameUsageDescription
App/Module Support
CAppModuleas-isapp support, CComModule derived
    CServerAppModuleas-ismodule for COM servers
CMessageLoopas-ismessage loop
CMessageFiltermi basemessage filter interface
CIdleHandlermi baseidle time handler interface
Frame Windows
CFrameWindowImplBasebase
    CFrameWindowImpl<>implframe window support
COwnerDraw<>impl mi baseowner-draw msg map and handlers
CDialogResize<>impl mi basesupport for resizing dialogs
MDI Windows
CMDIWindowclientMDI methods
CMDIFrameWindowImpl<>implMDI frame window
CMDIChildWindowImpl<>implMDI child window
Update UI
CUpdateUIBasebase
    CUpdateUI<>mi base classprovides support for UI update
Standard Controls
CStaticclientstatic ctrl
CButtonclientbutton ctrl
CListBoxclientlist box ctrl
CComboBoxclientcombo box ctrl
CEditclientedit ctrl
CEditCommandsmistandard edit command support
CScrollBarclientscroll bar ctrl
Common Controls
CImageListclient/implimage list
CListViewCtrlclientlist view ctrl
CTreeViewCtrlclienttree view ctrl
    CTreeItemhelper
CTreeViewCtrlExclientuses CTreeItem
CHeaderCtrlclientheader bar ctrl
CToolBarCtrlclienttoolbar ctrl
CStatusBarCtrlclientstatus bar ctrl
CTabCtrlclienttab ctrl
CToolTipCtrlclienttool tip ctrl
    CToolInfohelper
CTrackBarCtrlclienttrackbar ctrl
CUpDownCtrlclientup-down ctrl
CProgressBarCtrlclientprogress bar ctrl
CHotKeyCtrlclienthot key ctrl
CAnimateCtrlclientanimation ctrl
CRichEditCtrlclientrich edit ctrl
CRichEditCommandsmistd rich edit commands support
CDragListBoxclientdrag list box
    CDragListNotifyImpl<>impl mi classsupport for notifications
CReBarCtrlclientrebar ctrl
CComboBoxExclientextended combo box
CDateTimePickerCtrlclientdate-time ctrl
CFlatScrollBarImplmi implflat scroll bars support
CFlatScrollBaras-isflat scroll bars support
CIPAddressCtrlclientIP address ctrl
CMonthCalendarCtrlclientmonth calendar ctrl
CCustomDraw<>impl mi classcustom draw handling support
Property Sheet & Page
CPropertySheetWindowclient
    CPropertySheetImpl<>implproperty sheet
        CPropertySheetas-is
CPropertyPageWindowclient
    CPropertyPageImpl<>implproperty page
        CPropertyPageas-is
    CAxPropertyPageImpl<>implproperty page with ActiveX
        CAxPropertyPageas-is
Common Dialogs
CFileDialogImpl<>implGetOpenFileName/GetSaveFileName
    CFileDialogas-is
CFolderDialogImpl<>impldirectory picker
    CFolderDialogas-is
CFontDialogImpl<>implChooseFont common dialog
    CFontDialogas-is
    CRichEditFontDialogImpl<>implChooseFont for rich edit
        CRichEditFontDialogas-is
CColorDialogImpl<>implChooseColor common dialog
    CColorDialogas-is
CPrintDialogImpl<>implPrintDlg common dialog
    CPrintDialogas-is
CPrintDialogExImpl<>implnew Win2000 print dialog
    CPrintDialogExas-is
CPageSetupDialogImpl<>implPageSetupDlg common dialog
    CPageSetupDialogas-is
CFindReplaceDialogImpl<>implFindText/ReplaceText
    CFindReplaceDialogas-is
User Support
CMenuclientmenu support
GDI support
CDCclientDC support
    CPaintDCclientfor handling WM_PAINT
    CClientDCclientfor GetDC
    CWindowDCclientfor GetWindowDC
    CEnhMetaFileDCclientfor DCs drawn from a metafile
CPenclientGDI pen object
CBrushclientGDI brush object
CFontclientGDI font object
CBitmapclientGDI bitmap object
CPaletteclientGDI palette object
CRgnclientGDI rgn object
CEnhMetaFileInfoclientGDI metafile information
CEnhMetaFileclientGDI enhanced metafile object
Enhanced Controls
CCommandBarCtrlImplimplcommand bar
    CCommandBarCtrlas-is
CBitmapButtonImplimplbitmap button
    CBitmapButtonas-is
CCheckListViewCtrlImplimplcheck list box
    CCheckListViewCtrlas-is
CHyperLinkImplimplhyper link control
    CHyperLinkas-is
CWaitCursoras-iswait cursor
CMultiPaneStatusBarCtrlImplimplstatus bar with multiple panes
    CMultiPaneStatusBarCtrlas-is
CPaneContainerImpl<>implpane window container
    CPaneContaineras-is
Additional UI Components
CScrollImplimplscrolling support
CScrollWindowImplimplscrollable window
CMapScrollImplimplscrolling support with map modes
CMapScrollWindowImplimplscrollable window with map modes
CSplitterImplimplsplitter support
CSplitterWindowImplimplsplitter window
CSplitterWindowas-is
Printing Support
CPrinterInfo<>as-isprint info support
CPrinterclientprinter handle wrapper
CDevModeclientDEVMODE wrapper
CPrinterDCclientprinting DC support
CPrintJobInfoclientprint job info
CPrintJobclientprint job support
CPrintPreviewmiprint preview support
CPrintPreviewWindowImplimpl
    CPrintPreviewWindowas-isprint preview window
Miscellaneous
CSizeas-isATL port of MFC's CSize
CPointas-isATL port of MFC's CPoint
CRectas-isATL port of MFC's CRect
CStringas-isATL port of MFC's CString
CWinDataExchangemidata exchange for controls
CRecentDocumentListBasebase
    CRecentDocumentList<>mi or as-issupport for MRU list

App/Module Support

CAppModule

Basics

Characteristic Value/description
Inherits from CComModule (ATL)
Usage mode As-is global application object (typically named _Module)

Methods

public:
    HRESULT Init(_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance,
        const GUID* pLibID = NULL)
    void Term()
    BOOL AddMessageLoop(CMessageLoop* pMsgLoop)
    BOOL RemoveMessageLoop()
    CMessageLoop* GetMessageLoop(DWORD dwThreadID = ::GetCurrentThreadId())
        const
    BOOL AddSettingChangeNotify(HWND hWnd)
    BOOL RemoveSettingChangeNotify(HWND hWnd)

Methods Inherited from CComModule

public:
    void AddCreateWndData(_AtlCreateWndData* pData, void* pObject)
    void* ExtractCreateWndData()
    HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL)
    HRESULT AddThunk(IUnknown** pp, LPCTSTR lpsz, REFIID iid)
    HRESULT AddNonAddRefThunk(IUnknown* p, LPCTSTR lpsz, IUnknown** ppThunkRet)
    void DeleteNonAddRefThunk(IUnknown* pUnk)
    void DeleteThunk(_QIThunk* p)
    bool DumpLeakedThunks()
    void Term()
    HRESULT AddTermFunc(_ATL_TERMFUNC* pFunc, DWORD dw)
    LONG Lock()
    LONG Unlock()
    LONG GetLockCount()
    HINSTANCE GetModuleInstance() {return m_hInst;}
    HINSTANCE GetResourceInstance() {return m_hInstResource;}
    HINSTANCE GetTypeLibInstance() {return m_hInstTypeLib;}
    HRESULT RegisterTypeLib()
    HRESULT RegisterTypeLib(LPCTSTR lpszIndex)
    HRESULT UnRegisterTypeLib()
    HRESULT UnRegisterTypeLib(LPCTSTR lpszIndex)
    HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL)
    HRESULT UnregisterServer(const CLSID* pCLSID = NULL)
    HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL)
    HRESULT WINAPI UpdateRegistryFromResourceD(LPCTSTR lpszRes, BOOL bRegister,
        struct _ATL_REGMAP_ENTRY* pMapEntries = NULL)
    HRESULT WINAPI UpdateRegistryFromResourceD(UINT nResID, BOOL bRegister,
        struct _ATL_REGMAP_ENTRY* pMapEntries = NULL)
    HRESULT WINAPI UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister,
        struct _ATL_REGMAP_ENTRY* pMapEntries = NULL);
    HRESULT WINAPI UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister,
        struct _ATL_REGMAP_ENTRY* pMapEntries = NULL);
    HRESULT WINAPI UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID,
        LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags, BOOL bRegister);
    HRESULT WINAPI RegisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
        LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags);
    HRESULT WINAPI UnregisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
        LPCTSTR lpszVerIndProgID);
    HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags)
    HRESULT RevokeClassObjects()
    HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
    HRESULT CreateInstance(void* /*pfnCreateInstance*/, REFIID /*riid*/, void** /*ppvObj*/)
    static HRESULT RegisterProgID(LPCTSTR lpszCLSID, LPCTSTR lpszProgID, LPCTSTR lpszUserDesc);
    static void ReplaceSingleQuote(LPOLESTR lpDest, LPCOLESTR lp)

Data Members

public:
    DWORD m_dwMainThreadID;
    CSimpleMap* m_pMsgLoopMap;
    CSimpleArray* m_pSettingChangeNotify;

Data Members Inherited from CComModule

public:
    static GUID m_libid;
    UINT m_nIndexQI;
    UINT m_nIndexBreakAt;
    CSimpleArray<_QIThunk*>* m_paThunks;

Data Members Inherited from _ATL_MODULE

public:
    UINT cbSize;
    HINSTANCE m_hInst;
    HINSTANCE m_hInstResource;
    HINSTANCE m_hInstTypeLib;
    _ATL_OBJMAP_ENTRY* m_pObjMap;
    LONG m_nLockCnt;
    HANDLE m_hHeap;
    union
    {
        CRITICAL_SECTION m_csTypeInfoHolder;
        CRITICAL_SECTION m_csStaticDataInit;
    };
    CRITICAL_SECTION m_csWindowCreate;
    CRITICAL_SECTION m_csObjMap;
    DWORD dwAtlBuildVer;
    _AtlCreateWndData* m_pCreateWndList;
    bool m_bDestroyHeap;
    GUID* pguidVer;
    DWORD m_dwHeaps;    // Number of heaps we have (-1)
    HANDLE* m_phHeaps;
    int m_nHeap;        // Which heap to choose from
    _ATL_TERMFUNC_ELEM* m_pTermFuncs;

CServerAppModule

Basics

Characteristic Value/description
Inherits from CAppModule
Usage mode As-is global application object (typically named _Module)

Methods

public:
    HRESULT Init(_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)
    void Term()
    LONG Unlock()
    void MonitorShutdown()
    bool StartMonitor()
    bool ParseCommandLine(LPCTSTR lpCmdLine, UINT nResId, HRESULT* pnRetCode)
    bool ParseCommandLine(LPCTSTR lpCmdLine, LPCTSTR pAppId, HRESULT* pnRetCode)
    static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
    HRESULT RegisterAppId(LPCTSTR pAppId)
    HRESULT UnregisterAppId(LPCTSTR pAppId)

Data Members

public:
    HANDLE m_hEventShutdown;
    bool m_bActivity;
    DWORD m_dwTimeOut;
    DWORD m_dwPause;

CMessageLoop

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode As-is, typically used within a CMainFrame implementation

Methods

public:
    BOOL AddMessageFilter(CMessageFilter* pMessageFilter)
    BOOL RemoveMessageFilter(CMessageFilter* pMessageFilter)
    BOOL AddIdleHandler(CIdleHandler* pIdleHandler)
    BOOL RemoveIdleHandler(CIdleHandler* pIdleHandler)
    BOOL AddUpdateUI(CIdleHandler* pIdleHandler)
    BOOL RemoveUpdateUI(CIdleHandler* pIdleHandler)
    int Run()
    static BOOL IsIdleMessage(MSG* pMsg)
Overrideables
    // Override to change message filtering
    virtual BOOL PreTranslateMessage(MSG* pMsg)

    // Override to change idle processing
    virtual BOOL OnIdle(int /*nIdleCount*/)

Data Members

public:
    CSimpleArray m_aMsgFilter;
    CSimpleArray m_aIdleHandler;
    MSG m_msg;

CMessageFilter

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class for window and modeless dialog implementation

Usage Notes

If you want a shot at message before the message loop sends them to TranslateMessage(), make your window or dialog class multiply-inherit from this class. All it does is add a single method to your class, PreTranslateMessage, which you must override.

There's a bit more to it than that, though. You've got to register your class as a message filter with the CMessageLoop, or your PreTranslateMessage method will never be called.

For a modeless dialog, you'd typically do register yourself in OnInitDialog (WM_INITDIALOG). For a winodw, you register yourself in OnCreate (WM_CREATE). Here's how you register the window or dialog class to filter messages:

    CMessageLoop* pLoop = _Module.GetMessageLoop();
    pLoop->AddMessageFilter(this);

As for the implementation of PreTranslateMessage, here's what you'd do for a dialog:

    virtual BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
    {
        if (pMsg->message = WM_WHATEVER)
        {
            //...my code to handle WM_WHATEVER
            return TRUE;
        }

        return IsDialogMessage(pMsg);
    }

For a typical CMainFrame-type frame window containing a view, you might want to give CFrameWindowImpl a shot at the message first, then pass it along to your member view window, like this:

    virtual BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
    {
        if (CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
            return TRUE;

        return m_view.PreTranslateMessage(pMsg);
    }

Methods

public:
    virtual BOOL PreTranslateMessage(MSG* pMsg) = 0;

Data Members

    (none)

CIdleHandler

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class for CMainFrame implementation

Methods

public:
    virtual BOOL OnIdle() = 0;

Data Members

    (none)

Frame Windows

CFrameWindowImplBase

Basics

Characteristic Value/description
Inherits from CWindowImplBase<>
Usage mode Base class (normally you use a CFrameWindowImpl<>)

Methods

public:
    CFrameWindowImplBase()
    HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle,
        DWORD dwExStyle, _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam)
    static HWND CreateSimpleToolBarCtrl(HWND hWndParent, UINT nResourceID,
        BOOL bInitialSeparator = FALSE, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE,
        UINT nID = ATL_IDW_TOOLBAR)
    static HWND CreateSimpleReBarCtrl(HWND hWndParent,
        DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR)
    BOOL CreateSimpleReBar(DWORD dwStyle = ATL_SIMPLE_REBAR_STYLE,
        UINT nID = ATL_IDW_TOOLBAR)
    static BOOL AddSimpleReBarBandCtrl(HWND hWndReBar, HWND hWndBand, int nID = 0,
        LPTSTR lpstrTitle = NULL, BOOL bNewRow = FALSE, int cxWidth = 0,
        BOOL bFullWidthAlways = FALSE)
    BOOL AddSimpleReBarBand(HWND hWndBand, LPTSTR lpstrTitle = NULL,
        BOOL bNewRow = FALSE, int cxWidth = 0, BOOL bFullWidthAlways = FALSE)
    void SizeSimpleReBarBands()
    BOOL CreateSimpleStatusBar(LPCTSTR lpstrText,
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
            | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR)
    BOOL CreateSimpleStatusBar(UINT nTextID = ATL_IDS_IDLEMESSAGE,
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
            | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR)
    void UpdateLayout(BOOL bResizeBars = TRUE)
    void UpdateBarsPosition(RECT& rect, BOOL bResizeBars = TRUE)
    BOOL PreTranslateMessage(MSG* pMsg)
    bool PrepareChevronMenu(_ChevronMenuInfo& cmi)
    void DisplayChevronMenu(_ChevronMenuInfo& cmi)
    void CleanupChevronMenu(_ChevronMenuInfo& cmi)

Message Map and Handlers

    BEGIN_MSG_MAP(CFrameWindowImplBase)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
        MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
        NOTIFY_CODE_HANDLER(TTN_GETDISPINFOA, OnToolTipTextA)
        NOTIFY_CODE_HANDLER(TTN_GETDISPINFOW, OnToolTipTextW)
    END_MSG_MAP()

    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
        BOOL& bHandled)
    LRESULT OnMenuSelect(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnSetFocus(UINT, WPARAM, LPARAM, BOOL& bHandled)
    LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL& bHandled)
    LRESULT OnToolTipTextA(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT OnToolTipTextW(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/)

Methods Inherited from CWindowImplBase<>

public:
    CWindowImplBase()
    static DWORD GetWndStyle(DWORD dwStyle)
    static DWORD GetWndExStyle(DWORD dwExStyle)
    virtual WNDPROC GetWindowProc()
    static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam,
        LPARAM lParam);
    static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam,
        LPARAM lParam);
    HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName,
        DWORD dwStyle, DWORD dwExStyle, UINT nID, ATOM atom,
        LPVOID lpCreateParam = NULL);
    BOOL DestroyWindow()
    BOOL SubclassWindow(HWND hWnd);
    HWND UnsubclassWindow(BOOL bForce = FALSE);
    LRESULT DefWindowProc()
    LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Overrideables
    virtual void OnFinalMessage(HWND /*hWnd*/)

Data Members

public:
    HWND m_hWndToolBar;
    HWND m_hWndStatusBar;
    HWND m_hWndClient;
    HACCEL m_hAccel;

Data Members Inherited from CWindowImplBase<>

public:
    WNDPROC m_pfnSuperWindowProc;

CFrameWindowImpl<>

Basics

Characteristic Value/description
Inherits from CFrameWindowImplBase
Usage mode Window implementation (has a WindowProc)

Methods

public:
    HWND Create(HWND hWndParent = NULL, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            HMENU hMenu = NULL, LPVOID lpCreateParam = NULL)
    HWND CreateEx(HWND hWndParent = NULL, _U_RECT rect = NULL, DWORD dwStyle = 0,
        DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL)
    BOOL CreateSimpleToolBar(UINT nResourceID = 0,
        DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE, UINT nID = ATL_IDW_TOOLBAR)

Message Map and Handlers

    BEGIN_MSG_MAP(CFrameWindowImpl<>)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize)
        NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed)
        CHAIN_MSG_MAP(CFrameWindowImplBase)
    END_MSG_MAP()

    LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
    LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)

Data Members

    (none)

COwnerDraw<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class, and is a window implementation (has a WindowProc)

Methods

public:
    BOOL IsMsgHandled() const
    void SetMsgHandled(BOOL bHandled)

Message Map and Handlers

    BEGIN_MSG_MAP(COwnerDraw< T >)
        MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
        MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
        MESSAGE_HANDLER(WM_COMPAREITEM, OnCompareItem)
        MESSAGE_HANDLER(WM_DELETEITEM, OnDeleteItem)
    ALT_MSG_MAP(1)
        MESSAGE_HANDLER(OCM_DRAWITEM, OnDrawItem)
        MESSAGE_HANDLER(OCM_MEASUREITEM, OnMeasureItem)
        MESSAGE_HANDLER(OCM_COMPAREITEM, OnCompareItem)
        MESSAGE_HANDLER(OCM_DELETEITEM, OnDeleteItem)
    END_MSG_MAP()

    LRESULT OnDrawItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnCompareItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnDeleteItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
Overrideables
    void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/)
    void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
    int CompareItem(LPCOMPAREITEMSTRUCT /*lpCompareItemStruct*/)
    void DeleteItem(LPDELETEITEMSTRUCT /*lpDeleteItemStruct*/)

Data Members

public:
    BOOL m_bHandledOD;

CDialogResize<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class

Usage Notes

This class provides support for resizing dialog controls (works for any window that has child controls). Put CDialogResize in the list of base classes for a dialog (or even plain window), then implement DLGRESIZE map by specifying controls and groups of control and using DLSZ_* values to specify how are they supposed to be resized:

    BEGIN_DLGRESIZE_MAP(CDialogResize<>)
    END_DLGRESIZE_MAP()
    DLGRESIZE_CONTROL(id, flags)
    BEGIN_DLGRESIZE_GROUP()
    END_DLGRESIZE_GROUP()

The flags are:

    DLSZ_SIZE_X     = 0x00000001,
    DLSZ_SIZE_Y     = 0x00000002,
    DLSZ_MOVE_X     = 0x00000004,
    DLSZ_MOVE_Y     = 0x00000008,
    DLSZ_REPAINT    = 0x00000010

Methods

public:
    CDialogResize()
    void DlgResize_Init(bool bAddGripper = true, bool bUseMinTrackSize = true,
        DWORD dwForceStyle = WS_THICKFRAME | WS_CLIPCHILDREN)
    void DlgResize_UpdateLayout(int cxWidth, int cyHeight)

Message Map and Handlers

    BEGIN_MSG_MAP(CDialogResize)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)
    END_MSG_MAP()

    LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnGetMinMaxInfo(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)

Data Members

public:
    CSimpleArray<_AtlDlgResizeData> m_arrData;
    SIZE m_sizeDialog;
    POINT m_ptMinTrackSize;
    bool m_bGripper;

MDI Windows

CMDIWindow

Basics

Characteristic Value/description
Inherits from CWindow
Usage mode Client (however normally you'd use a CMDIFrameWindowImpl or a CMDIChildWindowImpl instead).

Methods

public:
    CMDIWindow(HWND hWnd = NULL)
    CMDIWindow& operator=(HWND hWnd)
Operations
    HWND MDIGetActive(BOOL* lpbMaximized = NULL)
    void MDIActivate(HWND hWndChildToActivate)
    void MDINext(HWND hWndChild, BOOL bPrevious = FALSE)
    void MDIMaximize(HWND hWndChildToMaximize)
    void MDIRestore(HWND hWndChildToRestore)
    void MDIDestroy(HWND hWndChildToDestroy)
    BOOL MDICascade(UINT uFlags = 0)
    BOOL MDITile(UINT uFlags = MDITILE_HORIZONTAL)
    void MDIIconArrange()
    HMENU MDISetMenu(HMENU hMenuFrame, HMENU hMenuWindow)
    HMENU MDIRefreshMenu()
Additional operations
    static HMENU GetStandardWindowMenu(HMENU hMenu)
    void SetMDIFrameMenu()
    HWND GetMDIFrame() const

Methods Inherited from CWindow

public:
    CWindow(HWND hWnd = NULL)
    CWindow& operator=(HWND hWnd)
    static LPCTSTR GetWndClassName()
    void Attach(HWND hWndNew)
    HWND Detach()
    HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, RECT& rcPos,
        LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0,
        UINT nID = 0, LPVOID lpCreateParam = NULL)
    HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, LPRECT lpRect = NULL,
        LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0,
        HMENU hMenu = NULL, LPVOID lpCreateParam = NULL)
    BOOL DestroyWindow()
Attributes
    operator HWND() const { return m_hWnd; }
    DWORD GetStyle() const
    DWORD GetExStyle() const
    LONG GetWindowLong(int nIndex) const
    LONG SetWindowLong(int nIndex, LONG dwNewLong)
    WORD GetWindowWord(int nIndex) const
    WORD SetWindowWord(int nIndex, WORD wNewWord)
Message Functions
    LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
    BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
    BOOL SendNotifyMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
    static LRESULT SendMessage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Window Text Functions
    BOOL SetWindowText(LPCTSTR lpszString)
    int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount) const
    int GetWindowTextLength() const
Font Functions
    void SetFont(HFONT hFont, BOOL bRedraw = TRUE)
    HFONT GetFont() const
Menu Functions (non-child windows only)
    HMENU GetMenu() const
    BOOL SetMenu(HMENU hMenu)
    BOOL DrawMenuBar()
    HMENU GetSystemMenu(BOOL bRevert) const
    BOOL HiliteMenuItem(HMENU hMenu, UINT uItemHilite, UINT uHilite)
Window Size and Position Functions
    BOOL IsIconic() const
    BOOL IsZoomed() const
    BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE)
    BOOL MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE)
    BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
    BOOL SetWindowPos(HWND hWndInsertAfter, LPCRECT lpRect, UINT nFlags)
    UINT ArrangeIconicWindows()
    BOOL BringWindowToTop()
    BOOL GetWindowRect(LPRECT lpRect) const
    BOOL GetClientRect(LPRECT lpRect) const
    BOOL GetWindowPlacement(WINDOWPLACEMENT FAR* lpwndpl) const
    BOOL SetWindowPlacement(const WINDOWPLACEMENT FAR* lpwndpl)
Coordinate Mapping Functions
    BOOL ClientToScreen(LPPOINT lpPoint) const
    BOOL ClientToScreen(LPRECT lpRect) const
    BOOL ScreenToClient(LPPOINT lpPoint) const
    BOOL ScreenToClient(LPRECT lpRect) const
    int MapWindowPoints(HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
    int MapWindowPoints(HWND hWndTo, LPRECT lpRect) const
Update and Painting Functions
    HDC BeginPaint(LPPAINTSTRUCT lpPaint)
    void EndPaint(LPPAINTSTRUCT lpPaint)
    HDC GetDC()
    HDC GetWindowDC()
    int ReleaseDC(HDC hDC)
    void Print(HDC hDC, DWORD dwFlags) const
    void PrintClient(HDC hDC, DWORD dwFlags) const
    BOOL UpdateWindow()
    void SetRedraw(BOOL bRedraw = TRUE)
    BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE)
    int GetUpdateRgn(HRGN hRgn, BOOL bErase = FALSE)
    BOOL Invalidate(BOOL bErase = TRUE)
    BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE)
    BOOL ValidateRect(LPCRECT lpRect)
    void InvalidateRgn(HRGN hRgn, BOOL bErase = TRUE)
    BOOL ValidateRgn(HRGN hRgn)
    BOOL ShowWindow(int nCmdShow)
    BOOL IsWindowVisible() const
    BOOL ShowOwnedPopups(BOOL bShow = TRUE)
    HDC GetDCEx(HRGN hRgnClip, DWORD flags)
    BOOL LockWindowUpdate(BOOL bLock = TRUE)
    BOOL RedrawWindow(LPCRECT lpRectUpdate = NULL, HRGN hRgnUpdate = NULL,
        UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE)
Timer Functions
    UINT SetTimer(UINT nIDEvent, UINT nElapse)
    BOOL KillTimer(UINT nIDEvent)
Window State Functions
    BOOL IsWindowEnabled() const
    BOOL EnableWindow(BOOL bEnable = TRUE)
    HWND SetActiveWindow()
    HWND SetCapture()
    HWND SetFocus()
Dialog-Box Item Functions
    BOOL CheckDlgButton(int nIDButton, UINT nCheck)
    BOOL CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
    int DlgDirList(LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType)
    int DlgDirListComboBox(LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath,
        UINT nFileType)
    BOOL DlgDirSelect(LPTSTR lpString, int nCount, int nIDListBox)
    BOOL DlgDirSelectComboBox(LPTSTR lpString, int nCount, int nIDComboBox)
    UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const
    UINT GetDlgItemText(int nID, LPTSTR lpStr, int nMaxCount) const
    BOOL GetDlgItemText(int nID, BSTR& bstrText) const
    HWND GetNextDlgGroupItem(HWND hWndCtl, BOOL bPrevious = FALSE) const
    HWND GetNextDlgTabItem(HWND hWndCtl, BOOL bPrevious = FALSE) const
    UINT IsDlgButtonChecked(int nIDButton) const
    LRESULT SendDlgItemMessage(int nID, UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
    BOOL SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE)
    BOOL SetDlgItemText(int nID, LPCTSTR lpszString)
    HRESULT GetDlgControl(int nID, REFIID iid, void** ppUnk)
Scrolling Functions
    int GetScrollPos(int nBar) const
    BOOL GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
    BOOL ScrollWindow(int xAmount, int yAmount, LPCRECT lpRect = NULL,
        LPCRECT lpClipRect = NULL)
    int ScrollWindowEx(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip,
        HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT uFlags)
    int ScrollWindowEx(int dx, int dy, UINT uFlags, LPCRECT lpRectScroll = NULL,
        LPCRECT lpRectClip = NULL, HRGN hRgnUpdate = NULL, LPRECT lpRectUpdate = NULL)
    int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE)
    BOOL SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
    BOOL ShowScrollBar(UINT nBar, BOOL bShow = TRUE)
    BOOL EnableScrollBar(UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE_BOTH)
Window Access Functions
    HWND ChildWindowFromPoint(POINT point) const
    HWND ChildWindowFromPointEx(POINT point, UINT uFlags) const
    HWND GetTopWindow() const
    HWND GetWindow(UINT nCmd) const
    HWND GetLastActivePopup() const
    BOOL IsChild(HWND hWnd) const
    HWND GetParent() const
    HWND SetParent(HWND hWndNewParent)
Window Tree Access
    int GetDlgCtrlID() const
    int SetDlgCtrlID(int nID)
    HWND GetDlgItem(int nID) const
Alert Functions
    BOOL FlashWindow(BOOL bInvert)
    int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = _T(""), UINT nType = MB_OK)
Clipboard Functions
    BOOL ChangeClipboardChain(HWND hWndNewNext)
    HWND SetClipboardViewer()
    BOOL OpenClipboard()
Caret Functions
    BOOL CreateCaret(HBITMAP hBitmap)
    BOOL CreateSolidCaret(int nWidth, int nHeight)
    BOOL CreateGrayCaret(int nWidth, int nHeight)
    BOOL HideCaret()
    BOOL ShowCaret()
Drag-Drop Functions
    void DragAcceptFiles(BOOL bAccept = TRUE)
Icon Functions
    HICON SetIcon(HICON hIcon, BOOL bBigIcon = TRUE)
    HICON GetIcon(BOOL bBigIcon = TRUE) const
Help Functions
    BOOL WinHelp(LPCTSTR lpszHelp, UINT nCmd = HELP_CONTEXT, DWORD dwData = 0)
    BOOL SetWindowContextHelpId(DWORD dwContextHelpId)
    DWORD GetWindowContextHelpId() const
Hot Key Functions
    int SetHotKey(WORD wVirtualKeyCode, WORD wModifiers)
    DWORD GetHotKey() const
Misc. Operations
    BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo)
    BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
    BOOL IsDialogMessage(LPMSG lpMsg)
    void NextDlgCtrl() const
    void PrevDlgCtrl() const
    void GotoDlgCtrl(HWND hWndCtrl) const
    BOOL ResizeClient(int nWidth, int nHeight, BOOL bRedraw = TRUE)
    int GetWindowRgn(HRGN hRgn)
    int SetWindowRgn(HRGN hRgn, BOOL bRedraw = FALSE)
    HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy,
        UINT uFlags)
    DWORD GetWindowThreadID()
    DWORD GetWindowProcessID()
    BOOL IsWindow()
    BOOL IsWindowUnicode()
    BOOL IsParentDialog()
    BOOL ShowWindowAsync(int nCmdShow)
    HWND GetDescendantWindow(int nID) const
    void SendMessageToDescendants(UINT message, WPARAM wParam = 0, LPARAM lParam = 0,
        BOOL bDeep = TRUE)
    BOOL CenterWindow(HWND hWndCenter = NULL)
    BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0)
    BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0)
    BOOL GetWindowText(BSTR* pbstrText)
    BOOL GetWindowText(BSTR& bstrText)
    HWND GetTopLevelParent() const
    HWND GetTopLevelWindow() const

Data Members

public:
    HWND m_hWndMDIClient;
    HMENU m_hMenu;

Data Members Inherited from CWindow

public:
    static RECT rcDefault;
    HWND m_hWnd;

CMDIFrameWindowImpl<>

Basics

Characteristic Value/description
Inherits from CMDIWindow, CFrameWindowImplBase
Usage mode Window implementation (has a WndProc)

Methods

public:
    HWND Create(HWND hWndParent = NULL, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            HMENU hMenu = NULL, LPVOID lpCreateParam = NULL)
    HWND CreateEx(HWND hWndParent = NULL, _U_RECT rect = NULL, DWORD dwStyle = 0,
        DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL)
    BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE,
        UINT nID = ATL_IDW_TOOLBAR)
    virtual WNDPROC GetWindowProc()
    static LRESULT CALLBACK MDIFrameWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam,
        LPARAM lParam)
    LRESULT DefWindowProc()
    LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
    BOOL PreTranslateMessage(MSG* pMsg)
    HWND CreateMDIClient(HMENU hWindowMenu = NULL, UINT nID = ATL_IDW_CLIENT,
        UINT nFirstChildID = ATL_IDM_FIRST_MDICHILD)

Message Map and Handlers

    BEGIN_MSG_MAP(CMDIFrameWindowImpl<>)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
        MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu)
        NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize)
        NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed)
        CHAIN_MSG_MAP(CFrameWindowImplBase)
    END_MSG_MAP()

    LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnMDISetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
        BOOL& /*bHandled*/)
    LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
    LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)

Data Members

    (none)

CMDIChildWindowImpl<>

Basics

Characteristic Value/description
Inherits from CMDIWindow, CFrameWindowImplBase
Usage mode Window implementation (has a WndProc)

Methods

public:
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            UINT nMenuID = 0, LPVOID lpCreateParam = NULL)
    HWND CreateEx(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR lpcstrWindowName = NULL,
        DWORD dwStyle = 0, DWORD dwExStyle = 0, LPVOID lpCreateParam = NULL)
    BOOL CreateSimpleToolBar(UINT nResourceID = 0, DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE,
        UINT nID = ATL_IDW_TOOLBAR)
    BOOL UpdateClientEdge(LPRECT lpRect = NULL)

Message Map and Handlers

    BEGIN_MSG_MAP(CMDIChildWindowImpl)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, OnWindowPosChanging)
        MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
        MESSAGE_HANDLER(WM_MDIACTIVATE, OnMDIActivate)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
        NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnReBarAutoSize)
        NOTIFY_CODE_HANDLER(RBN_CHEVRONPUSHED, OnChevronPushed)
        CHAIN_MSG_MAP(CFrameWindowImplBase)
    END_MSG_MAP()

    LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnWindowPosChanging(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam,
        BOOL& bHandled)
    LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnMDIActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnReBarAutoSize(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
    LRESULT OnChevronPushed(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)

Data Members

    (none)

Update UI

CUpdateUIBase

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Base class (normally you use CUpdateUI<>)

Methods

public:
    CUpdateUIBase()
    ~CUpdateUIBase()
    bool UIGetBlockAccelerators() const
    bool UISetBlockAccelerators(bool bBlock)
    BOOL UIAddMenuBar(HWND hWnd)            // menu bar (main menu)
    BOOL UIAddToolBar(HWND hWnd)            // toolbar
    BOOL UIAddStatusBar(HWND hWnd)          // status bar
    BOOL UIAddChildWindowContainer(HWND hWnd)   // child window
    LRESULT OnInitMenuPopup(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    BOOL UIEnable(int nID, BOOL bEnable, BOOL bForceUpdate = FALSE)
    BOOL UISetCheck(int nID, int nCheck, BOOL bForceUpdate = FALSE)
    BOOL UISetRadio(int nID, BOOL bRadio, BOOL bForceUpdate = FALSE)
    BOOL UISetText(int nID, LPCTSTR lpstrText, BOOL bForceUpdate = FALSE)
    BOOL UISetState(int nID, DWORD dwState)
    BOOL UIUpdateMenuBar(BOOL bForceUpdate = FALSE, BOOL bMainMenu = FALSE)
    BOOL UIUpdateToolBar(BOOL bForceUpdate = FALSE)
    BOOL UIUpdateStatusBar(BOOL bForceUpdate = FALSE)
    BOOL UIUpdateChildWindows(BOOL bForceUpdate = FALSE)

Data Members

public:
    CSimpleArray<_AtlUpdateUIElement> m_UIElements; // elements data
    const _AtlUpdateUIMap* m_pUIMap;        // static UI data
    _AtlUpdateUIData* m_pUIData;            // instance UI data
    WORD m_wDirtyType;              // global dirty flag
    bool m_bBlockAccelerators;

Constants

    // UI element type
    UPDUI_MENUPOPUP     = 0x0001,
    UPDUI_MENUBAR       = 0x0002,
    UPDUI_CHILDWINDOW   = 0x0004,
    UPDUI_TOOLBAR       = 0x0008,
    UPDUI_STATUSBAR     = 0x0010,
    // state
    UPDUI_ENABLED       = 0x0000,
    UPDUI_DISABLED      = 0x0100,
    UPDUI_CHECKED       = 0x0200,
    UPDUI_CHECKED2      = 0x0400,
    UPDUI_RADIO     = 0x0800,
    UPDUI_DEFAULT       = 0x1000,
    UPDUI_TEXT      = 0x2000,

CUpdateUI<>

Basics

Characteristic Value/description
Inherits from CUpdateUIBase
Usage mode Multiple-inheritance base class for CMainFrame implementation

Methods

public:
    CUpdateUI()

Data Members

    (none)

Standard Controls

CStatic

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CStaticT(HWND hWnd = NULL)
    CStatic& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    HICON GetIcon() const
    HICON SetIcon(HICON hIcon)
    HENHMETAFILE GetEnhMetaFile() const
    HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile)
    CBitmapHandle GetBitmap() const
    CBitmapHandle SetBitmap(HBITMAP hBitmap)
    HCURSOR GetCursor() const
    HCURSOR SetCursor(HCURSOR hCursor)

Data Members

    (none)

CButton

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CButtonT(HWND hWnd = NULL)
    CButton& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0,
        DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    UINT GetState() const
    void SetState(BOOL bHighlight)
    int GetCheck() const
    void SetCheck(int nCheck)
    UINT GetButtonStyle() const
    void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE)
    HICON GetIcon() const
    HICON SetIcon(HICON hIcon)
    CBitmapHandle GetBitmap() const
    CBitmapHandle SetBitmap(HBITMAP hBitmap)
Operations
    void Click()

Data Members

    (none)

CListBox

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CListBox(HWND hWnd = NULL)
    CListBox& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()

    // for entire listbox
    int GetCount() const
    int SetCount(int cItems)
    int GetHorizontalExtent() const
    void SetHorizontalExtent(int cxExtent)
    int GetTopIndex() const
    int SetTopIndex(int nIndex)
    LCID GetLocale() const
    LCID SetLocale(LCID nNewLocale)

    // for single-selection listboxes
    int GetCurSel() const
    int SetCurSel(int nSelect)

    // for multiple-selection listboxes
    int GetSel(int nIndex) const           // also works for single-selection
    int SetSel(int nIndex, BOOL bSelect = TRUE)
    int GetSelCount() const
    int GetSelItems(int nMaxItems, LPINT rgIndex) const
    int GetAnchorIndex() const
    void SetAnchorIndex(int nIndex)
    int GetCaretIndex() const
    int SetCaretIndex(int nIndex, BOOL bScroll = TRUE)

    // for listbox items
    DWORD_PTR GetItemData(int nIndex) const
    int SetItemData(int nIndex, DWORD_PTR dwItemData)
    void* GetItemDataPtr(int nIndex) const
    int SetItemDataPtr(int nIndex, void* pData)
    int GetItemRect(int nIndex, LPRECT lpRect) const
    int GetText(int nIndex, LPTSTR lpszBuffer) const
    BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const
    int GetText(int nIndex, CString& strText) const
    int GetTextLen(int nIndex) const
    int GetItemHeight(int nIndex) const
    int SetItemHeight(int nIndex, UINT cyItemHeight)

    // Settable only attributes
    void SetColumnWidth(int cxWidth)
    BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
    BOOL SetTabStops()
    BOOL SetTabStops(const int& cxEachStop)    // takes an 'int'
Operations
    int InitStorage(int nItems, UINT nBytes)
    void ResetContent()
    UINT ItemFromPoint(POINT pt, BOOL& bOutside) const

    // manipulating listbox items
    int AddString(LPCTSTR lpszItem)
    int DeleteString(UINT nIndex)
    int InsertString(int nIndex, LPCTSTR lpszItem)
    int Dir(UINT attr, LPCTSTR lpszWildCard)
    int AddFile(LPCTSTR lpstrFileName)

    // selection helpers
    int FindString(int nStartAfter, LPCTSTR lpszItem) const
    int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
    int SelectString(int nStartAfter, LPCTSTR lpszItem)
    int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem)

Data Members

    (none)

CComboBox

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CComboBox(HWND hWnd = NULL)
    CComboBox& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0,
        DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()

    // for entire combo box
    int GetCount() const
    int GetCurSel() const
    int SetCurSel(int nSelect)
    LCID GetLocale() const
    LCID SetLocale(LCID nNewLocale)
    int GetTopIndex() const
    int SetTopIndex(int nIndex)
    UINT GetHorizontalExtent() const
    void SetHorizontalExtent(UINT nExtent)
    int GetDroppedWidth() const
    int SetDroppedWidth(UINT nWidth)

    // for edit control
    DWORD GetEditSel() const
    BOOL SetEditSel(int nStartChar, int nEndChar)

    // for combobox item
    DWORD_PTR GetItemData(int nIndex) const
    int SetItemData(int nIndex, DWORD_PTR dwItemData)
    void* GetItemDataPtr(int nIndex) const
    int SetItemDataPtr(int nIndex, void* pData)
    int GetLBText(int nIndex, LPTSTR lpszText) const
    BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const
    int GetLBText(int nIndex, CString& strText) const
    int GetLBTextLen(int nIndex) const
    int GetItemHeight(int nIndex) const
    int SetItemHeight(int nIndex, UINT cyItemHeight)
    BOOL GetExtendedUI() const
    int SetExtendedUI(BOOL bExtended = TRUE)
    void GetDroppedControlRect(LPRECT lprect) const
    BOOL GetDroppedState() const
Operations
    int InitStorage(int nItems, UINT nBytes)
    void ResetContent()

    // for edit control
    BOOL LimitText(int nMaxChars)

    // for drop-down combo boxes
    void ShowDropDown(BOOL bShowIt = TRUE)

    // manipulating listbox items
    int AddString(LPCTSTR lpszString)
    int DeleteString(UINT nIndex)
    int InsertString(int nIndex, LPCTSTR lpszString)
    int Dir(UINT attr, LPCTSTR lpszWildCard)

    // selection helpers
    int FindString(int nStartAfter, LPCTSTR lpszString) const
    int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
    int SelectString(int nStartAfter, LPCTSTR lpszString)

    // Clipboard operations
    void Clear()
    void Copy()
    void Cut()
    void Paste()

Data Members

    (none)

CEdit

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CEdit(HWND hWnd = NULL)
    CEdit& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    BOOL CanUndo() const
    int GetLineCount() const
    BOOL GetModify() const
    void SetModify(BOOL bModified = TRUE)
    void GetRect(LPRECT lpRect) const
    DWORD GetSel() const
    void GetSel(int& nStartChar, int& nEndChar) const
    HLOCAL GetHandle() const
    void SetHandle(HLOCAL hBuffer)
    DWORD GetMargins() const
    void SetMargins(UINT nLeft, UINT nRight)
    UINT GetLimitText() const
    void SetLimitText(UINT nMax)
    POINT PosFromChar(UINT nChar) const
    int CharFromPos(POINT pt, int* pLine = NULL) const

    // NOTE: first word in lpszBuffer must contain the size of the buffer!
    int GetLine(int nIndex, LPTSTR lpszBuffer) const
    int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
    TCHAR GetPasswordChar() const
    void SetPasswordChar(TCHAR ch)
    EDITWORDBREAKPROC GetWordBreakProc() const
    void SetWordBreakProc(EDITWORDBREAKPROC ewbprc)
    int GetFirstVisibleLine() const
    int GetThumb() const
    BOOL SetReadOnly(BOOL bReadOnly = TRUE)
    UINT GetImeStatus(UINT uStatus) const
    UINT SetImeStatus(UINT uStatus, UINT uData)
Operations
    void EmptyUndoBuffer()
    BOOL FmtLines(BOOL bAddEOL)
    void LimitText(int nChars = 0)
    int LineFromChar(int nIndex = -1) const
    int LineIndex(int nLine = -1) const
    int LineLength(int nLine = -1) const
    void LineScroll(int nLines, int nChars = 0)
    void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
    void SetRect(LPCRECT lpRect)
    void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE)
    void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE)
    void SetSelAll(BOOL bNoScroll = FALSE)
    void SetSelNone(BOOL bNoScroll = FALSE)
    BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
    BOOL SetTabStops()
    BOOL SetTabStops(const int& cxEachStop)    // takes an 'int'
    void ScrollCaret()
    int Scroll(int nScrollAction)
    void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE,
        BOOL bCanUndo = FALSE)
    void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)

    // Clipboard operations
    BOOL Undo()
    void Clear()
    void Copy()
    void Cut()
    void Paste()

Data Members

    (none)

CEditCommands

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client

Usage Notes

The CEditCommands class provides message handlers for standard editing commands. Chain to the CEditCommands message map. Your class must also derive from CEdit. For example:

class CMyEdit : public CWindowImpl<CMyEdit, CEdit>,
                public CEditCommands<CMyEdit>
{
public:
     BEGIN_MSG_MAP(CMyEdit)
             // your handlers...
             CHAIN_MSG_MAP_ALT(CEditCommands<CMyEdit>, 1)
     END_MSG_MAP()
     // other stuff...
};

Methods

State (update UI) helpers
    BOOL CanCut() const
    BOOL CanCopy() const
    BOOL CanClear() const
    BOOL CanSelectAll() const
    BOOL CanFind() const
    BOOL CanRepeat() const
    BOOL CanReplace() const
    BOOL CanClearAll() const
Implementation
    BOOL HasSelection() const
    BOOL HasText() const

Message Map and Handlers

    BEGIN_MSG_MAP(CEditCommands< T >)
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
        COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll)
        COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
        COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut)
        COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste)
        COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll)
        COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo)
    END_MSG_MAP()

    LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)
    LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
        BOOL& /*bHandled*/)

Data Members

    (none)

CScrollBar

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CScrollBar(HWND hWnd = NULL)
    CScrollBar& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    int GetScrollPos() const
    int SetScrollPos(int nPos, BOOL bRedraw = TRUE)
    void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const
    void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
    BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const
    int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
    int GetScrollLimit() const
Operations
    void ShowScrollBar(BOOL bShow = TRUE)
    BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH)

Data Members

    (none)

Common Controls

CImageList

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client

Methods

public:
    CImageList(HIMAGELIST hImageList = NULL)
Operators, etc.
    CImageList& operator=(HIMAGELIST hImageList)
    operator HIMAGELIST() const { return m_hImageList; }
    void Attach(HIMAGELIST hImageList)
    HIMAGELIST Detach()
    bool IsNull() const { return (m_hImageList == NULL); }
Attributes
    int GetImageCount() const
    COLORREF GetBkColor() const
    COLORREF SetBkColor(COLORREF cr)
    BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const
    HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const
    BOOL GetIconSize(int& cx, int& cy) const
    BOOL GetIconSize(SIZE& size) const
    BOOL SetIconSize(int cx, int cy)
    BOOL SetIconSize(SIZE size)
    BOOL SetImageCount(UINT uNewCount)
    BOOL SetOverlayImage(int nImage, int nOverlay)
Operations
    BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow)
    BOOL Create(_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask)
    BOOL CreateFromImage(_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType,
        UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE)
    BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2,
        int dx, int dy)
    BOOL Destroy()
    int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL)
    int Add(HBITMAP hBitmap, COLORREF crMask)
    BOOL Remove(int nImage)
    BOOL RemoveAll()
    BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask)
    int AddIcon(HICON hIcon)
    int ReplaceIcon(int nImage, HICON hIcon)
    HICON ExtractIcon(int nImage)
    BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle)
    BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle)
    BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk,
        COLORREF rgbFg, UINT fStyle)
    BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg,
        UINT fStyle)
    static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp)
    BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE)
    HIMAGELIST Read(LPSTREAM lpStream)
    BOOL Write(LPSTREAM lpStream)
Drag operations
    BOOL BeginDrag(int nImage, POINT ptHotSpot)
    BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot)
    static void EndDrag()
    static BOOL DragMove(POINT pt)
    static BOOL DragMove(int x, int y)
    BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot)
    BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot)
    static BOOL DragShowNolock(BOOL bShow = TRUE)
    static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot)
    static BOOL DragEnter(HWND hWnd, POINT point)
    static BOOL DragEnter(HWND hWnd, int x, int y)
    static BOOL DragLeave(HWND hWnd)
    CImageList Duplicate()
    static CImageList Duplicate(HIMAGELIST hImageList)

Data Members

public:
    HIMAGELIST m_hImageList;

CListViewCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a ListView control, do this:

class CMyListView : CWindowImpl<CMyListView, CListViewCtrl>
{
public:
     BEGIN_MSG_MAP(CMyListView)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CListViewCtrl(HWND hWnd = NULL)
    CListViewCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    COLORREF GetBkColor() const
    BOOL SetBkColor(COLORREF cr)
    CImageList GetImageList(int nImageListType) const
    CImageList SetImageList(HIMAGELIST hImageList, int nImageList)
    int GetItemCount() const
    void SetItemCount(int nItems)
    BOOL GetItem(LPLVITEM pItem) const
    BOOL SetItem(const LVITEM* pItem)
    BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
        int nImage, UINT nState, UINT nStateMask, LPARAM lParam)
    UINT GetItemState(int nItem, UINT nMask) const
    BOOL SetItemState(int nItem, UINT nState, UINT nStateMask)
    BOOL SetItemState(int nItem, LPLVITEM pItem)
    BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const
    int GetItemText(int nItem, int nSubItem, CString& strText) const
    int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const
    BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
    DWORD_PTR GetItemData(int nItem) const
    BOOL SetItemData(int nItem, DWORD_PTR dwData)
    UINT GetCallbackMask() const
    BOOL SetCallbackMask(UINT nMask)
    BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const
    BOOL SetItemPosition(int nItem, POINT pt)
    BOOL SetItemPosition(int nItem, int x, int y)
    int GetStringWidth(LPCTSTR lpsz) const
    CEdit GetEditControl() const
    BOOL GetColumn(int nCol, LV_COLUMN* pColumn) const
    BOOL SetColumn(int nCol, const LV_COLUMN* pColumn)
    int GetColumnWidth(int nCol) const
    BOOL SetColumnWidth(int nCol, int cx)
    BOOL GetViewRect(LPRECT lpRect) const
    COLORREF GetTextColor() const
    BOOL SetTextColor(COLORREF cr)
    COLORREF GetTextBkColor() const
    BOOL SetTextBkColor(COLORREF cr)
    int GetTopIndex() const
    int GetCountPerPage() const
    BOOL GetOrigin(LPPOINT lpPoint) const
    UINT GetSelectedCount() const
    BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const
    HCURSOR GetHotCursor() const
    HCURSOR SetHotCursor(HCURSOR hHotCursor)
    int GetHotItem() const
    int SetHotItem(int nIndex)
    BOOL GetColumnOrderArray(int nCount, int* lpnArray) const
    BOOL SetColumnOrderArray(int nCount, int* lpnArray)
    CHeaderCtrl GetHeader() const
    BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const
    DWORD SetIconSpacing(int cx, int cy)
    int GetISearchString(LPTSTR lpstr) const
    void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const

    // single-selection only
    int GetSelectedIndex() const
    BOOL GetSelectedItem(LPLVITEM pItem) const

    // extended list view styles
    DWORD GetExtendedListViewStyle() const

    // dwExMask = 0 means all styles
    DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0)

    // checkboxes only
    BOOL GetCheckState(int nIndex) const
    BOOL SetCheckState(int nItem, BOOL bCheck)

    // view type
    DWORD GetViewType() const
    DWORD SetViewType(DWORD dwType)
    BOOL GetBkImage(LPLVBKIMAGE plvbki) const
    BOOL SetBkImage(LPLVBKIMAGE plvbki)
    int GetSelectionMark() const
    int SetSelectionMark(int nIndex)
    BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const
    BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect)
    DWORD GetHoverTime() const
    DWORD SetHoverTime(DWORD dwHoverTime)
    BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const
    void SetItemCountEx(int nItems, DWORD dwFlags)
    CToolTipCtrl GetToolTips() const
    CToolTipCtrl SetToolTips(HWND hWndTT)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    int InsertColumn(int nCol, const LV_COLUMN* pColumn)
    int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth,
        int nSubItem)
    BOOL DeleteColumn(int nCol)
    int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask,
        int nImage, LPARAM lParam)
    int InsertItem(const LVITEM* pItem)
    int InsertItem(int nItem, LPCTSTR lpszItem)
    int InsertItem(int nItem, LPCTSTR lpszItem, int nImage)
    int GetNextItem(int nItem, int nFlags) const
    BOOL DeleteItem(int nItem)
    BOOL DeleteAllItems()
    int FindItem(LV_FINDINFO* pFindInfo, int nStart) const
    int HitTest(LV_HITTESTINFO* pHitTestInfo) const
    int HitTest(POINT pt, UINT* pFlags) const
    BOOL EnsureVisible(int nItem, BOOL bPartialOK)
    BOOL Scroll(SIZE size)
    BOOL RedrawItems(int nFirst, int nLast)
    BOOL Arrange(UINT nCode)
    CEdit EditLabel(int nItem)
    BOOL Update(int nItem)
    BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
    CImageList RemoveImageList(int nImageList)
    CImageList CreateDragImage(int nItem, LPPOINT lpPoint)
    DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1)
    int SubItemHitTest(LPLVHITTESTINFO lpInfo)
    int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1,
            int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
            int nFmt = LVCFMT_LEFT)
    int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -1)
    BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)

    // single-selection only
    BOOL SelectItem(int nIndex)

Data Members

    (none)

CTreeViewCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a TreeView control, do this:

class CMyTreeView : CWindowImpl<CMyTreeView, CTreeViewCtrl>
{
public:
     BEGIN_MSG_MAP(CMyTreeView)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CTreeViewCtrl(HWND hWnd = NULL)
    CTreeViewCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    UINT GetCount() const
    UINT GetIndent() const
    void SetIndent(UINT nIndent)
    CImageList GetImageList(UINT nImageList) const
    CImageList SetImageList(HIMAGELIST hImageList, int nImageListType)
    BOOL GetItem(LPTVITEM pItem) const
    BOOL SetItem(LPTVITEM pItem)
    BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage,
        int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam)
    BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const
    BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const
    BOOL GetItemText(HTREEITEM hItem, CString& strText) const
    BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem)
    BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const
    BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage)
    UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const
    BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask)
    DWORD_PTR GetItemData(HTREEITEM hItem) const
    BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData)
    CEdit GetEditControl() const
    UINT GetVisibleCount() const
    BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const
    BOOL ItemHasChildren(HTREEITEM hItem) const
    CToolTipCtrl GetToolTips() const
    CToolTipCtrl SetToolTips(HWND hWndTT)
    int GetISearchString(LPTSTR lpstr) const

    // checkboxes only
    BOOL GetCheckState(HTREEITEM hItem) const
    BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck)

    COLORREF GetBkColor() const
    COLORREF SetBkColor(COLORREF clr)
    COLORREF GetInsertMarkColor() const
    COLORREF SetInsertMarkColor(COLORREF clr)
    int GetItemHeight() const
    int SetItemHeight(int cyHeight)
    int GetScrollTime() const
    int SetScrollTime(int nScrollTime)
    COLORREF GetTextColor() const
    COLORREF SetTextColor(COLORREF clr)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
    COLORREF GetLineColor() const
    COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/)
Operations
    HTREEITEM InsertItem(LPTV_INSERTSTRUCT lpInsertStruct)
    HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage,
        int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
    HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
    HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage,
        int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
        HTREEITEM hParent, HTREEITEM hInsertAfter)
    BOOL DeleteItem(HTREEITEM hItem)
    BOOL DeleteAllItems()
    BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND)
    HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const
    HTREEITEM GetChildItem(HTREEITEM hItem) const
    HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const
    HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const
    HTREEITEM GetParentItem(HTREEITEM hItem) const
    HTREEITEM GetFirstVisibleItem() const
    HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const
    HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const
    HTREEITEM GetSelectedItem() const
    HTREEITEM GetDropHilightItem() const
    HTREEITEM GetRootItem() const
    BOOL Select(HTREEITEM hItem, UINT nCode)
    BOOL SelectItem(HTREEITEM hItem)
    BOOL SelectDropTarget(HTREEITEM hItem)
    BOOL SelectSetFirstVisible(HTREEITEM hItem)
    CEdit EditLabel(HTREEITEM hItem)
    BOOL EndEditLabelNow(BOOL bCancel)
    HTREEITEM HitTest(TV_HITTESTINFO* pHitTestInfo)
    HTREEITEM HitTest(POINT pt, UINT* pFlags)
    BOOL SortChildren(HTREEITEM hItem)
    BOOL EnsureVisible(HTREEITEM hItem)
    BOOL SortChildrenCB(LPTV_SORTCB pSort)
    CImageList RemoveImageList(int nImageList)
    CImageList CreateDragImage(HTREEITEM hItem)
    BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter)
    BOOL RemoveInsertMark()

Data Members

    (none)

CTreeItem

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Helper class (for use with CTreeViewCtrl and CTreeViewCtrlEx

Methods

public:
    CTreeItem(HTREEITEM hTreeItem = NULL, CTreeViewCtrlEx* pTreeView = NULL)
    CTreeItem(const CTreeItem& posSrc)
    operator HTREEITEM() { return m_hTreeItem; }
    CTreeItem& operator =(const CTreeItem& itemSrc)
Attributes
    CTreeViewCtrlEx* GetTreeView() const { return m_pTreeView; }
    BOOL operator !() const { return m_hTreeItem == NULL; }
    BOOL IsNull() const { return m_hTreeItem == NULL; }
    BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const;
    BOOL GetText(LPTSTR lpstrText, int nLen) const;
    BOOL GetText(BSTR& bstrText) const;
    BOOL GetText(CString& strText) const;
    BOOL SetText(LPCTSTR lpszItem);
    BOOL GetImage(int& nImage, int& nSelectedImage) const;
    BOOL SetImage(int nImage, int nSelectedImage);
    UINT GetState(UINT nStateMask) const;
    BOOL SetState(UINT nState, UINT nStateMask);
    DWORD_PTR GetData() const;
    BOOL SetData(DWORD_PTR dwData);
    BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState,
        UINT nStateMask, LPARAM lParam);
Operations
    CTreeItem InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, int nImageIndex)
    CTreeItem AddHead(LPCTSTR lpstrItem, int nImageIndex)
    CTreeItem AddTail(LPCTSTR lpstrItem, int nImageIndex)
    CTreeItem GetChild() const;
    CTreeItem GetNext(UINT nCode) const;
    CTreeItem GetNextSibling() const;
    CTreeItem GetPrevSibling() const;
    CTreeItem GetParent() const;
    CTreeItem GetFirstVisible() const;
    CTreeItem GetNextVisible() const;
    CTreeItem GetPrevVisible() const;
    CTreeItem GetSelected() const;
    CTreeItem GetDropHilight() const;
    CTreeItem GetRoot() const;
    BOOL HasChildren() const;
    BOOL Delete();
    BOOL Expand(UINT nCode = TVE_EXPAND);
    BOOL Select(UINT nCode);
    BOOL Select();
    BOOL SelectDropTarget();
    BOOL SelectSetFirstVisible();
    HWND EditLabel();
    HIMAGELIST CreateDragImage();
    BOOL SortChildren();
    BOOL EnsureVisible();
    CTreeItem _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter);
    int GetImageIndex() const;
    BOOL SetInsertMark(BOOL bAfter);

Data Members

public:
    HTREEITEM m_hTreeItem;
    CTreeViewCtrlEx* m_pTreeView;

CTreeViewCtrlEx

Basics

Characteristic Value/description
Inherits from CTreeViewCtrl
Usage mode Client

Usage Notes

To implement a window based on a TreeViewEx control, do this:

class CMyTreeViewEx : CWindowImpl<CMyTreeViewEx, CTreeViewCtrlEx>
{
public:
     BEGIN_MSG_MAP(CMyTreeViewEx)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CTreeViewCtrlEx(HWND hWnd = NULL)
    CTreeViewCtrlEx& operator=(HWND hWnd)
Operations (overides that return CTreeItem)
    CTreeItem InsertItem(LPTV_INSERTSTRUCT lpInsertStruct)
    CTreeItem InsertItem(LPCTSTR lpszItem, int nImage,
    CTreeItem InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
    CTreeItem GetNextItem(HTREEITEM hItem, UINT nCode)
    CTreeItem GetChildItem(HTREEITEM hItem)
    CTreeItem GetNextSiblingItem(HTREEITEM hItem)
    CTreeItem GetPrevSiblingItem(HTREEITEM hItem)
    CTreeItem GetParentItem(HTREEITEM hItem)
    CTreeItem GetFirstVisibleItem()
    CTreeItem GetNextVisibleItem(HTREEITEM hItem)
    CTreeItem GetPrevVisibleItem(HTREEITEM hItem)
    CTreeItem GetSelectedItem()
    CTreeItem GetDropHilightItem()
    CTreeItem GetRootItem()
    CTreeItem HitTest(TV_HITTESTINFO* pHitTestInfo)
    CTreeItem InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage,
        int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
        HTREEITEM hParent, HTREEITEM hInsertAfter)
    CTreeItem HitTest(POINT pt, UINT* pFlags)

Data Members

    (none)

CHeaderCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a Header control, do this:

class CMyHeaderCtrl : CWindowImpl<CMyHeaderCtrl, CHeaderCtrl>
{
public:
     BEGIN_MSG_MAP(CMyHeaderCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CHeaderCtrl(HWND hWnd = NULL)
    CHeaderCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    int GetItemCount() const
    BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const
    BOOL SetItem(int nIndex, LPHDITEM pHeaderItem)
    CImageList GetImageList() const
    CImageList SetImageList(HIMAGELIST hImageList)
    BOOL GetOrderArray(int nSize, int* lpnArray) const
    BOOL SetOrderArray(int nSize, int* lpnArray)
    BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const
    int SetHotDivider(BOOL bPos, DWORD dwInputValue)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
    int GetBitmapMargin() const
    int SetBitmapMargin(int nWidth)
    int SetFilterChangeTimeout(DWORD dwTimeOut)
    int InsertItem(int nIndex, LPHDITEM phdi)
    BOOL DeleteItem(int nIndex)
    BOOL Layout(HD_LAYOUT* pHeaderLayout)
    int HitTest(LPHDHITTESTINFO lpHitTestInfo) const
    int OrderToIndex(int nOrder)
    CImageList CreateDragImage(int nIndex)
    int EditFilter(int nColumn, BOOL bDiscardChanges)
    int ClearFilter(int nColumn)
    int ClearAllFilters()

Data Members

    (none)

CToolBarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a ToolBar control, do this:

class CMyToolBarCtrl : CWindowImpl<CMyToolBarCtrl, CToolBarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyToolBarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CToolBarCtrl(HWND hWnd = NULL)
    CToolBarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    BOOL IsButtonEnabled(int nID) const
    BOOL IsButtonChecked(int nID) const
    BOOL IsButtonPressed(int nID) const
    BOOL IsButtonHidden(int nID) const
    BOOL IsButtonIndeterminate(int nID) const
    int GetState(int nID) const
    BOOL SetState(int nID, UINT nState)
    BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const
    int GetButtonCount() const
    BOOL GetItemRect(int nIndex, LPRECT lpRect) const
    void SetButtonStructSize(int nSize = sizeof(TBBUTTON))
    BOOL SetButtonSize(SIZE size)
    BOOL SetButtonSize(int cx, int cy)
    BOOL SetBitmapSize(SIZE size)
    BOOL SetBitmapSize(int cx, int cy)
    CToolTipCtrl GetToolTips() const
    void SetToolTips(HWND hWndToolTip)
    void SetNotifyWnd(HWND hWnd)
    int GetRows() const
    void SetRows(int nRows, BOOL bLarger, LPRECT lpRect)
    BOOL SetCmdID(int nIndex, UINT nID)
    DWORD GetBitmapFlags() const
    int GetBitmap(int nID) const
    int GetButtonText(int nID, LPTSTR lpstrText) const
    CImageList GetImageList() const
    CImageList SetImageList(HIMAGELIST hImageList)
    CImageList GetDisabledImageList() const
    CImageList SetDisabledImageList(HIMAGELIST hImageList)
    CImageList GetHotImageList() const
    CImageList SetHotImageList(HIMAGELIST hImageList)
    DWORD GetStyle() const
    void SetStyle(DWORD dwStyle)
    DWORD GetButtonSize() const
    void GetButtonSize(SIZE& size) const
    BOOL GetRect(int nID, LPRECT lpRect) const
    int GetTextRows() const
    BOOL SetButtonWidth(int cxMin, int cxMax)
    BOOL SetIndent(int nIndent)
    BOOL SetMaxTextRows(int nMaxTextRows)
    BOOL GetAnchorHighlight() const
    BOOL SetAnchorHighlight(BOOL bEnable = TRUE)
    int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const
    BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi)
    int GetHotItem() const
    int SetHotItem(int nItem)
    BOOL IsButtonHighlighted(int nButtonID) const
    DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags)
    BOOL GetColorScheme(LPCOLORSCHEME lpcs) const
    void SetColorScheme(LPCOLORSCHEME lpcs)
    DWORD GetExtendedStyle() const
    DWORD SetExtendedStyle(DWORD dwStyle)
    void GetInsertMark(LPTBINSERTMARK lptbim) const
    void SetInsertMark(LPTBINSERTMARK lptbim)
    COLORREF GetInsertMarkColor() const
    COLORREF SetInsertMarkColor(COLORREF clr)
    BOOL GetMaxSize(LPSIZE lpSize) const
    void GetPadding(LPSIZE lpSizePadding) const
    void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
    int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const
    int GetStringBSTR(int nString, BSTR& bstrString) const
    int GetString(int nString, CString& str) const
Operations
    BOOL EnableButton(int nID, BOOL bEnable = TRUE)
    BOOL CheckButton(int nID, BOOL bCheck = TRUE)
    BOOL PressButton(int nID, BOOL bPress = TRUE)
    BOOL HideButton(int nID, BOOL bHide = TRUE)
    BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE)
    int AddBitmap(int nNumButtons, UINT nBitmapID)
    int AddBitmap(int nNumButtons, HBITMAP hBitmap)
    BOOL AddButtons(int nNumButtons, LPTBBUTTON lpButtons)
    BOOL InsertButton(int nIndex, LPTBBUTTON lpButton)
    BOOL DeleteButton(int nIndex)
    UINT CommandToIndex(UINT nID) const
    void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName)
    void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName)
    void Customize()
    int AddString(UINT nStringID)
    int AddStrings(LPCTSTR lpszStrings)
    void AutoSize()
    BOOL ChangeBitmap(int nID, int nBitmap)
    int LoadImages(int nBitmapID)
    int LoadStdImages(int nBitmapID)
    BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb)
    int HitTest(LPPOINT lpPoint)
    BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim)
    BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim)
    BOOL MapAccelerator(TCHAR chAccel, int& nID) const
    BOOL MarkButton(int nID, BOOL bHighlight = TRUE)
    BOOL MoveButton(int nOldPos, int nNewPos)
    HRESULT GetObject(REFIID iid, LPVOID* ppvObject)

Data Members

    (none)

CStatusBarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a StatusBar control, do this:

class CMyStatusBarCtrl : CWindowImpl<CMyStatusBarCtrl, CStatusBarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyStatusBarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CStatusBarCtrl(HWND hWnd = NULL)
    CStatusBarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Methods
    static LPCTSTR GetWndClassName()
    int GetParts(int nParts, int* pParts) const
    BOOL SetParts(int nParts, int* pWidths)
    int GetTextLength(int nPane, int* pType = NULL) const
    int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const
    BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const
    int GetText(int nPane, CString& strText, int* pType = NULL) const
    BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0)
    BOOL GetRect(int nPane, LPRECT lpRect) const
    BOOL GetBorders(int* pBorders) const
    BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const
    void SetMinHeight(int nMin)
    BOOL SetSimple(BOOL bSimple = TRUE)
    BOOL IsSimple() const
    COLORREF SetBkColor(COLORREF clrBk)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
    void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const
    void SetTipText(int nPane, LPCTSTR lpstrText)
    HICON GetIcon(int nPane) const
    BOOL SetIcon(int nPane, HICON hIcon)

Data Members

    (none)

CTabCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a Tab control, do this:

class CMyTabCtrl : CWindowImpl<CMyTabCtrl, CTabCtrl>
{
public:
     BEGIN_MSG_MAP(CMyTabCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CTabCtrl(HWND hWnd = NULL)
    CTabCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    CImageList GetImageList() const
    CImageList SetImageList(HIMAGELIST hImageList)
    int GetItemCount() const
    BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const
    BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem)
    BOOL GetItemRect(int nItem, LPRECT lpRect) const
    int GetCurSel() const
    int SetCurSel(int nItem)
    SIZE SetItemSize(SIZE size)
    void SetPadding(SIZE size)
    int GetRowCount() const
    CToolTipCtrl GetTooltips() const
    void SetTooltips(HWND hWndToolTip)
    int GetCurFocus() const
    void SetCurFocus(int nItem)
    BOOL SetItemExtra(int cbExtra)
    int SetMinTabWidth(int nWidth = -1)
    DWORD GetExtendedStyle() const
    DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    BOOL InsertItem(int nItem, LPTCITEM pTabCtrlItem)
    BOOL DeleteItem(int nItem)
    BOOL DeleteAllItems()
    void AdjustRect(BOOL bLarger, LPRECT lpRect)
    void RemoveImage(int nImage)
    int HitTest(TC_HITTESTINFO* pHitTestInfo) const
    void DeselectAll(BOOL bExcludeFocus = TRUE)
    BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE)

Data Members

    (none)

CToolTipCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a ToolTip control, do this:

class CMyToolTipCtrl : CWindowImpl<CMyToolTipCtrl, CToolTipCtrl>
{
public:
     BEGIN_MSG_MAP(CMyToolTipCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CToolTipCtrl(HWND hWnd = NULL)
    CToolTipCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    void GetText(LPTOOLINFO lpToolInfo) const
    void GetText(LPTSTR lpstrText, HWND hWnd, UINT nIDTool = 0) const
    BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const
    BOOL GetToolInfo(HWND hWnd, UINT nIDTool, UINT* puFlags, LPRECT lpRect,
        LPTSTR lpstrText) const
    void SetToolInfo(LPTOOLINFO lpToolInfo)
    void SetToolRect(LPTOOLINFO lpToolInfo)
    void SetToolRect(HWND hWnd, UINT nIDTool, LPCRECT lpRect)
    int GetToolCount() const
    int GetDelayTime(DWORD dwType) const
    void SetDelayTime(DWORD dwType, int nTime)
    void GetMargin(LPRECT lpRect) const
    void SetMargin(LPRECT lpRect)
    int GetMaxTipWidth() const
    int SetMaxTipWidth(int nWidth)
    COLORREF GetTipBkColor() const
    void SetTipBkColor(COLORREF clr)
    COLORREF GetTipTextColor() const
    void SetTipTextColor(COLORREF clr)
    BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const
    SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const
    BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle)
Operations
    void Activate(BOOL bActivate)
    BOOL AddTool(LPTOOLINFO lpToolInfo)
    BOOL AddTool(HWND hWnd, _U_STRINGorID text = LPSTR_TEXTCALLBACK,
        LPCRECT lpRectTool = NULL, UINT nIDTool = 0)
    void DelTool(LPTOOLINFO lpToolInfo)
    void DelTool(HWND hWnd, UINT nIDTool = 0)
    BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const
    BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const
    void RelayEvent(LPMSG lpMsg)
    void UpdateTipText(LPTOOLINFO lpToolInfo)
    void UpdateTipText(_U_STRINGorID text, HWND hWnd, UINT nIDTool = 0)
    BOOL EnumTools(UINT nTool, LPTOOLINFO lpToolInfo) const
    void Pop()
    void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate)
    void TrackPosition(int xPos, int yPos)
    void Update()
    BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/)

Data Members

    (none)

CToolInfo

Basics

Characteristic Value/description
Inherits from TOOLINFO
Usage mode Wrapper class for TOOLINFO

Methods

public:
    CToolInfo(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL,
        LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
    operator LPTOOLINFO() { return this; }
    operator LPARAM() { return (LPARAM)this; }
    void Init(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL,
        LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)

Data Members

    (none)

CTrackBarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a TrackBar control, do this:

class CMyTrackBarCtrl : CWindowImpl<CMyTrackBarCtrl, CTrackBarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyTrackBarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CTrackBarCtrl(HWND hWnd = NULL)
    CTrackBarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    int GetLineSize() const
    int SetLineSize(int nSize)
    int GetPageSize() const
    int SetPageSize(int nSize)
    int GetRangeMin() const
    void SetRangeMin(int nMin, BOOL bRedraw = FALSE)
    int GetRangeMax() const
    void SetRangeMax(int nMax, BOOL bRedraw = FALSE)
    void GetRange(int& nMin, int& nMax) const
    void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE)
    int GetSelStart() const
    void SetSelStart(int nMin)
    int GetSelEnd() const
    void SetSelEnd(int nMax)
    void GetSelection(int& nMin, int& nMax) const
    void SetSelection(int nMin, int nMax)
    void GetChannelRect(LPRECT lprc) const
    void GetThumbRect(LPRECT lprc) const
    int GetPos() const
    void SetPos(int nPos)
    UINT GetNumTics() const
    DWORD* GetTicArray() const
    int GetTic(int nTic) const
    BOOL SetTic(int nTic)
    int GetTicPos(int nTic) const
    void SetTicFreq(int nFreq)
    int GetThumbLength() const
    void SetThumbLength(int nLength)
    void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE)
    CWindow GetBuddy(BOOL bLeft = TRUE) const
    CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE)
    CToolTipCtrl GetToolTips() const
    void SetToolTips(HWND hWndTT)
    int SetTipSide(int nSide)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    void ClearSel(BOOL bRedraw = FALSE)
    void VerifyPos()
    void ClearTics(BOOL bRedraw = FALSE)

Data Members

    (none)

CUpDownCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a UpDown control, do this:

class CMyUpDownCtrl : CWindowImpl<CMyUpDownCtrl, CUpDownCtrl>
{
public:
     BEGIN_MSG_MAP(CMyUpDownCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CUpDownCtrl(HWND hWnd = NULL)
    CUpDownCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    UINT GetAccel(int nAccel, UDACCEL* pAccel) const
    BOOL SetAccel(int nAccel, UDACCEL* pAccel)
    UINT GetBase() const
    int SetBase(int nBase)
    CWindow GetBuddy() const
    CWindow SetBuddy(HWND hWndBuddy)
    int GetPos() const
    int SetPos(int nPos)
    DWORD GetRange() const
    void GetRange(int& nLower, int& nUpper) const
    void SetRange(int nLower, int nUpper)
    void SetRange32(int nLower, int nUpper)
    void GetRange32(int& nLower, int& nUpper) const
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
    int GetPos32(LPBOOL lpbError /*= NULL*/) const
    int SetPos32(int nPos)

Data Members

    (none)

CProgressBarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a ProgressBar control, do this:

class CMyProgressBarCtrl : CWindowImpl<CMyProgressBarCtrl, CProgressBarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyProgressBarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CProgressBarCtrl(HWND hWnd = NULL)
    CProgressBarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    DWORD SetRange(int nLower, int nUpper)
    int SetPos(int nPos)
    int OffsetPos(int nPos)
    int SetStep(int nStep)
    UINT GetPos() const
    void GetRange(PPBRANGE pPBRange) const
    int GetRangeLimit(BOOL bLimit) const
    DWORD SetRange32(int nMin, int nMax)
    COLORREF SetBarColor(COLORREF clr)
    COLORREF SetBkColor(COLORREF clr)
Operations
    int StepIt()

Data Members

    (none)

CHotKeyCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a HotKey control, do this:

class CMyHotKeyCtrl : CWindowImpl<CMyHotKeyCtrl, CHotKeyCtrl>
{
public:
     BEGIN_MSG_MAP(CMyHotKeyCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CHotKeyCtrl(HWND hWnd = NULL)
    CHotKeyCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    DWORD GetHotKey() const
    void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const
    void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers)
    void SetRules(WORD wInvalidComb, WORD wModifiers)

Data Members

    (none)

CAnimateCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a Animate control, do this:

class CMyAnimateCtrl : CWindowImpl<CMyAnimateCtrl, CAnimateCtrl>
{
public:
     BEGIN_MSG_MAP(CMyAnimateCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CAnimateCtrl(HWND hWnd = NULL)
    CAnimateCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
Operations
    BOOL Open(_U_STRINGorID FileName)
    BOOL Play(UINT nFrom, UINT nTo, UINT nRep)
    BOOL Stop()
    BOOL Close()
    BOOL Seek(UINT nTo)

Data Members

    (none)

CRichEditCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a RichEdit control, do this:

class CMyRichEditCtrl : CWindowImpl<CMyRichEditCtrl, CRichEditCtrl>
{
public:
     BEGIN_MSG_MAP(CMyRichEditCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CRichEditCtrl(HWND hWnd = NULL)
    CRichEditCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    static LPCTSTR GetLibraryName()
    int GetLineCount() const
    BOOL GetModify() const
    void SetModify(BOOL bModified = TRUE)
    void GetRect(LPRECT lpRect) const
    DWORD GetOptions() const
    DWORD SetOptions(WORD wOperation, DWORD dwOptions)

    // NOTE: first word in lpszBuffer must contain the size of the buffer!
    int GetLine(int nIndex, LPTSTR lpszBuffer) const
    int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
    BOOL CanUndo() const
    BOOL CanPaste(UINT nFormat = 0) const
    void GetSel(LONG& nStartChar, LONG& nEndChar) const
    void GetSel(CHARRANGE &cr) const
    int SetSel(LONG nStartChar, LONG nEndChar)
    int SetSel(CHARRANGE &cr)
    int SetSelAll()
    int SetSelNone()
    DWORD GetDefaultCharFormat(CHARFORMAT& cf) const
    DWORD GetSelectionCharFormat(CHARFORMAT& cf) const
    DWORD GetEventMask() const
    LONG GetLimitText() const
    DWORD GetParaFormat(PARAFORMAT& pf) const
    // richedit EM_GETSELTEXT is ANSI
    LONG GetSelText(LPSTR lpBuf) const
    BOOL GetSelTextBSTR(BSTR& bstrText) const
    LONG GetSelText(CString& strText) const
    WORD GetSelectionType() const
    COLORREF SetBackgroundColor(COLORREF cr)
    COLORREF SetBackgroundColor()   // sets to system background
    BOOL SetDefaultCharFormat(CHARFORMAT& cf)
    BOOL SetSelectionCharFormat(CHARFORMAT& cf)
    BOOL SetWordCharFormat(CHARFORMAT& cf)
    DWORD SetEventMask(DWORD dwEventMask)
    BOOL SetParaFormat(PARAFORMAT& pf)
    BOOL SetTargetDevice(HDC hDC, int cxLineWidth)
    int GetTextLength() const
    BOOL SetReadOnly(BOOL bReadOnly = TRUE)
    int GetFirstVisibleLine() const
    int GetTextRange(TEXTRANGE* pTextRange) const
    int GetTextRange(LONG nStartChar, LONG nEndChar, LPSTR lpstrText) const
    EDITWORDBREAKPROCEX GetWordBreakProcEx() const
    EDITWORDBREAKPROCEX SetWordBreakProcEx(EDITWORDBREAKPROCEX pfnEditWordBreakProcEx)
    DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const
    BOOL SetDefaultCharFormat(CHARFORMAT2& cf)
    DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const
    BOOL SetSelectionCharFormat(CHARFORMAT2& cf)
    BOOL SetWordCharFormat(CHARFORMAT2& cf)
    DWORD GetParaFormat(PARAFORMAT2& pf) const
    BOOL SetParaFormat(PARAFORMAT2& pf)
    TEXTMODE GetTextMode() const
    BOOL SetTextMode(TEXTMODE enumTextMode)
    UNDONAMEID GetUndoName() const
    UNDONAMEID GetRedoName() const
    BOOL CanRedo() const
    BOOL GetAutoURLDetect() const
    BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE)

    // this method is deprecated, please use SetAutoURLDetect
    BOOL EnableAutoURLDetect(BOOL bEnable = TRUE) { return SetAutoURLDetect(bEnable); }
    UINT SetUndoLimit(UINT uUndoLimit)
    void SetPalette(HPALETTE hPalette)
    int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const
    int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT,
        UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL,
        LPBOOL lpUsedDefChar = NULL) const
    int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const
    int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP) const
    int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText)
    int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodePage = CP_ACP)
    int GetEditStyle() const
    int SetEditStyle(int nStyle, int nMask = -1)
    BOOL SetFontSize(int nFontSizeDelta)
    void GetScrollPos(LPPOINT lpPoint) const
    void SetScrollPos(LPPOINT lpPoint)
    BOOL GetZoom(int& nNum, int& nDen) const
    BOOL SetZoom(int nNum, int nDen)
    BOOL SetZoomOff()
Operations
    void LimitText(LONG nChars = 0)
    int LineFromChar(LONG nIndex) const
    POINT PosFromChar(LONG nChar) const
    int CharFromPos(POINT pt) const
    void EmptyUndoBuffer()
    int LineIndex(int nLine = -1) const
    int LineLength(int nLine = -1) const
    BOOL LineScroll(int nLines, int nChars = 0)
    void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
    void SetRect(LPCRECT lpRect)
    BOOL DisplayBand(LPRECT pDisplayRect)
    LONG FindText(DWORD dwFlags, FINDTEXT& ft) const
    LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const
    LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE)
    void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE)
    void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0)
    void RequestResize()
    LONG StreamIn(UINT uFormat, EDITSTREAM& es)
    LONG StreamOut(UINT uFormat, EDITSTREAM& es)
    DWORD FindWordBreak(int nCode, LONG nStartChar)
Additional operations
    void ScrollCaret()
    int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE)
    int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE)
Clipboard operations
    BOOL Undo()
    void Clear()
    void Copy()
    void Cut()
    void Paste()
OLE support
    IRichEditOle* GetOleInterface() const
    BOOL SetOleCallback(IRichEditOleCallback* pCallback)
    BOOL Redo()
    void StopGroupTyping()
    void ShowScrollBar(int nBarType, BOOL bVisible = TRUE)

Data Members

    (none)

CRichEditCommands

Basics

Characteristic Value/description
Inherits from CEditCommands
Usage mode Helper class for use with CRichEditCtrl

Usage Notes

Chain to the CRichEditCommands message map. Your class must also derive from CRichEditCtrl. Example:

class CMyRichEdit : public CWindowImpl<CMyRichEdit, CRichEditCtrl>,
                    public CRichEditCommands<CMyRichEdit>
{
public:
     BEGIN_MSG_MAP(CMyRichEdit)
             // your handlers...
             CHAIN_MSG_MAP_ALT(CRichEditCommands<CMyRichEdit>, 1)
     END_MSG_MAP()
     // other stuff...
};

Methods

public:
State (update UI) helpers
    BOOL CanCut() const
    BOOL CanCopy() const
    BOOL CanClear() const
Implementation
    BOOL HasSelection() const

Message Map and Handlers

    BEGIN_MSG_MAP(CRichEditCommands)
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_EDIT_CLEAR, CEditCommands< T >::OnEditClear)
        COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, CEditCommands< T >::OnEditClearAll)
        COMMAND_ID_HANDLER(ID_EDIT_COPY, CEditCommands< T >::OnEditCopy)
        COMMAND_ID_HANDLER(ID_EDIT_CUT, CEditCommands< T >::OnEditCut)
        COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPaste)
        COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEditSelectAll)
        COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo)
        COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo)
    END_MSG_MAP()

    LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    // (Others are inherited)

Data Members

    (none)

CDragListBox

Basics

Characteristic Value/description
Inherits from CListBox
Usage mode Client

Usage Notes

To implement a window based on a DragListBox control, do this:

class CMyDragListBox : CWindowImpl<CMyDragListBox, CDragListBox>
{
public:
     BEGIN_MSG_MAP(CMyDragListBox)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CDragListBox(HWND hWnd = NULL)
    CDragListBox& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Operations
    BOOL MakeDragList()
    int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE)
    void DrawInsert(int nItem)
    static UINT GetDragListMessage()

Data Members

    (none)

CDragListNotifyImpl<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Notification implementation for use with CDragListBox

Message Map and Handlers

    BEGIN_MSG_MAP(CDragListNotifyImpl< T >)
        MESSAGE_HANDLER(CDragListBox::GetDragListMessage(), OnDragListNotify)
    END_MSG_MAP()

    LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)

Methods

public:
Overrideables
    BOOL OnBeginDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/)
    void OnCancelDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/)
    int OnDragging(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/)
    void OnDropped(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/)

Data Members

    (none)

CReBarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a ReBar control, do this:

class CMyReBarCtrl : CWindowImpl<CMyReBarCtrl, CReBarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyReBarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CReBarCtrl(HWND hWnd = NULL)
    CReBarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    UINT GetBandCount() const
    BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const
    BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi)
    BOOL GetBarInfo(LPREBARINFO lprbi) const
    BOOL SetBarInfo(LPREBARINFO lprbi)
    UINT GetRowCount() const
    UINT GetRowHeight(int nBand) const
    COLORREF GetTextColor() const
    COLORREF SetTextColor(COLORREF clr)
    COLORREF GetBkColor() const
    COLORREF SetBkColor(COLORREF clr)
    UINT GetBarHeight() const
    BOOL GetRect(int nBand, LPRECT lpRect) const
    CToolTipCtrl GetToolTips() const
    void SetToolTips(HWND hwndToolTip)
    void GetBandBorders(int nBand, LPRECT lpRect) const
    BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const
    void SetColorScheme(LPCOLORSCHEME lpColorScheme)
    HPALETTE GetPalette() const
    HPALETTE SetPalette(HPALETTE hPalette)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi)
    BOOL DeleteBand(int nBand)
    CWindow SetNotifyWnd(HWND hWnd)
    void BeginDrag(int nBand, DWORD dwPos)
    void BeginDrag(int nBand, int xPos, int yPos)
    void EndDrag()
    void DragMove(DWORD dwPos)
    void DragMove(int xPos, int yPos)
    void GetDropTarget(IDropTarget** ppDropTarget) const
    void MaximizeBand(int nBand)
    void MinimizeBand(int nBand)
    BOOL SizeToRect(LPRECT lpRect)
    int IdToIndex(UINT uBandID) const
    int HitTest(LPRBHITTESTINFO lprbht) const
    BOOL ShowBand(int nBand, BOOL bShow)
    BOOL MoveBand(int nBand, int nNewPos)
    void PushChevron(int nBand, LPARAM lAppValue)

Data Members

    (none)

CComboBoxEx

Basics

Characteristic Value/description
Inherits from CComboBox
Usage mode Client

Usage Notes

To implement a window based on a ComboBox control, do this:

class CMyComboBoxEx : CWindowImpl<CMyComboBoxEx, CComboBoxEx>
{
public:
     BEGIN_MSG_MAP(CMyComboBoxEx)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CComboBoxEx(HWND hWnd = NULL)
    CComboBoxEx& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    CImageList GetImageList() const
    CImageList SetImageList(HIMAGELIST hImageList)
    DWORD GetExtendedStyle() const
    DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle)
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    int InsertItem(const COMBOBOXEXITEM FAR* lpcCBItem)
    int DeleteItem(int nIndex)
    BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const
    BOOL SetItem(const COMBOBOXEXITEM FAR* lpcCBItem)
    CComboBox GetComboCtrl() const
    CEdit GetEditCtrl() const
    BOOL HasEditChanged() const

Data Members

    (none)

CDateTimePickerCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a DateTimePicker control, do this:

class CMyDateTimePickerCtrl : CWindowImpl<CMyDateTimePickerCtrl, CDateTimePickerCtrl>
{
public:
     BEGIN_MSG_MAP(CMyDateTimePickerCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CDateTimePickerCtrl(HWND hWnd = NULL)
    CDateTimePickerCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Operations
    static LPCTSTR GetWndClassName()
    BOOL SetFormat(LPTSTR lpszFormat)
    COLORREF GetMonthCalColor(int nColorType) const
    COLORREF SetMonthCalColor(int nColorType, COLORREF clr)
    DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const
    BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray)
    DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const
    BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime)
    CMonthCalendarCtrl GetMonthCal() const
    CFontHandle GetMonthCalFont() const
    void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE)

Data Members

    (none)

CFlatScrollBarImpl

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class for use with CFlatScrollBar

Methods

public:
Initialization
    BOOL FlatSB_Initialize()
    HRESULT FlatSB_Uninitialize()
Flat scroll bar properties
    BOOL FlatSB_GetScrollProp(UINT uIndex, LPINT lpnValue) const
    BOOL FlatSB_SetScrollProp(UINT uIndex, int nValue, BOOL bRedraw = TRUE)
Attributes
    int FlatSB_GetScrollPos(int nBar) const
    int FlatSB_SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE)
    BOOL FlatSB_GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
    BOOL FlatSB_SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
    BOOL FlatSB_GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) const
    int FlatSB_SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
Operations
    BOOL FlatSB_ShowScrollBar(UINT nBar, BOOL bShow = TRUE)
    BOOL FlatSB_EnableScrollBar(UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE_BOTH)

Data Members

    (none)

CFlatScrollBar

Basics

Characteristic Value/description
Inherits from CFlatScrollBarImpl
Usage mode As-is, as an alternative to CScrollBar

Methods

public:
    CFlatScrollBar(HWND hWnd = NULL)
    CFlatScrollBar& operator=(HWND hWnd)

Data Members

    (none)

CIPAddressCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a IPAddress control, do this:

class CMyIPAddressCtrl : CWindowImpl<CMyIPAddressCtrl, CIPAddressCtrl>
{
public:
     BEGIN_MSG_MAP(CMyIPAddressCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CIPAddressCtrl(HWND hWnd = NULL)
    CIPAddressCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Atteributes
    static LPCTSTR GetWndClassName()
    BOOL IsBlank() const
    int GetAddress(LPDWORD lpdwAddress) const
    void SetAddress(DWORD dwAddress)
    void ClearAddress()
    void SetRange(int nField, WORD wRange)
    void SetRange(int nField, BYTE nMin, BYTE nMax)
    void SetFocus(int nField)

Data Members

    (none)

CMonthCalendarCtrl

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Usage Notes

To implement a window based on a MonthCalendar control, do this:

class CMyMonthCalendarCtrl : CWindowImpl<CMyMonthCalendarCtrl, CMonthCalendarCtrl>
{
public:
     BEGIN_MSG_MAP(CMyMonthCalendarCtrl)
         // put your message handler entries here
     END_MSG_MAP()
};

Methods

public:
    CMonthCalendarCtrl(HWND hWnd = NULL)
    CMonthCalendarCtrl& operator=(HWND hWnd)
    HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
Attributes
    static LPCTSTR GetWndClassName()
    COLORREF GetColor(int nColorType) const
    COLORREF SetColor(int nColorType, COLORREF clr)
    BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const
    BOOL SetCurSel(LPSYSTEMTIME lpSysTime)
    int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const
    int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL)
    int GetMaxSelCount() const
    BOOL SetMaxSelCount(int nMax)
    int GetMonthDelta() const
    int SetMonthDelta(int nDelta)
    DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const
    BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray)
    BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const
    BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray)
    BOOL GetToday(LPSYSTEMTIME lpSysTime) const
    void SetToday(LPSYSTEMTIME lpSysTime)
    BOOL GetMinReqRect(LPRECT lpRectInfo) const
    int GetMonthRange() const
    BOOL GetUnicodeFormat() const
    BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
Operations
    int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const
    BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray)
    DWORD HitTest(PMCHITTESTINFO pMCHitTest) const

Data Members

    (none)

CCustomDraw<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class

Message Map and Handlers

    BEGIN_MSG_MAP(CCustomDraw< T >)
        NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw)
    ALT_MSG_MAP(1)
        REFLECTED_NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw)
    END_MSG_MAP()

    LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
Overrideables
    DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnItemPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnItemPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)

Methods

public:
    BOOL IsMsgHandled() const
    void SetMsgHandled(BOOL bHandled)

Data Members

public:
    BOOL m_bHandledCD;

Property Sheet & Page

CPropertySheetWindow

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CPropertySheetWindow(HWND hWnd = NULL)
    CPropertySheetWindow& operator=(HWND hWnd)
Attributes
    int GetPageCount() const
    HWND GetActivePage() const
    int GetActiveIndex() const
    BOOL SetActivePage(int nPageIndex)
    BOOL SetActivePage(HPROPSHEETPAGE hPage)
    BOOL SetActivePageByID(int nPageID)
    void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
    HWND GetTabControl() const
    void SetFinishText(LPCTSTR lpszText)
    void SetWizardButtons(DWORD dwFlags)
Operations
    void AddPage(HPROPSHEETPAGE hPage)
    BOOL AddPage(LPCPROPSHEETPAGE pPage)
    void RemovePage(int nPageIndex)
    void RemovePage(HPROPSHEETPAGE hPage)
    BOOL PressButton(int nButton)
    BOOL Apply()
    void CancelToClose()
    void SetModified(HWND hWndPage, BOOL bChanged = TRUE)
    LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
    void RebootSystem()
    void RestartWindows()
    BOOL IsDialogMessage(LPMSG lpMsg)
    int HwndToIndex(HWND hWnd) const
    HWND IndexToHwnd(int nIndex) const
    int PageToIndex(HPROPSHEETPAGE hPage) const
    HPROPSHEETPAGE IndexToPage(int nIndex) const
    int IdToIndex(int nID) const
    int IndexToId(int nIndex) const
    int GetResult() const
    BOOL RecalcPageSizes()
Implementation - override to prevent usage
    HWND Create(LPCTSTR, HWND, _U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0,
        _U_MENUorID = 0U, LPVOID = NULL)

Data Members

    (none)

CPropertySheetImpl<>

Basics

Characteristic Value/description
Inherits from CWindowImplBase<CPropertySheetWindow> (see CFrameWindowImplBase)
Usage mode Implementation of a property sheet

Message Map and Handlers

    BEGIN_MSG_MAP(thisClass)
        MESSAGE_HANDLER(WM_COMMAND, OnCommand)
    END_MSG_MAP()

    LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)

Methods

public:
    CPropertySheetImpl(_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0,
        HWND hWndParent = NULL)
    ~CPropertySheetImpl()
    static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM)
    HWND Create(HWND hWndParent = NULL)
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
Attributes (extended overrides of client class methods)
    // These now can be called before the sheet is created
    // Note: Calling these after the sheet is created gives unpredictable results
    int GetPageCount() const
    int GetActiveIndex() const
    HPROPSHEETPAGE GetPage(int nPageIndex) const
    int GetPageIndex(HPROPSHEETPAGE hPage) const
    BOOL SetActivePage(int nPageIndex)
    BOOL SetActivePage(HPROPSHEETPAGE hPage)
    void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
    void SetWizardMode()
    void EnableHelp()
Operations
    BOOL AddPage(HPROPSHEETPAGE hPage)
    BOOL AddPage(LPCPROPSHEETPAGE pPage)
    BOOL RemovePage(HPROPSHEETPAGE hPage)
    BOOL RemovePage(int nPageIndex)
    void SetHeader(LPCTSTR szbmHeader)
    void SetHeader(HBITMAP hbmHeader)
    void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL)
    void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL)
    void StretchWatermark(bool bStretchWatermark)

Data Members

public:
    PROPSHEETHEADER m_psh;
    CSimpleArray<_HPROPSHEETPAGE_TYPE> m_arrPages;

CPropertySheet

Basics

Characteristic Value/description
Inherits from CPropertySheetImpl
Usage mode As-is for non-customize sheets

Message Map and Handlers

    BEGIN_MSG_MAP(thisClass)
        MESSAGE_HANDLER(WM_COMMAND, CPropertySheetImpl::OnCommand)
    END_MSG_MAP()

Methods

public:
    CPropertySheet(_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0,
        HWND hWndParent = NULL)

Data Members

    (none)

CPropertyPageWindow

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow)
Usage mode Client

Methods

public:
    CPropertyPageWindow(HWND hWnd = NULL)
    CPropertyPageWindow& operator=(HWND hWnd)
Attributes
    CPropertySheetWindow GetPropertySheet() const
Operations
    BOOL Apply()
    void CancelToClose()
    void SetModified(BOOL bChanged = TRUE)
    LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
    void RebootSystem()
    void RestartWindows()
    void SetWizardButtons(DWORD dwFlags)
Implementation - overrides to prevent usage
    HWND Create(LPCTSTR, HWND, _U_RECT = NULL, LPCTSTR = NULL, DWORD = 0, DWORD = 0,
        _U_MENUorID = 0U, LPVOID = NULL)

Data Members

    (none)

CPropertyPageImpl<>

Basics

Characteristic Value/description
Inherits from CDialogImplBase<CPropertyPageWindow>
Usage mode Implementation of a property sheet

Message Map and Handlers

    BEGIN_MSG_MAP(thisClass)
        MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
    END_MSG_MAP()

    LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
Overridables
    BOOL OnSetActive()
    BOOL OnKillActive()
    BOOL OnApply()
    void OnReset()
    BOOL OnQueryCancel()
    int OnWizardBack()
    int OnWizardNext()
    BOOL OnWizardFinish()
    void OnHelp()
    BOOL OnGetObject(LPNMOBJECTNOTIFY /*lpObjectNotify*/)
    BOOL OnTranslateAccelerator(LPMSG /*lpMsg*/)
    HWND OnQueryInitialFocus(HWND /*hWndFocus*/)

Methods

public:
    operator PROPSHEETPAGE*() { return &m_psp; }
    CPropertyPageImpl(_U_STRINGorID title = (LPCTSTR)NULL)
    static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
    HPROPSHEETPAGE Create()
Attributes
    void SetTitle(_U_STRINGorID title)
    void SetHeaderTitle(LPCTSTR lpstrHeaderTitle)
    void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle)
Operations
    void EnableHelp()

Data Members

public:
    PROPSHEETPAGE m_psp;

CPropertyPage

Basics

Characteristic Value/description
Inherits from CPropertyPageImpl
Usage mode As-is for non-customized property pages

Usage notes

Typical usage:

CPropertyPage<IDD_MYPAGEDIALOG>

Methods

public:
    CPropertyPage(_U_STRINGorID title = (LPCTSTR)NULL)

    DECLARE_EMPTY_MSG_MAP()

Data Members

    (none)

CAxPropertyPageImpl<>

Basics

Characteristic Value/description
Inherits from CPropertyPageImpl
Usage mode Implements a property page that can contain ActiveX controls

Methods

public:
    CAxPropertyPageImpl(_U_STRINGorID title = (LPCTSTR)NULL)
    ~CAxPropertyPageImpl()
Methods
    // call this one to handle keyboard message for ActiveX controls
    BOOL PreTranslateMessage(LPMSG pMsg)
Overridables
    // new default implementation for ActiveX hosting pages
    BOOL OnTranslateAccelerator(LPMSG lpMsg)

Data Members

public:
    HGLOBAL m_hInitData;
    HGLOBAL m_hDlgRes;
    HGLOBAL m_hDlgResSplit;

CAxPropertyPage

Basics

Characteristic Value/description
Inherits from '>CAxPropertyPageImpl
Usage mode As-is for non-cumstomized ActiveX-containing property pages

Usage notes

Typical usage:

CAxPropertyPage<IDD_MYPAGEDIALOG>

Methods

public:
    CAxPropertyPage(_U_STRINGorID title = (LPCTSTR)NULL)

    // not empty so we handle accelerators
    BEGIN_MSG_MAP(CAxPropertyPage)
        CHAIN_MSG_MAP(CAxPropertyPageImpl<CAxPropertyPage<t_wDlgTemplateID>>)
    END_MSG_MAP()

Data Members

    (none)

Common Dialogs

CFileDialogImpl<>

Basics

Characteristic Value/description
Inherits from CDialogImplBase
Usage mode Implementation (often you'd use CFileDialog)

Message Map and Handlers

    BEGIN_MSG_MAP(CFileDialogImpl< T >)
        NOTIFY_CODE_HANDLER(CDN_FILEOK, _OnFileOK)
        NOTIFY_CODE_HANDLER(CDN_FOLDERCHANGE, _OnFolderChange)
        NOTIFY_CODE_HANDLER(CDN_HELP, _OnHelp)
        NOTIFY_CODE_HANDLER(CDN_INITDONE, _OnInitDone)
        NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange)
        NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation)
        NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange)
    END_MSG_MAP()

    LRESULT _OnFileOK(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnFolderChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnHelp(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnInitDone(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnSelChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnShareViolation(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
    LRESULT _OnTypeChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)

Methods

public:
    CFileDialogImpl(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
            LPCTSTR lpszDefExt = NULL,
            LPCTSTR lpszFileName = NULL,
            DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
            LPCTSTR lpszFilter = NULL,
            HWND hWndParent = NULL)
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
Attributes
    CWindow GetFileDialogWindow() const
    int GetFilePath(LPTSTR lpstrFilePath, int nLength) const
    int GetFolderIDList(LPVOID lpBuff, int nLength) const
    int GetFolderPath(LPTSTR lpstrFolderPath, int nLength) const
    int GetSpec(LPTSTR lpstrSpec, int nLength) const
    void SetControlText(int nCtrlID, LPCTSTR lpstrText)
    void SetDefExt(LPCTSTR lpstrExt)
    BOOL GetReadOnlyPref() const    // return TRUE if readonly checked
Operations
    void HideControl(int nCtrlID)
Special override for common dialogs
    BOOL EndDialog(INT_PTR /*nRetCode*/ = 0)
Overrideables
    BOOL OnFileOK(LPOFNOTIFY /*lpon*/)
    void OnFolderChange(LPOFNOTIFY /*lpon*/)
    void OnHelp(LPOFNOTIFY /*lpon*/)
    void OnInitDone(LPOFNOTIFY /*lpon*/)
    void OnSelChange(LPOFNOTIFY /*lpon*/)
    int OnShareViolation(LPOFNOTIFY /*lpon*/)
    void OnTypeChange(LPOFNOTIFY /*lpon*/)

Data Members

public:
    OPENFILENAME m_ofn;
    BOOL m_bOpenFileDialog;         // TRUE for file open, FALSE for file save
    TCHAR m_szFileTitle[_MAX_FNAME];    // contains file title after return
    TCHAR m_szFileName[_MAX_PATH];      // contains full path name after return

CFileDialog

Basics

Characteristic Value/description
Inherits from CFileDialogImpl
Usage mode As-is for simple usage

Methods

public:
    CFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
        LPCTSTR lpszDefExt = NULL,
        LPCTSTR lpszFileName = NULL,
        DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
        LPCTSTR lpszFilter = NULL,
        HWND hWndParent = NULL)

    // override base class map and references to handlers
    DECLARE_EMPTY_MSG_MAP()

Data Members

    (none)

CFolderDialogImpl<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Implementation (often you'd use CFolderDialog)

Methods

public:
    CFolderDialogImpl(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL,
        UINT uFlags = BIF_RETURNONLYFSDIRS)
Operations
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
    // filled after a call to DoModal
    LPCTSTR GetFolderPath() const
    LPCTSTR GetFolderDisplayName() const
    int GetFolderImageIndex() const
Callback function and overrideables
    static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
    void OnInitialized()
    void OnSelChanged(LPITEMIDLIST /*pItemIDList*/)
    int OnValidateFailed(LPCTSTR /*lpstrFolderPath*/)
    // Commands - valid to call only from handlers
    void EnableOK(BOOL bEnable)
    void SetSelection(LPITEMIDLIST pItemIDList)
    void SetSelection(LPCTSTR lpstrFolderPath)
    void SetStatusText(LPCTSTR lpstrText)

Data Members

public:
    BROWSEINFO m_bi;
    TCHAR m_szFolderDisplayName[MAX_PATH];
    TCHAR m_szFolderPath[MAX_PATH];
    HWND m_hWnd;    // used only in the callback function

CFolderDialog

Basics

Characteristic Value/description
Inherits from CFolderDialogImpl<>
Usage mode As-is for simple usage

Methods

public:
    CFolderDialog(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL,
        UINT uFlags = BIF_RETURNONLYFSDIRS)

Data Members

    (none)

CFontDialogImpl<>

Basics

Characteristic Value/description
Inherits from CCommonDialogImplBase
Usage mode Implementation (often you'd use CFontDialog)

Methods

public:
    CFontDialogImpl(LPLOGFONT lplfInitial = NULL,
            DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
            HDC hDCPrinter = NULL,
            HWND hWndParent = NULL)
Operations
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
    void GetCurrentFont(LPLOGFONT lplf) const

    // Helpers for parsing information after successful return
    LPCTSTR GetFaceName() const   // return the face name of the font
    LPCTSTR GetStyleName() const  // return the style name of the font
    int GetSize() const           // return the pt size of the font
    COLORREF GetColor() const     // return the color of the font
    int GetWeight() const         // return the chosen font weight
    BOOL IsStrikeOut() const      // return TRUE if strikeout
    BOOL IsUnderline() const      // return TRUE if underline
    BOOL IsBold() const           // return TRUE if bold font
    BOOL IsItalic() const         // return TRUE if italic font

Methods Inherited from CCommonDialogImplBase

public:
    static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    // Special override for common dialogs
    BOOL EndDialog(INT_PTR /*nRetCode*/ = 0)
    // Implementation - try to override these, to prevent errors
    HWND Create(HWND, _U_RECT, LPCTSTR, DWORD, DWORD, _U_MENUorID, ATOM, LPVOID)

Data Members

public:
    CHOOSEFONT m_cf;
    TCHAR m_szStyleName[64];    // contains style name after return
    LOGFONT m_lf;           // default LOGFONT to store the info

Data Members Inherited from CCommonDialogImplBase

    (none)

CFontDialog

Basics

Characteristic Value/description
Inherits from CFontDialogImpl <CFontDialog>
Usage mode As-s for simple usage

Methods

public:
    CFontDialog(LPLOGFONT lplfInitial = NULL,
        DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
        HDC hDCPrinter = NULL,
        HWND hWndParent = NULL)

Data Members

    (none)

CRichEditFontDialogImpl<>

Basics

Characteristic Value/description
Inherits from CFontDialogImpl
Usage mode Implementation (often you'd use CRichEditFontDialog)

Methods

public:
    CRichEditFontDialogImpl(const CHARFORMAT& charformat,
            DWORD dwFlags = CF_SCREENFONTS,
            HDC hDCPrinter = NULL,
            HWND hWndParent = NULL)
    void GetCharFormat(CHARFORMAT& cf) const
    DWORD FillInLogFont(const CHARFORMAT& cf)

Data Members

    (none)

CRichEditFontDialog

Basics

Characteristic Value/description
Inherits from CRichEditFontDialogImpl
Usage mode As-is for simple usage

Methods

public:
    CRichEditFontDialog(const CHARFORMAT& charformat,
        DWORD dwFlags = CF_SCREENFONTS,
        HDC hDCPrinter = NULL,
        HWND hWndParent = NULL)

Data Members

    (none)

CColorDialogImpl<>

Basics

Characteristic Value/description
Inherits from CCommonDialogImplBase (see CFontDialogImpl)
Usage mode Implementation (often you'd use CColorDialog

Methods

public:
    CColorDialogImpl(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)
Operations
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
    // Set the current color while dialog is displayed
    void SetCurrentColor(COLORREF clr)
    // Helpers for parsing information after successful return
    COLORREF GetColor() const
    static COLORREF* GetCustomColors()

Message Map and Handlers

    BEGIN_MSG_MAP(CColorDialogImpl< T >)
        MESSAGE_HANDLER(_nMsgCOLOROK, _OnColorOK)
    END_MSG_MAP()

Overridable callbacks
    LRESULT _OnColorOK(UINT, WPARAM, LPARAM, BOOL&)
    BOOL OnColorOK()        // validate color

Data Members

public:
    CHOOSECOLOR m_cc;

CColorDialog

Basics

Characteristic Value/description
Inherits from CColorDialogImpl
Usage mode As-is for standard usage

Methods

public:
    CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)

    // override base class map and references to handlers
    DECLARE_EMPTY_MSG_MAP()

Data Members

    (none)

CPrintDialogImpl<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Implementation (often you'd use CPrintDialog)

Usage notes

Used for Print... and Print Setup...

Methods

public:
    CPrintDialogImpl(BOOL bPrintSetupOnly = FALSE,  // TRUE for Print Setup, FALSE for Print Dialog
            DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
            HWND hWndParent = NULL)
Operations
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())

    // GetDefaults will not display a dialog but will get device defaults
    BOOL GetDefaults()

    // Helpers for parsing information after successful return num. copies requested
    int GetCopies() const
    BOOL PrintCollate() const       // TRUE if collate checked
    BOOL PrintSelection() const     // TRUE if printing selection
    BOOL PrintAll() const           // TRUE if printing all pages
    BOOL PrintRange() const         // TRUE if printing page range
    int GetFromPage() const         // starting page if valid
    int GetToPage() const           // starting page if valid
    LPDEVMODE GetDevMode() const    // return DEVMODE
    LPCTSTR GetDriverName() const   // return driver name
    LPCTSTR GetDeviceName() const   // return device name
    LPCTSTR GetPortName() const     // return output port name
    HDC GetPrinterDC() const        // return HDC (caller must delete)

    // This helper creates a DC based on the DEVNAMES and DEVMODE structures.
    // This DC is returned, but also stored in m_pd.hDC as though it had been
    // returned by CommDlg.  It is assumed that any previously obtained DC
    // has been/will be deleted by the user.  This may be
    // used without ever invoking the print/print setup dialogs.
    HDC CreatePrinterDC()

Implementation
    CPrintDialogImpl(PRINTDLG& pdInit)
    BEGIN_MSG_MAP(CPrintDialogImpl< T >)
        COMMAND_ID_HANDLER(0x0400, OnPrintSetup) // value from dlgs.h
    END_MSG_MAP()
    LRESULT OnPrintSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/)

Data Members

public:
    // print dialog parameter block (note this is a reference)
    PRINTDLG& m_pd;

    // Implementation
    PRINTDLG m_pdActual; // the Print/Print Setup need to share this

CPrintDialog

Basics

Characteristic Value/description
Inherits from CPrintDialogImpl
Usage mode As-is for simple usage

Methods

public:
    CPrintDialog(BOOL bPrintSetupOnly = FALSE,
        DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
        HWND hWndParent = NULL)
    CPrintDialog(PRINTDLG& pdInit)

Data Members

    (none)

CPrintDialogExImpl<>

Basics

Characteristic Value/description
Inherits from CWindow (see CMDIWindow), CMessageMap, IPrintDialogCallback, IObjectWithSiteImpl<T>
Usage mode Implementation (often you'd use CPrintDialogEx)

Methods

public:
    CPrintDialogExImpl(DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS |
        PD_NOSELECTION | PD_NOCURRENTPAGE, HWND hWndParent = NULL)
Operations
    HRESULT DoModal(HWND hWndParent = ::GetActiveWindow())
    BOOL EndDialog(INT_PTR /*nRetCode*/ = 0)

    // GetDefaults will not display a dialog but will get device defaults
    HRESULT GetDefaults()

    // Helpers for parsing information after successful return num. copies requested
    int GetCopies() const
    BOOL PrintCollate() const       // TRUE if collate checked
    BOOL PrintSelection() const     // TRUE if printing selection
    BOOL PrintAll() const           // TRUE if printing all pages
    BOOL PrintRange() const         // TRUE if printing page range
    LPDEVMODE GetDevMode() const    // return DEVMODE
    LPCTSTR GetDriverName() const   // return driver name
    LPCTSTR GetDeviceName() const   // return device name
    LPCTSTR GetPortName() const     // return output port name
    HDC GetPrinterDC() const        // return HDC (caller must delete)

    // This helper creates a DC based on the DEVNAMES and DEVMODE structures.
    // This DC is returned, but also stored in m_pdex.hDC as though it had been
    // returned by CommDlg.  It is assumed that any previously obtained DC
    // has been/will be deleted by the user.  This may be
    // used without ever invoking the print/print setup dialogs.
    HDC CreatePrinterDC()
Implementation - IUnknown
    STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
    virtual ULONG STDMETHODCALLTYPE AddRef()
    virtual ULONG STDMETHODCALLTYPE Release()
Implementation - IPrintDialogCallback
    STDMETHOD(InitDone)()
    STDMETHOD(SelectionChange)()
    STDMETHOD(HandleMessage)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
        LRESULT* plResult)

Data Members

public:
    PRINTDLGEX m_pdex;

CPrintDialogEx

Basics

Characteristic Value/description
Inherits from CPrintDialogExImpl<>
Usage mode As-is for simple usage

Methods

public:
    CPrintDialogEx(
        DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION |
            PD_NOCURRENTPAGE, HWND hWndParent = NULL)

    DECLARE_EMPTY_MSG_MAP()

Data Members

    (none)

CPageSetupDialogImpl<>

Basics

Characteristic Value/description
Inherits from CCommonDialogImplBase (see CFontDialogImpl)
Usage mode Implementation (often you'd use CPageSetupDialog)

Methods

public:
    CPageSetupDialogImpl(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)
Attributes
    LPDEVMODE GetDevMode() const    // return DEVMODE
    LPCTSTR GetDriverName() const   // return driver name
    LPCTSTR GetDeviceName() const   // return device name
    LPCTSTR GetPortName() const     // return output port name
    HDC CreatePrinterDC()
    SIZE GetPaperSize() const
    void GetMargins(LPRECT lpRectMargins, LPRECT lpRectMinMargins) const
Operations
    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
Implementation
    static UINT CALLBACK PaintHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Overridables
    UINT PreDrawPage(WORD /*wPaper*/, WORD /*wFlags*/, LPPAGESETUPDLG /*pPSD*/)
    UINT OnDrawPage(UINT /*uMsg*/, HDC /*hDC*/, LPRECT /*lpRect*/)

Data Members

public:
    PAGESETUPDLG m_psd;
    CWndProcThunk m_thunkPaint;

CPageSetupDialog

Basics

Characteristic Value/description
Inherits from CPageSetupDialogImpl
Usage mode As-is for simple usage

Methods

public:
    CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)

    // override PaintHookProc and references to handlers
    static UINT CALLBACK PaintHookProc(HWND, UINT, WPARAM, LPARAM)

Data Members

    (none)

CFindReplaceDialogImpl<>

Basics

Characteristic Value/description
Inherits from CCommonDialogImplBase (see CFontDialogImpl)
Usage mode Implementation (often you'd use CFindReplaceDialog)

Methods

public:
    CFindReplaceDialogImpl()

    // Note: You must allocate the object on the heap.
    //       If you do not, you must override OnFinalMessage()
    virtual void OnFinalMessage(HWND /*hWnd*/)

    HWND Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace
            LPCTSTR lpszFindWhat,
            LPCTSTR lpszReplaceWith = NULL,
            DWORD dwFlags = FR_DOWN,
            HWND hWndParent = NULL)

    static const UINT GetFindReplaceMsg()

    // call while handling FINDMSGSTRING registered message to retreive the object
    static T* PASCAL GetNotifier(LPARAM lParam)
Operations
    // Helpers for parsing information after successful return
    LPCTSTR GetFindString() const    // get find string
    LPCTSTR GetReplaceString() const // get replacement string
    BOOL SearchDown() const          // TRUE if search down, FALSE is up
    BOOL FindNext() const            // TRUE if command is find next
    BOOL MatchCase() const           // TRUE if matching case
    BOOL MatchWholeWord() const      // TRUE if matching whole words only
    BOOL ReplaceCurrent() const      // TRUE if replacing current string
    BOOL ReplaceAll() const          // TRUE if replacing all occurrences
    BOOL IsTerminating() const       // TRUE if terminating dialog

Data Members

public:
    FINDREPLACE m_fr;
    TCHAR m_szFindWhat[128];
    TCHAR m_szReplaceWith[128];

CFindReplaceDialog

Basics

Characteristic Value/description
Inherits from CFindReplaceDialogImpl
Usage mode As-is for simple usage

Methods

public:
    CFindReplaceDialog()

    DECLARE_EMPTY_MSG_MAP()

Data Members

    (none)

User Support

CMenu

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CMenu (manages m_hMenu)
Alias CMenuHandle (does not manage m_hMenu)

Methods

public:
    CMenu(HMENU hMenu = NULL)
    ~CMenu()
    CMenu& operator=(HMENU hMenu)
    void Attach(HMENU hMenuNew)
    HMENU Detach()
    operator HMENU() const { return m_hMenu; }
    BOOL IsMenu() const
Create and load methods
    BOOL CreateMenu()
    BOOL CreatePopupMenu()
    BOOL LoadMenu(_U_STRINGorID menu)
    BOOL LoadMenuIndirect(const void* lpMenuTemplate)
    BOOL DestroyMenu()
Menu Operations
    BOOL DeleteMenu(UINT nPosition, UINT nFlags)
    BOOL TrackPopupMenu(UINT nFlags, int x, int y, HWND hWnd, LPCRECT lpRect = NULL)
    BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm = NULL)
    BOOL GetMenuInfo(LPMENUINFO lpMenuInfo) const
    BOOL SetMenuInfo(LPCMENUINFO lpMenuInfo)
Menu Item Operations
    BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewItem = NULL)
    BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp)
    UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck)
    UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable)
    BOOL HiliteMenuItem(HWND hWnd, UINT uIDHiliteItem, UINT uHilite)
    int GetMenuItemCount() const
    UINT GetMenuItemID(int nPos) const
    UINT GetMenuState(UINT nID, UINT nFlags) const
    int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const
    int GetMenuStringLen(UINT nIDItem, UINT nFlags) const
    BOOL GetMenuString(UINT nIDItem, BSTR& bstrText, UINT nFlags) const
    int GetMenuString(UINT nIDItem, CString& strText, UINT nFlags) const
    CMenuHandle GetSubMenu(int nPos) const
    BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0,
        LPCTSTR lpszNewItem = NULL)
    BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp)
    BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0,
        LPCTSTR lpszNewItem = NULL)
    BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp)
    BOOL RemoveMenu(UINT nPosition, UINT nFlags)
    BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUnchecked,
        HBITMAP hBmpChecked)
    BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags)
    BOOL GetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) const
    BOOL SetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii)
    BOOL InsertMenuItem(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii)
    UINT GetMenuDefaultItem(BOOL bByPosition = FALSE, UINT uFlags = 0U) const
    BOOL SetMenuDefaultItem(UINT uItem = (UINT)-1,  BOOL bByPosition = FALSE)
    BOOL GetMenuItemRect(HWND hWnd, UINT uItem, LPRECT lprcItem) const
    int MenuItemFromPoint(HWND hWnd, POINT point) const
Context Help Functions
    BOOL SetMenuContextHelpId(DWORD dwContextHelpId)
    DWORD GetMenuContextHelpId() const

Data Members

public:
    HMENU m_hMenu;

GDI support

CDC

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CDC (manages m_hDC)
Alias CDCHandle (does not manage m_hDC)

Methods

public:
Constructor/destructor
    CDC(HDC hDC = NULL)
    CDC& operator=(HDC hDC)
    ~CDC()

Operations
    void Attach(HDC hDC)
    HDC Detach()
    operator HDC() const { return m_hDC; }
    bool IsNull() const { return (m_hDC == NULL); }
    HWND WindowFromDC() const
    CPenHandle GetCurrentPen() const
    CBrushHandle GetCurrentBrush() const
    CPaletteHandle GetCurrentPalette() const
    CFontHandle GetCurrentFont() const
    CBitmapHandle GetCurrentBitmap() const
    HDC CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput,
        const DEVMODE* lpInitData)
    HDC CreateCompatibleDC(HDC hDC = NULL)
    BOOL DeleteDC()

Device-Context Functions
    int SaveDC()
    BOOL RestoreDC(int nSavedDC)
    int GetDeviceCaps(int nIndex) const
    UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags)
    UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags) const
    BOOL ResetDC(const DEVMODE* lpDevMode)

Drawing-Tool Functions
    BOOL GetBrushOrg(LPPOINT lpPoint) const
    BOOL SetBrushOrg(int x, int y, LPPOINT lpPoint = NULL)
    BOOL SetBrushOrg(POINT point, LPPOINT lpPointRet = NULL)
    int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData)

Type-safe selection helpers
    HPEN SelectPen(HPEN hPen)
    HBRUSH SelectBrush(HBRUSH hBrush)
    HFONT SelectFont(HFONT hFont)
    HBITMAP SelectBitmap(HBITMAP hBitmap)
    int SelectRgn(HRGN hRgn)       // special return for regions

Type-safe selection helpers for stock objects
    HPEN SelectStockPen(int nPen)
    HBRUSH SelectStockBrush(int nBrush)
    HFONT SelectStockFont(int nFont)
    HPALETTE SelectStockPalette(int nPalette, BOOL bForceBackground)

Color and Color Palette Functions
    COLORREF GetNearestColor(COLORREF crColor) const
    HPALETTE SelectPalette(HPALETTE hPalette, BOOL bForceBackground)
    UINT RealizePalette()
    void UpdateColors()

Drawing-Attribute Functions
    COLORREF GetBkColor() const
    int GetBkMode() const
    int GetPolyFillMode() const
    int GetROP2() const
    int GetStretchBltMode() const
    COLORREF GetTextColor() const
    COLORREF SetBkColor(COLORREF crColor)
    int SetBkMode(int nBkMode)
    int SetPolyFillMode(int nPolyFillMode)
    int SetROP2(int nDrawMode)
    int SetROP2(int nDrawMode)
    COLORREF SetTextColor(COLORREF crColor)
    BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const
    BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust)

Mapping Functions
    int GetMapMode() const
    BOOL GetViewportOrg(LPPOINT lpPoint) const
    int SetMapMode(int nMapMode)
    BOOL SetViewportOrg(int x, int y, LPPOINT lpPoint = NULL)
    BOOL SetViewportOrg(POINT point, LPPOINT lpPointRet = NULL)
    BOOL OffsetViewportOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL)
    BOOL GetViewportExt(LPSIZE lpSize) const
    BOOL SetViewportExt(int x, int y, LPSIZE lpSize = NULL)
    BOOL SetViewportExt(SIZE size, LPSIZE lpSizeRet = NULL)
    BOOL ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL)
    BOOL GetWindowOrg(LPPOINT lpPoint) vconst
    BOOL SetWindowOrg(int x, int y, LPPOINT lpPoint = NULL)
    BOOL SetWindowOrg(POINT point, LPPOINT lpPointRet = NULL)
    BOOL OffsetWindowOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL)
    BOOL GetWindowExt(LPSIZE lpSize) const
    BOOL SetWindowExt(int x, int y, LPSIZE lpSize = NULL)
    BOOL SetWindowExt(SIZE size, LPSIZE lpSizeRet)
    BOOL ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL)

Coordinate Functions
    BOOL DPtoLP(LPPOINT lpPoints, int nCount = 1) const
    BOOL DPtoLP(LPRECT lpRect) const
    BOOL DPtoLP(LPSIZE lpSize) const
    BOOL LPtoDP(LPPOINT lpPoints, int nCount = 1) const
    BOOL LPtoDP(LPRECT lpRect) const
    BOOL LPtoDP(LPSIZE lpSize) const
    void DPtoHIMETRIC(LPSIZE lpSize) const
    void HIMETRICtoDP(LPSIZE lpSize) const
    void LPtoHIMETRIC(LPSIZE lpSize) const
    void HIMETRICtoLP(LPSIZE lpSize) const

Region Functions
    BOOL FillRgn(HRGN hRgn, HBRUSH hBrush)
    BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight)
    BOOL InvertRgn(HRGN hRgn)
    BOOL PaintRgn(HRGN hRgn)

Clipping Functions
    int GetClipBox(LPRECT lpRect) const
    BOOL PtVisible(int x, int y) const
    BOOL PtVisible(POINT point) const
    BOOL RectVisible(LPCRECT lpRect) const
    int SelectClipRgn(HRGN hRgn)
    int ExcludeClipRect(int x1, int y1, int x2, int y2)
    int ExcludeClipRect(LPCRECT lpRect)
    int ExcludeUpdateRgn(HWND hWnd)
    int IntersectClipRect(int x1, int y1, int x2, int y2)
    int IntersectClipRect(LPCRECT lpRect)
    int OffsetClipRgn(int x, int y)
    int OffsetClipRgn(SIZE size)
    int SelectClipRgn(HRGN hRgn, int nMode)

Line-Output Functions
    BOOL GetCurrentPosition(LPPOINT lpPoint) const
    BOOL MoveTo(int x, int y, LPPOINT lpPoint = NULL)
    BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL)
    BOOL LineTo(int x, int y)
    BOOL LineTo(POINT point)
    BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
    BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
    BOOL Polyline(LPPOINT lpPoints, int nCount)
    BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle)
    BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
    BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
    int GetArcDirection() const
    int SetArcDirection(int nArcDirection)
    BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount)
    BOOL PolylineTo(const POINT* lpPoints, int nCount)
    BOOL PolyPolyline(const POINT* lpPoints,
        const DWORD* lpPolyPoints, int nCount)
    BOOL PolyBezier(const POINT* lpPoints, int nCount)
    BOOL PolyBezierTo(const POINT* lpPoints, int nCount)

Simple Drawing Functions
    BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush)
    BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush)
    BOOL InvertRect(LPCRECT lpRect)
    BOOL DrawIcon(int x, int y, HICON hIcon)
    BOOL DrawIcon(POINT point, HICON hIcon)
    BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0,
        HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
    BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0,
        HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
    BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL)
    BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL)
    BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE,
        int nTextLen = 0, HBRUSH hBrush = NULL)
    BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags,
        HBRUSH hBrush = NULL)

Ellipse and Polygon Functions
    BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
    BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
    void DrawFocusRect(LPCRECT lpRect)
    BOOL Ellipse(int x1, int y1, int x2, int y2)
    BOOL Ellipse(LPCRECT lpRect)
    BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
    BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
    BOOL Polygon(LPPOINT lpPoints, int nCount)
    BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount)
    BOOL Rectangle(int x1, int y1, int x2, int y2)
    BOOL Rectangle(LPCRECT lpRect)
    BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
    BOOL RoundRect(LPCRECT lpRect, POINT point)

Bitmap Functions
    BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop)
    BOOL BitBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC,
        int xSrc, int ySrc, DWORD dwRop)
    BOOL StretchBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc,
        int nSrcWidth, int nSrcHeight, DWORD dwRop)
    COLORREF GetPixel(int x, int y) const
    COLORREF GetPixel(POINT point) const
    COLORREF SetPixel(int x, int y, COLORREF crColor)
    COLORREF SetPixel(POINT point, COLORREF crColor)
    BOOL FloodFill(int x, int y, COLORREF crColor)
    BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType)
    BOOL MaskBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc,
        HBITMAP hMaskBitmap, int xMask, int yMask, DWORD dwRop)
    BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC, int xSrc, int ySrc, int nWidth, int nHeight,
        HBITMAP hMaskBitmap, int xMask, int yMask)
    BOOL SetPixelV(int x, int y, COLORREF crColor)
    BOOL SetPixelV(POINT point, COLORREF crColor)
    BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc,
        int nSrcWidth, int nSrcHeight, BLENDFUNCTION bf)
    BOOL TransparentBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc,
        int nSrcWidth, int nSrcHeight, UINT crTransparent)
    BOOL GradientFill(const PTRIVERTEX pVertices, DWORD nVertices, void* pMeshElements,
        DWORD nMeshElements, DWORD dwMode)

Extra bitmap functions
    BOOL DitherBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, HBITMAP hBitmap,
        int xSrc, int ySrc)

Text Functions
    BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount = -1)
    BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString,
        UINT nCount = -1, LPINT lpDxWidths = NULL)
    SIZE TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0,
        LPINT lpnTabStopPositions = NULL, int nTabOrigin = 0)
    int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat)
    BOOL GetTextExtent(LPCTSTR lpszString, int nCount, LPSIZE lpSize) const
    BOOL GetTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions,
        LPINT lpnTabStopPositions) const
    BOOL GrayString(HBRUSH hBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData,
        int nCount, int x, int y, int nWidth, int nHeight)
    UINT GetTextAlign() const
    UINT SetTextAlign(UINT nFlags)
    int GetTextFace(LPTSTR lpszFacename, int nCount) const
    int GetTextFaceLen() const
    BOOL GetTextFace(BSTR& bstrFace) const
    int GetTextFace(CString& strFace) const
    BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const
    int SetTextJustification(int nBreakExtra, int nBreakCount)
    int GetTextCharacterExtra() const
    int SetTextCharacterExtra(int nCharExtra)

Advanced Drawing
    BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags)
    BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState)

Scrolling Functions
    BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate,
        LPRECT lpRectUpdate)

Font Functions
    BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
    BOOL GetCharWidth32(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
    DWORD SetMapperFlags(DWORD dwFlag)
    BOOL GetAspectRatioFilter(LPSIZE lpSize) const
    BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const
    DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const
    int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const
    UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const
    DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer,
        LPVOID lpBuffer, const MAT2* lpmat2) const
    BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const
    BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const

Printer/Device Escape Functions
    int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData)
    int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData,
        int nOutputSize, LPSTR lpszOutputData)
    int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData)
    int StartDoc(LPCTSTR lpszDocName)  // old Win3.0 version
    int StartDoc(LPDOCINFO lpDocInfo)
    int StartPage()
    int EndPage()
    int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int))
    int AbortDoc()
    int EndDoc()

MetaFile Functions
    BOOL PlayMetaFile(HMETAFILE hMF)
    BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds)
    BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData)
    static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable,
        METARECORD* pMetaRec, int nHandles, LPARAM lParam)

Path Functions
    BOOL AbortPath()
    BOOL BeginPath()
    BOOL CloseFigure()
    BOOL EndPath()
    BOOL FillPath()
    BOOL FlattenPath()
    BOOL StrokeAndFillPath()
    BOOL StrokePath()
    BOOL WidenPath()
    BOOL GetMiterLimit(PFLOAT pfMiterLimit) const
    BOOL SetMiterLimit(float fMiterLimit)
    int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const
    BOOL SelectClipPath(int nMode)

Misc Helper Functions
    static CBrushHandle PASCAL GetHalftoneBrush()
    void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast,
        HBRUSH hBrush = NULL, HBRUSH hBrushLast = NULL)
    void FillSolidRect(LPCRECT lpRect, COLORREF clr)
    void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr)
    void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight)
    void Draw3dRect(int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)

DIB support
    int SetDIBitsToDevice(int x, int y, DWORD dwWidth, DWORD dwHeight, int xSrc, int ySrc,
        UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi,
        UINT uColorUse)
    int StretchDIBits(int x, int y, int nWidth, int nHeight, int xSrc, int ySrc, int nSrcWidth,
        int nSrcHeight, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse,
        DWORD dwRop)
    UINT GetDIBColorTable(UINT uStartIndex, UINT cEntries, RGBQUAD* pColors) const
    UINT SetDIBColorTable(UINT uStartIndex, UINT cEntries, CONST RGBQUAD* pColors)

OpenGL support
    int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd)
    int DescribePixelFormat(int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
    int GetPixelFormat() const
    BOOL SetPixelFormat(int iPixelFormat, CONST PIXELFORMATDESCRIPTOR* ppfd)
    BOOL SwapBuffers()
    HGLRC wglCreateContext()
    HGLRC wglCreateLayerContext(int iLayerPlane)
    BOOL wglMakeCurrent(HGLRC hglrc)
    BOOL wglUseFontBitmaps(DWORD dwFirst, DWORD dwCount, DWORD listBase)
    BOOL wglUseFontOutlines(DWORD dwFirst, DWORD dwCount, DWORD listBase, FLOAT deviation,
        FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf)
    BOOL wglDescribeLayerPlane(int iPixelFormat, int iLayerPlane, UINT nBytes,
        LPLAYERPLANEDESCRIPTOR plpd)
    int wglSetLayerPaletteEntries(int iLayerPlane, int iStart, int cEntries,
        CONST COLORREF* pclr)
    int wglGetLayerPaletteEntries(int iLayerPlane, int iStart, int cEntries, COLORREF* pclr)
    BOOL wglRealizeLayerPalette(int iLayerPlane, BOOL bRealize)
    BOOL wglSwapLayerBuffers(UINT uPlanes)

New for Windows 2000 only
    COLORREF GetDCPenColor() const
    COLORREF SetDCPenColor(COLORREF clr)
    COLORREF GetDCBrushColor() const
    COLORREF SetDCBrushColor(COLORREF clr)
    DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs) const
    DWORD GetGlyphIndices(LPCTSTR lpstr, int cch, LPWORD pgi, DWORD dwFlags) const
    BOOL GetTextExtentPointI(LPWORD pgiIn, int cgi, LPSIZE lpSize) const
    BOOL GetTextExtentExPointI(LPWORD pgiIn, int cgi, int nMaxExtent, LPINT lpnFit, LPINT alpDx,
        LPSIZE lpSize) const
    BOOL GetCharWidthI(UINT giFirst, UINT cgi, LPWORD pgi, LPINT lpBuffer) const
    BOOL GetCharABCWidthsI(UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc) const
    BOOL GetCharABCWidthsI(UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc) const

New for Windows 2000 and Windows 98
    BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries)

Data Members

public:
    HDC m_hDC;

CPaintDC

Basics

Characteristic Value/description
Inherits from CDC
Usage mode Client

Methods

public:
    CPaintDC(HWND hWnd)
    ~CPaintDC()

Data Members

public:
    HWND m_hWnd;
    PAINTSTRUCT m_ps;

CClientDC

Basics

Characteristic Value/description
Inherits from CDC
Usage mode Client

Methods

public:
    CClientDC(HWND hWnd)
    ~CClientDC()

Data Members

public:
    HWND m_hWnd;

CWindowDC

Basics

Characteristic Value/description
Inherits from CDC
Usage mode Client

Methods

public:
    CWindowDC(HWND hWnd)
    ~CWindowDC()

Data Members

public:
    HWND m_hWnd;

CEnhMetaFileDC

Basics

Characteristic Value/description
Inherits from CDC
Usage mode Client

Methods

public:
    CEnhMetaFileDC()
    CEnhMetaFileDC(HDC hdc, LPCRECT lpRect)
    CEnhMetaFileDC(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
    ~CEnhMetaFileDC()
Operations
    void Create(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
    HENHMETAFILE Close()

Data Members

public:
    (none)

CPen

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CPen (manages m_hPen)
Alias CPenHandle (does not manage m_hPen)

Methods

public:
    CPen(HPEN hPen = NULL)
    CPenT& operator=(HPEN hPen)
    ~CPen()
    void Attach(HPEN hPen)
    HPEN Detach()
    operator HPEN() const { return m_hPen; }
    bool IsNull() const { return (m_hPen == NULL); }
Create methods
    HPEN CreatePen(int nPenStyle, int nWidth, COLORREF crColor)
    HPEN CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
        int nStyleCount = 0, const DWORD* lpStyle = NULL)
    HPEN CreatePenIndirect(LPLOGPEN lpLogPen)
    BOOL DeleteObject()
Attributes
    int GetLogPen(LOGPEN* pLogPen) const
    bool GetLogPen(LOGPEN& LogPen) const
    int GetExtLogPen(EXTLOGPEN* pLogPen) const
    bool GetExtLogPen(EXTLOGPEN& ExtLogPen) const

Data Members

public:

CBrush

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CBrush (manages m_hBrush)
Alias CBrushHandle (does not manage m_hBrush)

Methods

public:
    CBrush(HBRUSH hBrush = NULL)
    CBrush& operator=(HBRUSH hBrush)
    ~CBrush()
    void Attach(HBRUSH hBrush)
    HBRUSH Detach()
    operator HBRUSH() const { return m_hBrush; }
    bool IsNull() const { return (m_hBrush == NULL); }
Create methods
    HBRUSH CreateSolidBrush(COLORREF crColor)
    HBRUSH CreateHatchBrush(int nIndex, COLORREF crColor)
    HBRUSH CreateBrushIndirect(const LOGBRUSH* lpLogBrush)
    HBRUSH CreatePatternBrush(HBITMAP hBitmap)
    HBRUSH CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage)
    HBRUSH CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage)
    HBRUSH CreateSysColorBrush(int nIndex)
    BOOL DeleteObject()
Attributes
    int GetLogBrush(LOGBRUSH* pLogBrush) const
    bool GetLogBrush(LOGBRUSH& LogBrush) const

Data Members

public:
    HBRUSH m_hBrush;

CFont

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CFont (manages m_hFont)
Alias CFontHandle (does not manage m_hFont)

Methods

public:
    CFont(HFONT hFont = NULL)
    ~CFont()
    CFont& operator=(HFONT hFont)
    void Attach(HFONT hFont)
    HFONT Detach()
    operator HFONT() const { return m_hFont; }
    bool IsNull() const { return (m_hFont == NULL); }
Create methods
    HFONT CreateFontIndirect(const LOGFONT* lpLogFont)
    HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex)
    HFONT CreateFont(int nHeight, int nWidth, int nEscapement,
    HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL)
    HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont, HDC hDC = NULL)
    BOOL DeleteObject()
Attributes
    int GetLogFont(LOGFONT* pLogFont) const
    bool GetLogFont(LOGFONT& LogFont) const

Data Members

public:
    HFONT m_hFont;

CBitmap

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CBitmap (manages m_hBitmap)
Alias CBitmapHandle (does not manage m_hBitmap)

Methods

public:
    CBitmap(HBITMAP hBitmap = NULL)
    ~CBitmap()
    CBitmap& operator=(HBITMAP hBitmap)
    void Attach(HBITMAP hBitmap)
    HBITMAP Detach()
    operator HBITMAP() const { return m_hBitmap; }
    bool IsNull() const { return (m_hBitmap == NULL); }
Create and load methods
    HBITMAP LoadBitmap(_U_STRINGorID bitmap)
    HBITMAP LoadOEMBitmap(UINT nIDBitmap) // for OBM_/OCR_/OIC_
    HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL,
        int nMapSize = 0)
    HBITMAP CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount,
        const void* lpBits)
    HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap)
    HBITMAP CreateCompatibleBitmap(HDC hDC, int nWidth, int nHeight)
    HBITMAP CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight)
    BOOL DeleteObject()
Attributes
    int GetBitmap(BITMAP* pBitMap) const
    bool GetBitmap(BITMAP& bm) const
    bool GetSize(SIZE& size) const
    DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const
    DWORD SetBitmapBits(DWORD dwCount, const void* lpBits)
    BOOL GetBitmapDimension(LPSIZE lpSize) const
    BOOL SetBitmapDimension(int nWidth, int nHeight, LPSIZE lpSize = NULL)
DIB support
    HBITMAP CreateDIBitmap(HDC hDC, CONST BITMAPINFOHEADER* lpbmih, DWORD dwInit,
        CONST VOID* lpbInit, CONST BITMAPINFO* lpbmi, UINT uColorUse)
    HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse,
        VOID** ppvBits, HANDLE hSection, DWORD dwOffset)
    int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines,  LPVOID lpvBits,
        LPBITMAPINFO lpbmi, UINT uColorUse) const
    int SetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits,
        CONST BITMAPINFO* lpbmi, UINT uColorUse)

Data Members

public:
    HBITMAP m_hBitmap;

CPalette

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CPalette (manages m_hPalette)
Alias CPaletteHandle (does not manage m_hPalette)

Methods

public:
    CPalette(HPALETTE hPalette = NULL)
    ~CPalette()
    CPalette& operator=(HPALETTE hPalette)
    void Attach(HPALETTE hPalette)
    HPALETTE Detach()
    operator HPALETTE() const { return m_hPalette; }
    bool IsNull() const { return (m_hPalette == NULL); }
Create methods
    HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)
    HPALETTE CreateHalftonePalette(HDC hDC)
    BOOL DeleteObject()
Attributes
    int GetEntryCount() const
    UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
        LPPALETTEENTRY lpPaletteColors) const
    UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
        LPPALETTEENTRY lpPaletteColors)
Operations
    void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
    BOOL ResizePalette(UINT nNumEntries)
    UINT GetNearestPaletteIndex(COLORREF crColor) const

Data Members

public:
    HPALETTE m_hPalette;

CRgn

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CRgn (manages m_hRgn)
Alias CRgnHandle (does not manage m_hRgn)

Methods

public:
    CRgn(HRGN hRgn = NULL)
    ~CRgn()
    CRgn& operator=(HRGN hRgn)
    void Attach(HRGN hRgn)
    HRGN Detach()
    operator HRGN() const { return m_hRgn; }
    bool IsNull() const { return (m_hRgn == NULL); }
Create methods
    HRGN CreateRectRgn(int x1, int y1, int x2, int y2)
    HRGN CreateRectRgnIndirect(LPCRECT lpRect)
    HRGN CreateEllipticRgn(int x1, int y1, int x2, int y2)
    HRGN CreateEllipticRgnIndirect(LPCRECT lpRect)
    HRGN CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode)
    HRGN CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount,
        int nPolyFillMode)
    HRGN CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3)
    HRGN CreateFromPath(HDC hDC)
    HRGN CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData)
    BOOL DeleteObject()
Operations
    void SetRectRgn(int x1, int y1, int x2, int y2)
    void SetRectRgn(LPCRECT lpRect)
    int CombineRgn(HRGN hRgnSrc1, HRGN hRgnSrc2, int nCombineMode)
    int CombineRgn(HRGN hRgnSrc, int nCombineMode)
    int CopyRgn(HRGN hRgnSrc)
    BOOL EqualRgn(HRGN hRgn) const
    int OffsetRgn(int x, int y)
    int OffsetRgn(POINT point)
    int GetRgnBox(LPRECT lpRect) const
    BOOL PtInRegion(int x, int y) const
    BOOL PtInRegion(POINT point) const
    BOOL RectInRegion(LPCRECT lpRect) const
    int GetRegionData(LPRGNDATA lpRgnData, int nDataSize) const

Data Members

public:
    HRGN m_hRgn;

CEnhMetaFileInfo

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode As-is

Methods

public:
    CEnhMetaFileInfo(HENHMETAFILE hEMF)
    BYTE* GetEnhMetaFileBits()
    LPTSTR GetEnhMetaFileDescription()
    ENHMETAHEADER* GetEnhMetaFileHeader()
    PIXELFORMATDESCRIPTOR* GetEnhMetaFilePixelFormat()

Data Members

public:
    HENHMETAFILE m_hEMF;
    BYTE* m_pBits;
    TCHAR* m_pDesc;
    ENHMETAHEADER m_header;
    PIXELFORMATDESCRIPTOR m_pfd;

CEnhMetaFile

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client
Alias CEnhMetaFile (manages m_hEMF)
Alias CEnhMetaFileHandle (does not manage m_hEMF)

Methods

public:
    CEnhMetaFile(HENHMETAFILE hEMF = NULL)
    ~CEnhMetaFile()
Operations
    CEnhMetaFile& operator=(HENHMETAFILE hEMF)
    void Attach(HENHMETAFILE hEMF)
    HENHMETAFILE Detach()
    operator HENHMETAFILE() const { return m_hEMF; }
    bool IsNull() const { return (m_hEMF == NULL); }
    BOOL DeleteObject()
    UINT GetEnhMetaFileBits(UINT cbBuffer, LPBYTE lpbBuffer) const
    UINT GetEnhMetaFileDescription(UINT cchBuffer, LPTSTR lpszDescription) const
    UINT GetEnhMetaFileHeader(LPENHMETAHEADER lpemh) const
    UINT GetEnhMetaFilePaletteEntries(UINT cEntries, LPPALETTEENTRY lppe) const
    UINT GetEnhMetaFilePixelFormat(DWORD cbBuffer, PIXELFORMATDESCRIPTOR* ppfd) const

Data Members

public:
    HENHMETAFILE m_hEMF;

Enhanced Controls

CCommandBarCtrlImpl

Basics

Characteristic Value/description
Inherits from CWindowImpl<>
Usage mode Implementation (often you'd use CCommandBarCtrl)

Methods

public:
    CCommandBarCtrlImpl()
    ~CCommandBarCtrlImpl()
Attributes
    DWORD GetCommandBarExtendedStyle() const
    DWORD SetCommandBarExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)
    CMenuHandle GetMenu() const
    COLORREF GetImageMaskColor() const
    COLORREF SetImageMaskColor(COLORREF clrMask)
    bool GetImagesVisible() const
    bool SetImagesVisible(bool bVisible)
    void GetImageSize(SIZE& size) const
    bool SetImageSize(SIZE& size)
    HWND GetCmdBar() const
Methods
    HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            UINT nID = 0, LPVOID lpCreateParam = NULL)
    BOOL AttachToWindow(HWND hWnd)
    BOOL LoadMenu(_U_STRINGorID menu)
    BOOL AttachMenu(HMENU hMenu)
    BOOL LoadImages(_U_STRINGorID image)
    BOOL LoadMappedImages(UINT nIDImage, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0)
    BOOL _LoadImagesHelper(_U_STRINGorID image, bool bMapped, UINT nFlags = 0,
        LPCOLORMAP lpColorMap = NULL, int nMapSize = 0)
    BOOL AddBitmap(_U_STRINGorID bitmap, int nCommandID)
    BOOL AddBitmap(HBITMAP hBitmap, UINT nCommandID)
    BOOL AddIcon(HICON hIcon, UINT nCommandID)
    BOOL ReplaceBitmap(_U_STRINGorID bitmap, int nCommandID)
    BOOL ReplaceBitmap(HBITMAP hBitmap, UINT nCommandID)
    BOOL ReplaceIcon(HICON hIcon, UINT nCommandID)
    BOOL RemoveImage(int nCommandID)
    BOOL RemoveAllImages()
    BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL)

    // NOTE: Limited support for MDI - no icon or min/max/close buttons
    BOOL SetMDIClient(HWND hWndMDIClient)
Implementation - ownerdraw overrideables and helpers
    void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
    void DrawMenuText(CDCHandle& dc, RECT& rc, LPCTSTR lpstrText, COLORREF color)
    void DrawBitmapDisabled(CDCHandle& dc, int nImage, POINT point)
    BOOL Draw3DCheckmark(CDCHandle& dc, const RECT& rc, BOOL bSelected, BOOL bDisabled, BOOL bRadio,
        HBITMAP hBmpCheck)
    void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
Implementation - hook procs
    static LRESULT CALLBACK CreateHookProc(int nCode, WPARAM wParam, LPARAM lParam)
    static LRESULT CALLBACK MessageHookProc(int nCode, WPARAM wParam, LPARAM lParam)
Implementation - menus
    void DoPopupMenu(int nIndex, bool bAnimate)
    BOOL DoTrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, LPTPMPARAMS lpParams = NULL)
    int GetPreviousMenuItem() const
    int GetNextMenuItem() const
    void GetSystemSettings()
Implementation - alternate focus mode support
    void TakeFocus()
    void GiveFocusBack()
Implementation - internal message helpers
    static UINT GetAutoPopupMessage()
    static UINT GetGetBarMessage()

Message Map and Handlers

    DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName())

    BEGIN_MSG_MAP(CCommandBarCtrlImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_INITMENU, OnInitMenu)
        MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup)
        MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
        MESSAGE_HANDLER(GetAutoPopupMessage(), OnInternalAutoPopup)
        MESSAGE_HANDLER(GetGetBarMessage(), OnInternalGetBar)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
        MESSAGE_HANDLER(WM_MENUCHAR, OnMenuChar)

        MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
        MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
        MESSAGE_HANDLER(WM_CHAR, OnChar)
        MESSAGE_HANDLER(WM_SYSKEYDOWN, OnSysKeyDown)
        MESSAGE_HANDLER(WM_SYSKEYUP, OnSysKeyUp)
        MESSAGE_HANDLER(WM_SYSCHAR, OnSysChar)

        // public API handlers - these stay to support chevrons in atlframe.h
        MESSAGE_HANDLER(CBRM_GETMENU, OnAPIGetMenu)
        MESSAGE_HANDLER(CBRM_TRACKPOPUPMENU, OnAPITrackPopupMenu)
        MESSAGE_HANDLER(CBRM_GETCMDBAR, OnAPIGetCmdBar)

        MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
        MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)

        MESSAGE_HANDLER(WM_FORWARDMSG, OnForwardMsg)
    ALT_MSG_MAP(1)      // Parent window messages
        NOTIFY_CODE_HANDLER(TBN_HOTITEMCHANGE, OnParentHotItemChange)
        NOTIFY_CODE_HANDLER(TBN_DROPDOWN, OnParentDropDown)
        MESSAGE_HANDLER(WM_INITMENUPOPUP, OnParentInitMenuPopup)
        MESSAGE_HANDLER(GetGetBarMessage(), OnParentInternalGetBar)
        MESSAGE_HANDLER(WM_SYSCOMMAND, OnParentSysCommand)
        MESSAGE_HANDLER(CBRM_GETMENU, OnParentAPIGetMenu)
        MESSAGE_HANDLER(WM_MENUCHAR, OnParentMenuChar)
        MESSAGE_HANDLER(CBRM_TRACKPOPUPMENU, OnParentAPITrackPopupMenu)
        MESSAGE_HANDLER(CBRM_GETCMDBAR, OnParentAPIGetCmdBar)

        MESSAGE_HANDLER(WM_DRAWITEM, OnParentDrawItem)
        MESSAGE_HANDLER(WM_MEASUREITEM, OnParentMeasureItem)

        MESSAGE_HANDLER(WM_ACTIVATE, OnParentActivate)
        NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnParentCustomDraw)
    ALT_MSG_MAP(2)      // MDI client window messages
        MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu)
    ALT_MSG_MAP(3)      // Message hook messages
        MESSAGE_HANDLER(WM_MOUSEMOVE, OnHookMouseMove)
        MESSAGE_HANDLER(WM_SYSKEYDOWN, OnHookSysKeyDown)
        MESSAGE_HANDLER(WM_SYSKEYUP, OnHookSysKeyUp)
        MESSAGE_HANDLER(WM_SYSCHAR, OnHookSysChar)
        MESSAGE_HANDLER(WM_KEYDOWN, OnHookKeyDown)
        MESSAGE_HANDLER(WM_NEXTMENU, OnHookNextMenu)
        MESSAGE_HANDLER(WM_CHAR, OnHookChar)
    END_MSG_MAP()

    LRESULT OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnSysKeyDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnSysKeyUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnSysChar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnInitMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnInternalAutoPopup(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnInternalGetBar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnMenuChar(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnDrawItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)

    // API message handlers
    LRESULT OnAPIGetMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnAPITrackPopupMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnAPIGetCmdBar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

    // Parent window message handlers
    // Do not hot track if application in background, OK for modeless dialogs
    LRESULT OnParentHotItemChange(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
    LRESULT OnParentDropDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
    LRESULT OnParentInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentInternalGetBar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentSysCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnParentAPIGetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentMenuChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentAPITrackPopupMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentAPIGetCmdBar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnParentActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnParentCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)

    // MDI client window message handlers
    LRESULT OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)

    // Message hook handlers
    LRESULT OnHookMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookSysKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookSysKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookSysChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookNextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnHookChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)

Data Members

public:
    HMENU m_hMenu;
    HIMAGELIST m_hImageList;
    CSimpleValArray m_arrCommand;

    CContainedWindow m_wndParent;
    CContainedWindow m_wndMDIClient;

    bool m_bMenuActive;
    bool m_bAttachedMenu;
    bool m_bImagesVisible;
    bool m_bPopupItem;
    bool m_bContextMenu;
    bool m_bEscapePressed;

    int m_nPopBtn;
    int m_nNextPopBtn;

    SIZE m_szBitmap;
    SIZE m_szButton;

    COLORREF m_clrMask;
    CFont m_fontMenu;

    bool m_bSkipMsg;
    UINT m_uSysKey;

    HWND m_hWndFocus;       // Alternate focus mode
    DWORD m_dwExtendedStyle;    // Command Bar specific extended styles

    bool m_bParentActive;

CCommandBarCtrl

Basics

Characteristic Value/description
Inherits from CCommandBarCtrlImpl
Usage mode As-is for simple usage

Methods

public:
    CCommandBarCtrl()

    DECLARE_WND_SUPERCLASS(_T("WTL_CommandBar"), GetWndClassName())

Data Members

    (none)

CBitmapButtonImpl

Basics

Characteristic Value/description
Inherits from CWindowImpl<>
Usage mode IImplementation (often you'd use CBitmapButton)

Methods

public:
    CBitmapButtonImpl(DWORD dwExtendedStyle = BMPBTN_AUTOSIZE, HIMAGELIST hImageList = NULL)
    ~CBitmapButtonImpl()

    // overridden to provide proper initialization
    BOOL SubclassWindow(HWND hWnd)
Attributes
    DWORD GetBitmapButtonExtendedStyle() const
    DWORD SetBitmapButtonExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)
    HIMAGELIST GetImageList() const
    HIMAGELIST SetImageList(HIMAGELIST hImageList)
    int GetToolTipTextLength() const
    bool GetToolTipText(LPTSTR lpstrText, int nLength) const
    bool SetToolTipText(LPCTSTR lpstrText)
Operations
    void SetImages(int nNormal, int nPushed = -1, int nFocusOrHover = -1, int nDisabled = -1)
    BOOL SizeToImage()
Overrideables
    void DoPaint(CDCHandle dc)

Message Map and Handlers

    DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName())

    BEGIN_MSG_MAP(CBitmapButtonImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
        MESSAGE_HANDLER(WM_SETFOCUS, OnFocus)
        MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus)
        MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
        MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
        MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
        MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
        MESSAGE_HANDLER(WM_ENABLE, OnEnable)
        MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
        MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
        MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
        MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
        MESSAGE_HANDLER(WM_TIMER, OnTimer)
    END_MSG_MAP()

    LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnFocus(UINT uMsg, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnEnable(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnMouseLeave(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
Implementation
    void Init()
    BOOL StartTrackMouseLeave()
    bool IsHoverMode() const

Data Members

public:
    DWORD m_dwExtendedStyle;

    CImageList m_ImageList;
    int m_nImage[_nImageCount];

    CToolTipCtrl m_tip;
    LPTSTR m_lpstrToolTipText;

    // Internal states
    unsigned m_fMouseOver:1;
    unsigned m_fFocus:1;
    unsigned m_fPressed:1;

Constants

#define BMPBTN_HOVER            0x00000001
#define BMPBTN_AUTO3D_SINGLE    0x00000002
#define BMPBTN_AUTO3D_DOUBLE    0x00000004
#define BMPBTN_AUTOSIZE         0x00000008
#define BMPBTN_SHAREIMAGELISTS  0x00000010
#define BMPBTN_AUTOFIRE         0x00000020

CBitmapButton

Basics

Characteristic Value/description
Inherits from CBitmapButtonImpl
Usage mode As-is for simple usage

Methods

public:
    CBitmapButton(DWORD dwExtendedStyle = BMPBTN_AUTOSIZE, HIMAGELIST hImageList = NULL)

    DECLARE_WND_SUPERCLASS(_T("WTL_BitmapButton"), GetWndClassName())

Data Members

    (none)

CCheckListViewCtrlImpl

Basics

Characteristic Value/description
Inherits from CListViewCtrl, CWindowImpl<>
Usage mode Implementation (often you'd use CCheckListViewCtrl)

Methods

public:
Attributes
    static DWORD GetExtendedLVStyle()
Operations
    BOOL SubclassWindow(HWND hWnd)
    void CheckSelectedItems(int nCurrItem)

Message Map and Handlers

    DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName())

    BEGIN_MSG_MAP(CCheckListViewCtrlImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
        MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDown)
        MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
    END_MSG_MAP()

    LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)

Data Members

    (none)

CCheckListViewCtrl

Basics

Characteristic Value/description
Inherits from CCheckListViewCtrlImpl
Usage mode As-is for simple usage

Methods

public:
    CCheckListViewCtrl()

Data Members

    (none)

CHyperLinkImpl

Basics

Characteristic Value/description
Inherits from CWindowImpl<>
Usage mode Implementation (often you'd use CHyperLink)

Methods

public:
    CHyperLinkImpl()
    ~CHyperLinkImpl()
Attributes
    bool GetLabel(LPTSTR lpstrBuffer, int nLength) const
    bool SetLabel(LPCTSTR lpstrLabel)
    bool GetHyperLink(LPTSTR lpstrBuffer, int nLength) const
    bool SetHyperLink(LPCTSTR lpstrLink)
Operations
    BOOL SubclassWindow(HWND hWnd)
    bool Navigate()

Message Map and Handlers

    BEGIN_MSG_MAP(CHyperLinkImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
        MESSAGE_HANDLER(WM_SETFOCUS, OnFocus)
        MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus)
        MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
        MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
        MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
        MESSAGE_HANDLER(WM_CHAR, OnChar)
        MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode)
        MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
    END_MSG_MAP()

    LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnGetDlgCode(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
Implementation
    void Init()
    static COLORREF _ParseColorString(LPTSTR lpstr)
    bool CalcLabelRect()
    void DoPaint(CDCHandle dc)

Data Members

public:
    LPTSTR m_lpstrLabel;
    LPTSTR m_lpstrHyperLink;
    HCURSOR m_hCursor;
    HFONT m_hFont;
    RECT m_rcLink;
    bool m_bPaintLabel;
    CToolTipCtrl m_tip;

    bool m_bVisited;
    COLORREF m_clrLink;
    COLORREF m_clrVisited;

CHyperLink

Basics

Characteristic Value/description
Inherits from CHyperLinkImpl
Usage mode As-is for simple usage

Usage Notes

While it is possible to create CHyperLinks with Create, you'll find this to be tedious because you can't easily determine the label width up front. If you do use Create, create it extra wide, set the label with SetLabel, then reset the control's width with SetWindowPos using the width of the RECT member m_rcLink.

If you're putting a link in a dialog or a form view based on a dialog template, a much easier way to use CHyperLinks is to just create a static text item that has the label text you want for the hyper link in your dialog template (we'll call it IDC_MYLINK), then use SubclassWindow:

CString csLink;
csLink.LoadString(IDS_MYLINKADDRESS);
mMyLink.SubclassWindow(GetDlgItem(IDC_MYLINK));
mMyLink.SetHyperLink(csLink);

Beyond that, CHyperLinks largely take care of themselves. They can indicate focus, so don't forget to set the "Tab stop" attribute for the static text item you plan to subclass.

Also, if you want a link inline with a bunch of other text, you might want to use the Hyperlink Text View Control described in an article at codeproject.com.

Methods

public:
    CHyperLink()

    DECLARE_WND_CLASS(_T("WTL_HyperLink"))

Data Members

    (none)

CWaitCursor

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode As-is

Methods

public:
    CWaitCursor(bool bSet = true, LPCTSTR lpstrCursor = IDC_WAIT, bool bSys = true)
    ~CWaitCursor()
Methods
    bool Set()
    bool Restore()

Data Members

public:
    HCURSOR m_hWaitCursor;
    HCURSOR m_hOldCursor;
    bool m_bInUse;

CMultiPaneStatusBarCtrlImpl

Basics

Characteristic Value/description
Inherits from CWindowImpl<>
Usage mode Implementation (often you'd use CMultiPaneStatusBarCtrl)

Methods

public:
    CMultiPaneStatusBarCtrlImpl()
    ~CMultiPaneStatusBarCtrlImpl()
Methods
    HWND Create(HWND hWndParent, LPCTSTR lpstrText, DWORD dwStyle = WS_CHILD | WS_VISIBLE |
        WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR)
    HWND Create(HWND hWndParent, UINT nTextID = ATL_IDS_IDLEMESSAGE, DWORD dwStyle = WS_CHILD |
        WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, UINT nID = ATL_IDW_STATUS_BAR)
    BOOL SetPanes(int* pPanes, int nPanes, bool bSetText = true)
    bool GetPaneTextLength(int nPaneID, int* pcchLength = NULL, int* pnType = NULL) const
    BOOL GetPaneText(int nPaneID, LPTSTR lpstrText, int* pcchLength = NULL, int* pnType = NULL) const
    BOOL SetPaneText(int nPaneID, LPCTSTR lpstrText, int nType = 0)
    BOOL GetPaneRect(int nPaneID, LPRECT lpRect) const
    BOOL SetPaneWidth(int nPaneID, int cxWidth)
    BOOL GetPaneTipText(int nPaneID, LPTSTR lpstrText, int nSize) const
    BOOL SetPaneTipText(int nPaneID, LPCTSTR lpstrText)
    BOOL GetPaneIcon(int nPaneID, HICON& hIcon) const
    BOOL SetPaneIcon(int nPaneID, HICON hIcon)
Implementation
    BOOL UpdatePanesLayout()
    int GetPaneIndexFromID(int nPaneID) const

Message Map and Handlers

    DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName())

    BEGIN_MSG_MAP(CMultiPaneStatusBarCtrlImpl< T >)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
    END_MSG_MAP()

    LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)

Data Members

public:
    int m_nPanes;
    int* m_pPane;

CMultiPaneStatusBarCtrl

Basics

Characteristic Value/description
Inherits from CMultiPaneStatusBarCtrlImpl
Usage mode As-is for simple usage

Methods

public:
    CMultiPaneStatusBarCtrl()

    DECLARE_WND_SUPERCLASS(_T("WTL_MultiPaneStatusBar"), GetWndClassName())

Data Members

    (none)

CPaneContainerImpl<>

Basics

Characteristic Value/description
Inherits from CWindowImpl<>
Usage mode Implementation (often you'd use CPaneContainer)

Methods

public:
    CPaneContainerImpl()
Attributes
    DWORD GetPaneContainerExtendedStyle() const
    DWORD SetPaneContainerExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)
    HWND GetClient() const
    HWND SetClient(HWND hWndClient)
    BOOL GetTitle(LPTSTR lpstrTitle, int cchLength) const
    BOOL SetTitle(LPCTSTR lpstrTitle)
    int GetTitleLength() const
Methods
    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)
    HWND Create(HWND hWndParent, UINT uTitleID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | 
        WS_CLIPSIBLINGS | WS_CLIPCHILDREN, DWORD dwExStyle = 0, UINT nID = 0,
        LPVOID lpCreateParam = NULL)
    BOOL EnableCloseButton(BOOL bEnable)
    void UpdateLayout()

Data Members

public:
    CToolBarCtrl m_tb;
    CWindow m_wndClient;
    int m_cxyHeader;
    TCHAR m_szTitle[m_cchTitle];
    DWORD m_dwExtendedStyle;    // Pane container specific extended styles

Message Map and Handlers

    BEGIN_MSG_MAP(CPaneContainerImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
        MESSAGE_HANDLER(WM_COMMAND, OnCommand)
        FORWARD_NOTIFICATIONS()
    END_MSG_MAP()

    LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
Custom draw overrides
    DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw)
    DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw)
Implementation - overrideable methods
    void UpdateLayout(int cxWidth, int cyHeight)
    void CreateCloseButton()
    void DestroyCloseButton()
    void CalcSize()
    HFONT GetTitleFont() const
    BOOL GetToolTipText(LPNMHDR /*lpnmh*/)
    void DrawPaneTitle(CDCHandle dc)

    // called only if pane is empty
    void DrawPane(CDCHandle dc)

    // drawing helper - draws "x" button image
    void DrawButtonImage(CDCHandle dc, RECT& rcImage, HPEN hPen)

Constants

#define PANECNT_NOCLOSEBUTTON   0x00000001
#define PANECNT_VERTICAL        0x00000002

CPaneContainer

Basics

Characteristic Value/description
Inherits from CPaneContainerImpl<>
Usage mode As-is for simple usage

Methods

public:
    CPaneContainer()

    DECLARE_WND_CLASS_EX(_T("WTL_PaneContainer"), 0, -1)

Data Members

    (none)

Additional UI Components

CScrollImpl

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Implementation

Usage notes

Provides scrolling support to any window.

Methods

public:
    CScrollImpl()
Attributes & Operations
    DWORD GetScrollExtendedStyle() const
    DWORD SetScrollExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)

    void SetScrollSize(SIZE size, BOOL bRedraw = TRUE)
    void GetScrollSize(SIZE& sizeWnd) const

    // line operations
    void SetScrollLine(int cxLine, int cyLine)
    void SetScrollLine(SIZE sizeLine)
    void GetScrollLine(SIZE& sizeLine) const

    // page operations
    void SetScrollPage(int cxPage, int cyPage)
    void SetScrollPage(SIZE sizePage)
    void GetScrollPage(SIZE& sizePage) const

    // commands
    void ScrollLineDown()
    void ScrollLineUp()
    void ScrollPageDown()
    void ScrollPageUp()
    void ScrollTop()
    void ScrollBottom()
    void ScrollLineRight()
    void ScrollLineLeft()
    void ScrollPageRight()
    void ScrollPageLeft()
    void ScrollAllLeft()
    void ScrollAllRight()

    // offset operations
    void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE)
    void SetScrollOffset(POINT ptOffset, BOOL bRedraw = TRUE)
    void GetScrollOffset(POINT& ptOffset) const

    // size operations
    void SetScrollSize(int cx, int cy, BOOL bRedraw = TRUE)
Overrideables
    void DoPaint(CDCHandle /*dc*/)
Implementation
    void DoScroll(int nType, int nScrollCode, int& cxyOffset, int cxySizeAll, int cxySizePage,
        int cxySizeLine)
    int CalcLineOrPage(int nVal, int nMax, int nDiv)
    void GetSystemSettings()
    bool IsScrollingChildren() const
    bool IsErasingBackground() const
    bool IsNoThumbTracking() const
    bool IsSmoothScroll() const

Message Map and Handlers

    BEGIN_MSG_MAP(CScrollImpl< T >)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
        MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
        MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
        MESSAGE_HANDLER(m_uMsgMouseWheel, OnMouseWheel)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
    // standard scroll commands
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_SCROLL_UP, OnScrollUp)
        COMMAND_ID_HANDLER(ID_SCROLL_DOWN, OnScrollDown)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, OnScrollPageUp)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, OnScrollPageDown)
        COMMAND_ID_HANDLER(ID_SCROLL_TOP, OnScrollTop)
        COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, OnScrollBottom)
        COMMAND_ID_HANDLER(ID_SCROLL_LEFT, OnScrollLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, OnScrollRight)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, OnScrollPageLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, OnScrollPageRight)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, OnScrollAllLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, OnScrollAllRight)
    END_MSG_MAP()

    LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnVScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnHScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)

    // scrolling handlers
    LRESULT OnScrollUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollPageUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollPageDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollTop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollBottom(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollPageLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollPageRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollAllLeft(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    LRESULT OnScrollAllRight(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

Data Members

public:
    POINT m_ptOffset;
    SIZE m_sizeAll;
    SIZE m_sizeLine;
    SIZE m_sizePage;
    SIZE m_sizeClient;
    int m_zDelta;           // current wheel value
    int m_nWheelLines;      // number of lines to scroll on wheel

    // Note that this message must be forwarded from a top level window
    UINT m_uMsgMouseWheel;      // MSH_MOUSEWHEEL

    UINT m_uScrollFlags;
    DWORD m_dwExtendedStyle;    // scroll specific extended styles

Constants

// Scroll extended styles
#define SCRL_SCROLLCHILDREN     0x00000001
#define SCRL_ERASEBACKGROUND    0x00000002
#define SCRL_NOTHUMBTRACKING    0x00000004
#define SCRL_SMOOTHSCROLL       0x00000008

CScrollWindowImpl

Basics

Characteristic Value/description
Inherits from CScrollImpl, CWindowImpl<>
Usage mode Implementation

Usage notes

Implements a scrollable window.

Methods

    (none)

Message Map and Handlers

    BEGIN_MSG_MAP(CScrollImpl< T >)
        MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll)
        MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll)
        MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange)
        MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize)
        MESSAGE_HANDLER(WM_PAINT, CScrollImpl< T >::OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, CScrollImpl< T >::OnPaint)
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp)
        COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown)
        COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop)
        COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom)
        COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight)
    END_MSG_MAP()

Data Members

    (none)

CMapScrollImpl

Basics

Characteristic Value/description
Inherits from CScrollImpl
Usage mode Implementation

Usage notes

Provides mapping and scrolling support to any window.

Methods

public:
    CMapScrollImpl()
Attributes & Operations
    // mapping mode operations
    void SetScrollMapMode(int nMapMode)
    int GetScrollMapMode() const

    // offset operations
    void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE)
    void SetScrollOffset(POINT ptOffset, BOOL bRedraw = TRUE)
    void GetScrollOffset(POINT& ptOffset) const
    // size operations
    void SetScrollSize(int xMin, int yMin, int xMax, int yMax, BOOL bRedraw = TRUE)
    void SetScrollSize(RECT& rcScroll, BOOL bRedraw = TRUE)
    void SetScrollSize(int cx, int cy, BOOL bRedraw = TRUE)
    void SetScrollSize(SIZE size, BOOL bRedraw = NULL)
    void GetScrollSize(RECT& rcScroll) const

    // line operations
    void SetScrollLine(int cxLine, int cyLine)
    void SetScrollLine(SIZE sizeLine)
    void GetScrollLine(SIZE& sizeLine) const

    // page operations
    void SetScrollPage(int cxPage, int cyPage)
    void SetScrollPage(SIZE sizePage)
    void GetScrollPage(SIZE& sizePage) const

Message Map and Handlers

    BEGIN_MSG_MAP(CMapScrollImpl< T >)
        MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll)
        MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll)
        MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange)
        MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp)
        COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown)
        COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop)
        COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom)
        COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight)
    END_MSG_MAP()

    LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)

Data Members

public:
    int m_nMapMode;
    RECT m_rectLogAll;
    SIZE m_sizeLogLine;
    SIZE m_sizeLogPage;

CMapScrollWindowImpl

Basics

Characteristic Value/description
Inherits from CMapScrollImpl, CWindowImpl<>
Usage mode Implementation

Usage notes

Implements scrolling window with mapping.

Methods

    (none)

Data Members

    BEGIN_MSG_MAP(CMapScrollWindowImpl< T >)
        MESSAGE_HANDLER(WM_VSCROLL, CScrollImpl< T >::OnVScroll)
        MESSAGE_HANDLER(WM_HSCROLL, CScrollImpl< T >::OnHScroll)
        MESSAGE_HANDLER(WM_MOUSEWHEEL, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(m_uMsgMouseWheel, CScrollImpl< T >::OnMouseWheel)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, CScrollImpl< T >::OnSettingChange)
        MESSAGE_HANDLER(WM_SIZE, CScrollImpl< T >::OnSize)
        MESSAGE_HANDLER(WM_PAINT, CMapScrollImpl< T >::OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, CMapScrollImpl< T >::OnPaint)
    ALT_MSG_MAP(1)
        COMMAND_ID_HANDLER(ID_SCROLL_UP, CScrollImpl< T >::OnScrollUp)
        COMMAND_ID_HANDLER(ID_SCROLL_DOWN, CScrollImpl< T >::OnScrollDown)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_UP, CScrollImpl< T >::OnScrollPageUp)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_DOWN, CScrollImpl< T >::OnScrollPageDown)
        COMMAND_ID_HANDLER(ID_SCROLL_TOP, CScrollImpl< T >::OnScrollTop)
        COMMAND_ID_HANDLER(ID_SCROLL_BOTTOM, CScrollImpl< T >::OnScrollBottom)
        COMMAND_ID_HANDLER(ID_SCROLL_LEFT, CScrollImpl< T >::OnScrollLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_RIGHT, CScrollImpl< T >::OnScrollRight)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_LEFT, CScrollImpl< T >::OnScrollPageLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_PAGE_RIGHT, CScrollImpl< T >::OnScrollPageRight)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_LEFT, CScrollImpl< T >::OnScrollAllLeft)
        COMMAND_ID_HANDLER(ID_SCROLL_ALL_RIGHT, CScrollImpl< T >::OnScrollAllRight)
    END_MSG_MAP()

Data Members

    (none)

CSplitterImpl

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode mi_impl_asis_helper_base

Methods

public:
    CSplitterImpl() :
Attributes
    void SetSplitterRect(LPRECT lpRect = NULL, bool bUpdate = true)
    void GetSplitterRect(LPRECT lpRect) const
    bool SetSplitterPos(int xyPos = -1, bool bUpdate = true)
    int GetSplitterPos() const
    bool SetSinglePaneMode(int nPane = SPLIT_PANE_NONE)
    int GetSinglePaneMode() const
    DWORD GetSplitterExtendedStyle() const
    DWORD SetSplitterExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)
Splitter operations
    void SetSplitterPanes(HWND hWndLeftTop, HWND hWndRightBottom, bool bUpdate = true)
    bool SetSplitterPane(int nPane, HWND hWnd, bool bUpdate = true)
    HWND GetSplitterPane(int nPane) const
    bool SetActivePane(int nPane)
    int GetActivePane() const
    bool ActivateNextPane(bool bNext = true)
    bool SetDefaultActivePane(int nPane)
    bool SetDefaultActivePane(HWND hWnd)
    int GetDefaultActivePane() const
    void DrawSplitter(CDCHandle dc)
Overrideables
    void DrawSplitterBar(CDCHandle dc)

    // called only if pane is empty
    void DrawSplitterPane(CDCHandle dc, int nPane)
Implementation - internal helpers
    void UpdateSplitterLayout()
    bool GetSplitterBarRect(LPRECT lpRect) const
    bool GetSplitterPaneRect(int nPane, LPRECT lpRect) const
    bool IsOverSplitterRect(int x, int y) const
    bool IsOverSplitterBar(int x, int y) const
    void DrawGhostBar()
    void GetSystemSettings(bool bUpdate)
    bool IsProportional() const
    void StoreProportionalPos()
    void UpdateProportionalPos()
    bool IsRightAligned() const
    void StoreRightAlignPos()
    void UpdateRightAlignPos()
    bool IsInteractive() const

Message Map and Handlers

    BEGIN_MSG_MAP(CSplitterImpl)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
        if(IsInteractive())
        {
            MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
            MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
            MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
            MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
            MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDoubleClick)
        }
        MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
        MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
        MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
    END_MSG_MAP()

    LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
    LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
    LRESULT OnLButtonDoubleClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM, BOOL& bHandled)
    LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
    LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

Data Members

public:
    HWND m_hWndPane[m_nPanesCount];
    RECT m_rcSplitter;
    int m_xySplitterPos;
    int m_nDefActivePane;
    int m_cxySplitBar;      // splitter bar width/height
    static HCURSOR m_hCursor;
    int m_cxyMin;           // minimum pane size
    int m_cxyBarEdge;       // splitter bar edge
    bool m_bFullDrag;
    int m_cxyDragOffset;
    int m_nProportionalPos;
    DWORD m_dwExtendedStyle;    // splitter specific extended styles
    int m_nSinglePane;      // single pane mode

Constants

// Splitter panes constants
#define SPLIT_PANE_LEFT          0
#define SPLIT_PANE_RIGHT         1
#define SPLIT_PANE_TOP           SPLIT_PANE_LEFT
#define SPLIT_PANE_BOTTOM        SPLIT_PANE_RIGHT
#define SPLIT_PANE_NONE         -1

// Splitter extended styles
#define SPLIT_PROPORTIONAL      0x00000001
#define SPLIT_NONINTERACTIVE    0x00000002
#define SPLIT_RIGHTALIGNED      0x00000004
#define SPLIT_BOTTOMALIGNED     SPLIT_RIGHTALIGNED

// Note: SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED are 
// mutually exclusive. If both are set, splitter defaults to SPLIT_PROPORTIONAL

CSplitterWindowImpl

Basics

Characteristic Value/description
Inherits from CSplitterImpl
Usage mode Implementation

Usage notes

Implements a splitter window.

Methods

    (none)

Message Map and Handlers

    DECLARE_WND_CLASS_EX(NULL, CS_DBLCLKS, COLOR_WINDOW)

    BEGIN_MSG_MAP(CSplitterWindowImpl)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        CHAIN_MSG_MAP(CSplitterImpl)
        FORWARD_NOTIFICATIONS()
    END_MSG_MAP()

    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)

Data Members

    (none)

CSplitterWindow

Basics

Characteristic Value/description
Inherits from CSplitterWindowImpl
Usage mode As-is splitter window.
Aliases CSplitterWindow (vertical splitter), CHorSplitterWindow (horizontal splitter)

Methods

    DECLARE_WND_CLASS_EX(_T("WTL_SplitterWindow"), CS_DBLCLKS, COLOR_WINDOW)

Data Members

    (none)

Printing Support

CPrinterInfo<>

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode As-is wrapper class

Methods

public:
    CPrinterInfo()
    CPrinterInfo(HANDLE hPrinter)
    ~CPrinterInfo()
Operations
    bool GetPrinterInfo(HANDLE hPrinter)
Implementation
    void Cleanup()
    static bool GetPrinterInfoHelper(HANDLE hPrinter, BYTE** pi, int nIndex)

Data Members

public:
    _printer_info::infotype* m_pi;

CPrinter

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client (wraps a handle to a printer)
Aliases CPrinter, CPrinterHandle

Methods

public:
    CPrinter(HANDLE hPrinter = NULL)
    ~CPrinter()
    operator HANDLE() const
Operations
    CPrinterT& operator=(HANDLE hPrinter)
    bool IsNull() const { return (m_hPrinter == NULL); }
    bool OpenPrinter(HANDLE hDevNames, const DEVMODE* pDevMode = NULL)
    bool OpenPrinter(LPCTSTR lpszPrinterName, const DEVMODE* pDevMode = NULL)
    bool OpenPrinter(LPCTSTR lpszPrinterName, PRINTER_DEFAULTS* pprintdefs)
    bool OpenDefaultPrinter(const DEVMODE* pDevMode = NULL)
    void ClosePrinter()
    bool PrinterProperties(HWND hWnd = NULL)
    HANDLE CopyToHDEVNAMES() const
    HDC CreatePrinterDC(const DEVMODE* pdm = NULL)
    HDC CreatePrinterIC(const DEVMODE* pdm = NULL)
    void Attach(HANDLE hPrinter)
    HANDLE Detach()

Data Members

public:
    HANDLE m_hPrinter;

CDevMode

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client (wraps DEVMODE)
Aliases CDevMode, CDevModeHandle

Methods

public:
    CDevMode(HANDLE hDevMode = NULL)
    ~CDevMode()
    operator HANDLE() const {return m_hDevMode;}
    operator DEVMODE*() const {return m_pDevMode;}
Operations
    CDevModeT& operator=(HANDLE hDevMode)
    void Attach(HANDLE hDevModeNew)
    HANDLE Detach()
    bool IsNull() const { return (m_hDevMode == NULL); }
    bool CopyFromPrinter(HANDLE hPrinter)
    bool CopyFromDEVMODE(const DEVMODE* pdm)
    bool CopyFromHDEVMODE(HANDLE hdm)
    HANDLE CopyToHDEVMODE()
    //If this devmode was for another printer, this will create a new devmode
    //based on the existing devmode, but retargeted at the new printer
    bool UpdateForNewPrinter(HANDLE hPrinter)
    bool DocumentProperties(HANDLE hPrinter, HWND hWnd = NULL)
Implementation
    void Cleanup()

Data Members

public:
    HANDLE m_hDevMode;
    DEVMODE* m_pDevMode;

CPrinterDC

Basics

Characteristic Value/description
Inherits from CDC
Usage mode Client (wraps a printer DC)

Methods

public:
    CPrinterDC()
    CPrinterDC(HANDLE hPrinter, const DEVMODE* pdm = NULL)
    ~CPrinterDC()

Data Members

    (none)

CPrintJobInfo

Basics

Characteristic Value/description
Inherits from IPrintJobInfo
Usage mode Client, but typically used as a multiple-inheritance base class for a view or document class.

Methods

public:
    virtual void BeginPrintJob(HDC /*hDC*/) //allocate handles needed, etc
    virtual void EndPrintJob(HDC /*hDC*/, bool /*bAborted*/)    // free handles, etc
    virtual void PrePrintPage(UINT /*nPage*/, HDC hDC)
    virtual bool PrintPage(UINT /*nPage*/, HDC /*hDC*/) = 0;
    virtual void PostPrintPage(UINT /*nPage*/, HDC hDC)
    virtual DEVMODE* GetNewDevModeForPage(UINT /*nLastPage*/, UINT /*nPage*/)
    virtual bool IsValidPage(UINT /*nPage*/)

Data Members

private:
    int m_nPJState;

CPrintJob

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Client

Methods

public:
    CPrintJob()
    ~CPrintJob()
    bool IsJobComplete() const { return m_bComplete; }
    bool StartPrintJob(bool bBackground, HANDLE hPrinter, DEVMODE* pDefaultDevMode,
        IPrintJobInfo* pInfo, LPCTSTR lpszDocName, 
        unsigned long nStartPage, unsigned long nEndPage)
Implementation
    static DWORD WINAPI StartProc(void* p)
    bool StartHelper()
    //Cancels a print job.  Can be called asynchronously.
    bool CancelPrintJob()

Data Members

public:
    CPrinterHandle m_printer;
    IPrintJobInfo* m_pInfo;
    DEVMODE* m_pDefDevMode;
    DOCINFO m_docinfo;
    DWORD m_dwJobID;
    bool m_bCancel;
    bool m_bComplete;
    unsigned long m_nStartPage;
    unsigned long m_nEndPage;

CPrintPreview

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class

Methods

public:
    CPrintPreview()
Operations
    void SetPrintPreviewInfo(HANDLE hPrinter, DEVMODE* pDefaultDevMode, IPrintJobInfo* pji)
    void SetEnhMetaFile(HENHMETAFILE hEMF)
    void SetPage(int nPage)
    void GetPageRect(RECT& rc, LPRECT prc)
Painting helper
    void DoPaint(CDCHandle dc, RECT& rc)

Data Members

public:
    IPrintJobInfo* m_pInfo;
    CPrinterHandle m_printer;
    CEnhMetaFile m_meta;
    DEVMODE* m_pDefDevMode;
    DEVMODE* m_pCurDevMode;
    SIZE m_sizeCurPhysOffset;
    int m_nCurPage;

CPrintPreviewWindowImpl

Basics

Characteristic Value/description
Inherits from CWindowImpl<>, CPrintPreview
Usage mode Implementation (often you'd use CPrintPreviewWindow)

Methods

public:
    CPrintPreviewWindowImpl()
Operations
    void SetPrintPreviewInfo(HANDLE hPrinter, DEVMODE* pDefaultDevMode, 
        IPrintJobInfo* pji, int nMinPage, int nMaxPage)
    bool NextPage()
    bool PrevPage()

Message Map and Handlers

    DECLARE_WND_CLASS_EX(NULL, CS_VREDRAW | CS_HREDRAW, -1)

    BEGIN_MSG_MAP(CPrintPreviewWindowImpl)
        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
    END_MSG_MAP()

    LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

Data Members

public:
    int m_nMinPage;
    int m_nMaxPage;

CPrintPreviewWindow

Basics

Characteristic Value/description
Inherits from CWindowImpl<>, CPrintPreviewWindowImpl
Usage mode As-is for simple usage

Methods

public:
    CPrintPreviewWindow()

    DECLARE_WND_CLASS_EX(_T("WTL_PrintPreview"), CS_VREDRAW | CS_HREDRAW, -1)

Data Members

    (none)

Miscellaneous

CSize

Basics

Characteristic Value/description
Inherits from struct tagSIZE
Usage mode As-is

Methods

public:
    CSize();
    CSize(int initCX, int initCY);
    CSize(SIZE initSize);
    CSize(POINT initPt);
    CSize(DWORD dwSize);
Operations
    BOOL operator==(SIZE size) const;
    BOOL operator!=(SIZE size) const;
    void operator+=(SIZE size);
    void operator-=(SIZE size);
    void SetSize(int CX, int CY);
Operators returning CSize values
    CSize operator+(SIZE size) const;
    CSize operator-(SIZE size) const;
    CSize operator-() const;
Operators returning CPoint values
    CPoint operator+(POINT point) const;
    CPoint operator-(POINT point) const;
Operators returning CRect values
    CRect operator+(const RECT* lpRect) const;
    CRect operator-(const RECT* lpRect) const;

Methods Inherited from tagSIZE

    (none)

Data Members

    (none)

Data Members Inherited from tagSIZE

public:
    LONG cx;
    LONG cy;

CPoint

Basics

Characteristic Value/description
Inherits from class tagPOINT
Usage mode As-is

Methods

public:
    CPoint();
    CPoint(int initX, int initY);
    CPoint(POINT initPt);
    CPoint(SIZE initSize);
    CPoint(DWORD dwPoint);
Operations
    void Offset(int xOffset, int yOffset);
    void Offset(POINT point);
    void Offset(SIZE size);
    BOOL operator==(POINT point) const;
    BOOL operator!=(POINT point) const;
    void operator+=(SIZE size);
    void operator-=(SIZE size);
    void operator+=(POINT point);
    void operator-=(POINT point);
    void SetPoint(int X, int Y);
Operators returning CPoint values
    CPoint operator+(SIZE size) const;
    CPoint operator-(SIZE size) const;
    CPoint operator-() const;
    CPoint operator+(POINT point) const;
Operators returning CSize values
    CSize operator-(POINT point) const;
Operators returning CRect values
    CRect operator+(const RECT* lpRect) const;
    CRect operator-(const RECT* lpRect) const;

Methods Inherited from tagPOINT

    (none)

Data Members

    (none)

Data Members Inherited from tagPOINT

public:
    LONG x;
    LONG y;

CRect

Basics

Characteristic Value/description
Inherits from struct tagRECT
Usage mode mi_impl_asis_helper_base

Methods

public:
    CRect();
    CRect(int l, int t, int r, int b);
    CRect(const RECT& srcRect);
    CRect(LPCRECT lpSrcRect);
    CRect(POINT point, SIZE size);
    CRect(POINT topLeft, POINT bottomRight);
Attributes (in addition to RECT members)
    int Width() const;
    int Height() const;
    CSize Size() const;
    CPoint& TopLeft();
    CPoint& BottomRight();
    const CPoint& TopLeft() const;
    const CPoint& BottomRight() const;
    CPoint CenterPoint() const;

    // convert between CRect and LPRECT/LPCRECT (no need for &)
    operator LPRECT();
    operator LPCRECT() const;

    BOOL IsRectEmpty() const;
    BOOL IsRectNull() const;
    BOOL PtInRect(POINT point) const;
Operations
    void SetRect(int x1, int y1, int x2, int y2);
    void SetRect(POINT topLeft, POINT bottomRight);
    void SetRectEmpty();
    void CopyRect(LPCRECT lpSrcRect);
    BOOL EqualRect(LPCRECT lpRect) const;
    void InflateRect(int x, int y);
    void InflateRect(SIZE size);
    void InflateRect(LPCRECT lpRect);
    void InflateRect(int l, int t, int r, int b);
    void DeflateRect(int x, int y);
    void DeflateRect(SIZE size);
    void DeflateRect(LPCRECT lpRect);
    void DeflateRect(int l, int t, int r, int b);
    void OffsetRect(int x, int y);
    void OffsetRect(SIZE size);
    void OffsetRect(POINT point);
    void NormalizeRect();

    // absolute position of rectangle
    void MoveToY(int y);
    void MoveToX(int x);
    void MoveToXY(int x, int y);
    void MoveToXY(POINT point);

    // operations that fill '*this' with result
    BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2);
    BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2);
    BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2);
Additional Operations
    void operator=(const RECT& srcRect);
    BOOL operator==(const RECT& rect) const;
    BOOL operator!=(const RECT& rect) const;
    void operator+=(POINT point);
    void operator+=(SIZE size);
    void operator+=(LPCRECT lpRect);
    void operator-=(POINT point);
    void operator-=(SIZE size);
    void operator-=(LPCRECT lpRect);
    void operator&=(const RECT& rect);
    void operator|=(const RECT& rect);
Operators returning CRect values
    CRect operator+(POINT point) const;
    CRect operator-(POINT point) const;
    CRect operator+(LPCRECT lpRect) const;
    CRect operator+(SIZE size) const;
    CRect operator-(SIZE size) const;
    CRect operator-(LPCRECT lpRect) const;
    CRect operator&(const RECT& rect2) const;
    CRect operator|(const RECT& rect2) const;
    CRect MulDiv(int nMultiplier, int nDivisor) const;

Methods Inherited from tagRECT

    (none)

Data Members

    (none)

Data Members Inherited from tagRECT

public:
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;

CString

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode As-is

Methods

public:
    CString();
    CString(const CString& stringSrc);
    CString(TCHAR ch, int nRepeat = 1);
    CString(LPCSTR lpsz);
    CString(LPCWSTR lpsz);
    CString(LPCTSTR lpch, int nLength);
    CString(const unsigned char* psz);
Attributes & Operations
    // as an array of characters
    int GetLength() const;
    BOOL IsEmpty() const;
    void Empty();                       // free up the data

    TCHAR GetAt(int nIndex) const;      // 0 based
    TCHAR operator[](int nIndex) const; // same as GetAt
    void SetAt(int nIndex, TCHAR ch);
    operator LPCTSTR() const;           // as a C string

    // overloaded assignment
    const CString& operator=(const CString& stringSrc);
    const CString& operator=(TCHAR ch);
    const CString& operator=(char ch);
    const CString& operator=(LPCSTR lpsz);
    const CString& operator=(LPCWSTR lpsz);
    const CString& operator=(const unsigned char* psz);

    // string concatenation
    const CString& operator+=(const CString& string);
    const CString& operator+=(TCHAR ch);
    const CString& operator+=(char ch);
    const CString& operator+=(LPCTSTR lpsz);
    friend CString __stdcall operator+(const CString& string1, const CString& string2);
    friend CString __stdcall operator+(const CString& string, TCHAR ch);
    friend CString __stdcall operator+(TCHAR ch, const CString& string);
    friend CString __stdcall operator+(const CString& string, char ch);
    friend CString __stdcall operator+(char ch, const CString& string);
    friend CString __stdcall operator+(const CString& string, LPCTSTR lpsz);
    friend CString __stdcall operator+(LPCTSTR lpsz, const CString& string);

    // string comparison
    int Compare(LPCTSTR lpsz) const;         // straight character
    int CompareNoCase(LPCTSTR lpsz) const;   // ignore case
    int Collate(LPCTSTR lpsz) const;         // NLS aware

    // simple sub-string extraction
    CString Mid(int nFirst, int nCount) const;
    CString Mid(int nFirst) const;
    CString Left(int nCount) const;
    CString Right(int nCount) const;
    CString SpanIncluding(LPCTSTR lpszCharSet) const;
    CString SpanExcluding(LPCTSTR lpszCharSet) const;

    // upper/lower/reverse conversion
    void MakeUpper();
    void MakeLower();
    void MakeReverse();

    // trimming whitespace (either side)
    void TrimRight();
    void TrimLeft();
Advanced manipulation
    // replace occurrences of chOld with chNew
    int Replace(TCHAR chOld, TCHAR chNew);

    // replace occurrences of substring lpszOld with lpszNew;
    // empty lpszNew removes instances of lpszOld
    int Replace(LPCTSTR lpszOld, LPCTSTR lpszNew);

    // remove occurrences of chRemove
    int Remove(TCHAR chRemove);

    // insert character at zero-based index; concatenates
    // if index is past end of string
    int Insert(int nIndex, TCHAR ch);

    // insert substring at zero-based index; concatenates
    // if index is past end of string
    int Insert(int nIndex, LPCTSTR pstr);

    // delete nCount characters starting at zero-based index
    int Delete(int nIndex, int nCount = 1);
Searching (return starting index, or -1 if not found)
    // look for a single character match
    int Find(TCHAR ch) const;               // like "C" strchr
    int ReverseFind(TCHAR ch) const;
    int FindOneOf(LPCTSTR lpszCharSet) const;

    // look for a specific sub-string
    int Find(LPCTSTR lpszSub) const;        // like "C" strstr

    // Concatentation for non strings
    const CString& Append(int n)

    // simple formatting
    void __cdecl Format(LPCTSTR lpszFormat, ...);
    void __cdecl Format(UINT nFormatID, ...);

    // formatting for localization (uses FormatMessage API)
    BOOL __cdecl FormatMessage(LPCTSTR lpszFormat, ...);
    BOOL __cdecl FormatMessage(UINT nFormatID, ...);
    BOOL LoadString(UINT nID);          // load from string resource
Other operations
    // ANSI <-> OEM support (convert string in place)
    void AnsiToOem();
    void OemToAnsi();

    // OLE BSTR support (use for OLE automation)
    BSTR AllocSysString() const;
    BSTR SetSysString(BSTR* pbstr) const;

    // Access to string implementation buffer as "C" character array
    LPTSTR GetBuffer(int nMinBufLength);
    void ReleaseBuffer(int nNewLength = -1);
    LPTSTR GetBufferSetLength(int nNewLength);
    void FreeExtra();

    // Use LockBuffer/UnlockBuffer to turn refcounting off
    LPTSTR LockBuffer();
    void UnlockBuffer();

Data Members

    (no public data members)

CWinDataExchange

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Multiple-inheritance base class

Methods

public:
Data exchange method - override in your derived class
    BOOL DoDataExchange(BOOL /*bSaveAndValidate*/ = FALSE, UINT /*nCtlID*/ = (UINT)-1)
Text exchange
    BOOL DDX_Text(UINT nID, LPTSTR lpstrText, int nSize, BOOL bSave,
        BOOL bValidate = FALSE, int nLength = 0)
    BOOL DDX_Text(UINT nID, BSTR& bstrText, int /*nSize*/, BOOL bSave,
        BOOL bValidate = FALSE, int nLength = 0)
    BOOL DDX_Text(UINT nID, CComBSTR& bstrText, int /*nSize*/, BOOL bSave,
        BOOL bValidate = FALSE, int nLength = 0)
    BOOL DDX_Text(UINT nID, CString& strText, int /*nSize*/, BOOL bSave,
        BOOL bValidate = FALSE, int nLength = 0)
    template  BOOL DDX_Int(UINT nID, Type& nVal, BOOL bSigned, BOOL bSave,
        BOOL bValidate = FALSE, Type nMin = 0, Type nMax = 0)
    static BOOL _AtlSimpleFloatParse(LPCTSTR lpszText, double& d)
    BOOL DDX_Float(UINT nID, float& nVal, BOOL bSave, BOOL bValidate = FALSE,
        float nMin = 0.F, float nMax = 0.F)
    BOOL DDX_Float(UINT nID, double& nVal, BOOL bSave, BOOL bValidate = FALSE,
        double nMin = 0., double nMax = 0.)
Control subclassing
    template  void DDX_Control(UINT nID, TControl& ctrl, BOOL bSave)
Control state
    void DDX_Check(UINT nID, int& nValue, BOOL bSave)
    void DDX_Radio(UINT nID, int& nValue, BOOL bSave)
Overrideables
    void OnDataExchangeError(UINT nCtrlID, BOOL /*bSave*/)
    void OnDataValidateError(UINT nCtrlID, BOOL /*bSave*/, _XData& /*data*/)

Data Members

    (none)

CRecentDocumentListBase

Basics

Characteristic Value/description
Inherits from (nothing)
Usage mode Base class (normally you use a CRecentDocumentList)

Methods

public:
    CRecentDocumentListBase()
Attributes
    HMENU GetMenuHandle() const
    void SetMenuHandle(HMENU hMenu)
    int GetMaxEntries() const
    void SetMaxEntries(int nMaxEntries)
    int GetMaxItemLength() const
    void SetMaxItemLength(int cchMaxLen)
Operations
    BOOL AddToList(LPCTSTR lpstrDocName)
    BOOL GetFromList(int nItemID, LPTSTR lpstrDocName)
    BOOL RemoveFromList(int nItemID)
    BOOL MoveToTop(int nItemID)
    BOOL ReadFromRegistry(LPCTSTR lpstrRegKey)
    BOOL WriteToRegistry(LPCTSTR lpstrRegKey)
Implementation
    BOOL UpdateMenu()
Overrideable
    // override to provide a different method of compacting document names
    static bool CompactDocumentName(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen)

Data Members

public:
    CSimpleArray<_DocEntry> m_arrDocs;
    int m_nMaxEntries;  // default is 4
    HMENU m_hMenu;
    TCHAR m_szNoEntries[t_cchItemLen];
    int m_cchMaxItemLen;

CRecentDocumentList<>

Basics

Characteristic Value/description
Inherits from CRecentDocumentListBase
Usage mode Multiple-inheritance base class or as-is

Methods

    (none)

Data Members

    (none)

Global Functions

WTL provides a set of global functions to provide additional type-safe access to system resources and other generally useful functions. Some (or even all) of these functions may have been intended for internal use within WTL, but they are nonetheless useful to all WTL programmers.

These functions reside in different WTL header files, which are given below.

Windows Version

Prototype inline bool AtlIsOldWindows()
Defined in atlapp.h

AtlIsOldWindows() returns a false if the current Windows version is Windows 2000, Windows Me, or greater. So the definition of "new" and "old" come down to this:

Windows Name New/Old Major Version Minor Version
Windows NT 3.51Old351
Windows 95Old40
Windows 98Old410
Windows MeNew490
Windows NT 4.0Old40
Windows 2000New50
Windows XPNew51

Typesafe GDI Stock Object Accessors

Prototype inline HFONT AtlGetDefaultGuiFont()
Defined in atlapp.h

AtlGetDefaultGuiFont() is a typesafe routine for accessing the stock font object DEFAULT_GUI_FONT.


Prototype inline HPEN AtlGetStockPen(int nPen)
Defined in atlmisc.h

AtlGetStockPen() is a typesafe routine for accessing stock pen objects such as BLACK_PEN.


Prototype inline HBRUSH AtlGetStockBrush(int nBrush)
Defined in atlmisc.h

AtlGetStockBrush() is a typesafe routine for accessing stock brush objects such as WHITE_BRUSH.


Prototype inline HFONT AtlGetStockFont(int nFont)
Defined in atlmisc.h

AtlGetStockFont() is a typesafe routine for accessing stock brush objects such as OEM_FIXED_FONT. If you want the Win32 default GUI font, you can use AtlGetDefaultGuiFont() instead.


Prototype inline HPALETTE AtlGetStockPalette(int nPalette)
Defined in atlmisc.h

AtlGetStockPalette() is a typesafe routine for accessing the stock palette object DEFAULT_PALETTE.

Typesafe Resource Loaders

Prototype inline HACCEL AtlLoadAccelerators(LPCTSTR table)
Prototype inline HACCEL AtlLoadAccelerators(long nID)
Defined in atlmisc.h

AtlLoadAccelerators() is a typesafe routine for loading accelerator tables. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HMENU AtlLoadMenu(LPCTSTR menu)
Prototype inline HMENU AtlLoadMenu(long nID)
Defined in atlmisc.h

AtlLoadMenu() is a typesafe routine for loading menu resources. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HBITMAP AtlLoadBitmap(LPCTSTR bitmap)
Prototype inline HBITMAP AtlLoadBitmap(long nID)
Defined in atlmisc.h

AtlLoadBitmap() is a typesafe routine for loading bitmap resources. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HBITMAP AtlLoadSysBitmap(LPCTSTR lpBitmapName)
Defined in atlmisc.h

AtlLoadSysBitmap() is a typesafe routine for loading system bitmap resources. It is only available if OEMRESOURCE is defined.


Prototype inline HCURSOR AtlLoadCursor(LPCTSTR cursor)
Prototype inline HCURSOR AtlLoadCursor(long nID)
Defined in atlmisc.h

AtlLoadCursor() is a typesafe routine for loading cursor resources. For standard cursors, use AtlLoadSysCursor(). AtlLoadCursor uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HCURSOR AtlLoadSysCursor(LPCTSTR bitmap)
Defined in atlmisc.h

AtlLoadSysCursor() is a typesafe routine for loading standard system cursors. This routine can be used to load IDC_ARROW, IDC_IBEAM, IDC_WAIT, IDC_CROSS, IDC_UPARROW, IDC_SIZE, IDC_ICON, IDC_SIZENWSE, IDC_SIZENESW, IDC_SIZEWE, IDC_SIZENS, IDC_SIZEALL, IDC_NO, IDC_APPSTARTING and IDC_HELP.


Prototype inline HICON AtlLoadIcon(LPCTSTR bitmap)
Prototype inline HICON AtlLoadIcon(long nID)
Defined in atlmisc.h

AtlLoadIcon() is a typesafe routine for loading icon resources. For standard icons use AtlLoadSysIcon(). AtlLoadIcon uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HICON AtlLoadSysIcon(LPCTSTR bitmap)
Defined in atlmisc.h

AtlLoadSysIcon() is a typesafe routine for loading standard system icons. This routine can be used to load IDI_APPLICATION, IDI_ASTERISK, IDI_EXCLAMATION, IDI_HAND, IDI_QUESTION, and IDI_WINLOGO.


Prototype inline HBITMAP AtlLoadBitmapImage(LPCTSTR bitmap, UINT fuLoad = LR_DEFAULTCOLOR)
Prototype inline HBITMAP AtlLoadBitmapImage(long nID, UINT fuLoad = LR_DEFAULTCOLOR)
Defined in atlmisc.h

AtlLoadBitmapImage() is a typesafe routine for loading bitmap image resources with the ::LoadBitmap Win32 API routine. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HCURSOR AtlLoadCursorImage(LPCTSTR bitmap, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Prototype inline HCURSOR AtlLoadCursorImage(long nID, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Defined in atlmisc.h

AtlLoadCursorImage() is a typesafe routine for loading cursor image resources with the ::LoadBitmap Win32 API routine. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HICON AtlLoadIconImage(LPCTSTR bitmap, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Prototype inline HICON AtlLoadIconImage(long nID, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Defined in atlmisc.h

AtlLoadIconImage() is a typesafe routine for loading icon image resources with the ::LoadBitmap Win32 API routine. It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HBITMAP AtlLoadSysBitmapImage(WORD wBitmapID, UINT fuLoad = LR_DEFAULTCOLOR)
Defined in atlmisc.h

AtlLoadSysBitmapImage() is a typesafe routine for loading non-file system bitmap images with the ::LoadBitmap Win32 API routine. (The ID range for such images is 32734 to 32767 inclusive.) AtlLoadSysBitmapImage is only available if OEMRESOURCE is defined.


Prototype inline HCURSOR AtlLoadSysCursorImage(LPCTSTR bitmap, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Prototype inline HCURSOR AtlLoadSysCursorImage(long nID, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Defined in atlmisc.h

AtlLoadSysCursorImage() is a typesafe routine for loading system cursor image resources with the ::LoadBitmap Win32 API routine. (The ID range for such images is 32512 to 32516 inclusive.) It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline HICON AtlLoadSysIconImage(LPCTSTR bitmap, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Prototype inline HICON AtlLoadSysIconImage(long nID, UINT fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, int cxDesired = 0, int cyDesired = 0)
Defined in atlmisc.h

AtlLoadSysIconImage() is a typesafe routine for loading system icon image resources with the ::LoadBitmap Win32 API routine. (The ID range for such images is 32512 to 32517 inclusive.) It uses a dual-accessor prototype (expanded here) that allows either strings or IDs to be specified.


Prototype inline int AtlLoadString(UINT uID, LPTSTR lpBuffer, int nBufferMax)
Prototype inline bool AtlLoadString(UINT uID, BSTR& bstrText)
Defined in atlmisc.h

AtlLoadString() is a typesafe routine for loading string resources. There are two variations, one that writes in to string buffer, another that writes to a BSTR.

Miscellaneous

Prototype inline bool AtlCompactPath(LPTSTR lpstrOut, LPCTSTR lpstrIn, int cchLen)
Defined in atlmisc.h

AtlCompactPath() is a function for compacting paths by replacing parts (in the middle) with ellipses. It makes the path fit in cchLen characters, and always preserves the filename at the end of the string. WTL's CRecentDocumentList class but is generally useful.


File Packing List


readme.txt      this file

include\
    atlapp.h    message loop, interfaces, general app stuff
    atlcrack.h  message cracker macros
    atlctrls.h  standard and common control classes
    atlctrlw.h  command bar class
    atlctrlx.h  bitmap button, check list view, and other controls
    atlddx.h    data exchange for dialogs and windows
    atldlgs.h   common dialog classes, property sheet and page classes
    atlframe.h  frame window classes, MDI, update UI classes
    atlgdi.h    DC classes, GDI object classes
    atlmisc.h   ATL ports of CPoint, CRect, CSize, CString, etc.
    atlprint.h  printing and print preview
    atlres.h    standard resource IDs
    atlscrl.h   scrollable windows
    atlsplit.h  splitter windows
    atluser.h   menu class

samples\
    BmpView\    bitmap file view sample
    MTPad\      multithreaded notepad sample
    MDIDocVw\   ATL version of the MDI sample
    GuidGen\    ATL version of the GuidGen sample

appwiz\
    atlapp60.awx    ATL/WTL AppWizard

To Do

Here's a list of stuff I want to add/fix/change, in no particular order. Contributions are welcomed! If you think you'd like to contribute, please email me with what you're planning to do so we don't duplicate effort.


Document History

VersionDateDescription
1.0.012/5/01 Initial public release
1.0.112/6/01 Fix some stray initializers on constructors, added document version under the initial head, changed the document title to be easier to grok in a full taskbar. Added the to do list.
1.0.212/7/01 Fixed some sprurious references to CxxxT() to not have the "T" which I remove by convention. Exposed this Document History and the To Do list so people can see what's on my list (and know what I need should they decide to contribute. Added the width bar to the top of the document.
1.0.312/17/01 Added some missing methods to controls in the Standard Controls section. Fixed some minor problems with CString's docs. Removed the #ifs from CAppModule, which I delete by convention. Fixed the syntax of my anchors (thanks Jalal).
1.0.412/18/01 Added Usage Notes for CHyperLink.
1.0.512/22/01 Added the new Global Functions section. Added Usage Notes for CMessageFilter.
1.0.66/11/02 Moved the "Optimum width for this document" table into the body where it belonged in the first place.

Credits

This document was compiled from the WTL 3.1 readme.txt document and from the WTL and ATL headers themselves. The real credit goes to those who implemented WTL.

This quick-reference compilation was created by Bryan K. Ressler (bressler@pallium.com).

The latest version can always be found online at http://www.pallium.com/wtl.

Please email any questions, comments, broken links, ideas, or feedback to me at bressler@pallium.com.

Thanks to Eamon O'Tuathail and the folks at clipcode.com for turning me on to WTL and inspiring this work in the first place.