class CWnd : public CCmdTarget
{
DECLARE_DYNCREATE(CWnd)
protected:
static const MSG* PASCAL GetCurrentMessage();
// Attributes
public:
HWND m_hWnd; // must be first data member
operator HWND() const;
BOOL operator==(const CWnd& wnd) const;
BOOL operator!=(const CWnd& wnd) const;
HWND GetSafeHwnd() const;
DWORD GetStyle() const;
DWORD GetExStyle() const;
BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
CWnd* GetOwner() const;
void SetOwner(CWnd* pOwnerWnd);
#if(WINVER >= 0x0500)
BOOL GetWindowInfo(PWINDOWINFO pwi) const;
BOOL GetTitleBarInfo(PTITLEBARINFO pti) const;
#endif // WINVER >= 0x0500
// Constructors and other creation
CWnd();
static CWnd* PASCAL FromHandle(HWND hWnd);
static CWnd* PASCAL FromHandlePermanent(HWND hWnd);
static void PASCAL DeleteTempMap();
BOOL Attach(HWND hWndNew);
HWND Detach();
// subclassing/unsubclassing functions
virtual void PreSubclassWindow();
BOOL SubclassWindow(HWND hWnd);
BOOL SubclassDlgItem(UINT nID, CWnd* pParent);
HWND UnsubclassWindow();
// handling of RT_DLGINIT resource (extension to RT_DIALOG)
BOOL ExecuteDlgInit(LPCTSTR lpszResourceName);
BOOL ExecuteDlgInit(LPVOID lpResource);
public:
// for child windows, views, panes etc
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL);
// advanced creation (allows access to extended styles)
virtual BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
int x, int y, int nWidth, int nHeight,
HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL);
virtual BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
LPVOID lpParam = NULL);
#ifndef _AFX_NO_OCC_SUPPORT
// for wrapping OLE controls
BOOL CreateControl(REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
BOOL CreateControl(LPCTSTR pszClass, LPCTSTR pszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
// Another overload for creating controls that use default extents.
BOOL CreateControl( REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
const POINT* ppt, const SIZE* psize, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );
//Overload for special controls (WinForms), that require more than CLSID.
BOOL CreateControl(const CControlCreationInfo& creationInfo, DWORD dwStyle,
const POINT* ppt, const SIZE* psize, CWnd* pParentWnd, UINT nID);
LPUNKNOWN GetControlUnknown();
BOOL PaintWindowlessControls(CDC *pDC);
#endif
virtual BOOL DestroyWindow();
// special pre-creation and window rect adjustment hooks
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// Advanced: virtual AdjustWindowRect
enum AdjustType { adjustBorder = 0, adjustOutside = 1 };
virtual void CalcWindowRect(LPRECT lpClientRect,
UINT nAdjustType = adjustBorder);
// Window tree access
int GetDlgCtrlID() const;
int SetDlgCtrlID(int nID);
// get and set window ID, for child windows only
CWnd* GetDlgItem(int nID) const;
// get immediate child with given ID
void GetDlgItem(int nID, HWND* phWnd) const;
// as above, but returns HWND
CWnd* GetDescendantWindow(int nID, BOOL bOnlyPerm = FALSE) const;
// like GetDlgItem but recursive
void SendMessageToDescendants(UINT message, WPARAM wParam = 0,
LPARAM lParam = 0, BOOL bDeep = TRUE, BOOL bOnlyPerm = FALSE);
CFrameWnd* GetParentFrame() const;
CFrameWnd* EnsureParentFrame() const;
CWnd* GetTopLevelParent() const;
CWnd* EnsureTopLevelParent() const;
CWnd* GetTopLevelOwner() const;
CWnd* GetParentOwner() const;
CFrameWnd* GetTopLevelFrame() const;
static CWnd* PASCAL GetSafeOwner(CWnd* pParent = NULL, HWND* pWndTop = NULL);
#if(WINVER >= 0x0500)
CWnd* GetAncestor(UINT gaFlags) const;
#endif // WINVER >= 0x0500
// Message Functions
#pragma push_macro("SendMessage")
#undef SendMessage
LRESULT _AFX_FUNCNAME(SendMessage)(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
#pragma pop_macro("SendMessage")
BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
BOOL SendNotifyMessage(UINT message, WPARAM wParam, LPARAM lParam);
BOOL SendChildNotifyLastMsg(LRESULT* pResult = NULL);
BOOL DragDetect(POINT pt) const;
// Message processing for modeless dialog-like windows
BOOL IsDialogMessage(LPMSG lpMsg);
// Window Text Functions
void SetWindowText(LPCTSTR lpszString);
int GetWindowText(__out_ecount_part_z(nMaxCount, return + 1) LPTSTR lpszStringBuf, __in int nMaxCount) const;
void GetWindowText(CString& rString) const;
int GetWindowTextLength() const;
void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
CFont* GetFont() const;
// CMenu Functions - non-Child windows only
CMenu* GetMenu() const;
BOOL SetMenu(CMenu* pMenu);
void DrawMenuBar();
CMenu* GetSystemMenu(BOOL bRevert) const;
BOOL HiliteMenuItem(CMenu* pMenu, UINT nIDHiliteItem, UINT nHilite);
#if(WINVER >= 0x0500)
BOOL GetMenuBarInfo(LONG idObject, LONG idItem, PMENUBARINFO pmbi) const;
#endif // WINVER >= 0x0500
// Window Size and Position Functions
BOOL IsIconic() const;
BOOL IsZoomed() const;
void MoveWindow(int x, int y, int nWidth, int nHeight,
BOOL bRepaint = TRUE);
void MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE);
int SetWindowRgn(HRGN hRgn, BOOL bRedraw);
int GetWindowRgn(HRGN hRgn) const;
static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter
BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
int cx, int cy, UINT nFlags);
UINT ArrangeIconicWindows();
void BringWindowToTop();
void GetWindowRect(LPRECT lpRect) const;
void GetClientRect(LPRECT lpRect) const;
BOOL GetWindowPlacement(WINDOWPLACEMENT* lpwndpl) const;
BOOL SetWindowPlacement(const WINDOWPLACEMENT* lpwndpl);
// Coordinate Mapping Functions
void ClientToScreen(LPPOINT lpPoint) const;
void ClientToScreen(LPRECT lpRect) const;
void ScreenToClient(LPPOINT lpPoint) const;
void ScreenToClient(LPRECT lpRect) const;
void MapWindowPoints(CWnd* pwndTo, LPPOINT lpPoint, UINT nCount) const;
void MapWindowPoints(CWnd* pwndTo, LPRECT lpRect) const;
// Update/Painting Functions
CDC* BeginPaint(LPPAINTSTRUCT lpPaint);
void EndPaint(LPPAINTSTRUCT lpPaint);
CDC* GetDC();
CDC* GetWindowDC();
int ReleaseDC(CDC* pDC);
void Print(CDC* pDC, DWORD dwFlags) const;
void PrintClient(CDC* pDC, DWORD dwFlags) const;
void UpdateWindow();
void SetRedraw(BOOL bRedraw = TRUE);
BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE);
int GetUpdateRgn(CRgn* pRgn, BOOL bErase = FALSE);
void Invalidate(BOOL bErase = TRUE);
void InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE);
void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
void ValidateRect(LPCRECT lpRect);
void ValidateRgn(CRgn* pRgn);
BOOL ShowWindow(int nCmdShow);
BOOL IsWindowVisible() const;
void ShowOwnedPopups(BOOL bShow = TRUE);
CDC* GetDCEx(CRgn* prgnClip, DWORD flags);
BOOL LockWindowUpdate();
void UnlockWindowUpdate();
BOOL RedrawWindow(LPCRECT lpRectUpdate = NULL,
CRgn* prgnUpdate = NULL,
UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH);
BOOL DrawAnimatedRects(int idAni, CONST RECT *lprcFrom, CONST RECT *lprcTo);
BOOL DrawCaption(CDC* pDC, LPCRECT lprc, UINT uFlags);
#if(WINVER >= 0x0500)
BOOL AnimateWindow(DWORD dwTime, DWORD dwFlags);
#endif // WINVER >= 0x0500
#if(_WIN32_WINNT >= 0x0501)
BOOL PrintWindow(CDC* pDC, UINT nFlags) const;
#endif // _WIN32_WINNT >= 0x0501
// Layered Window
#if(_WIN32_WINNT >= 0x0500)
BOOL SetLayeredWindowAttributes(COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
BOOL UpdateLayeredWindow(CDC* pDCDst, POINT *pptDst, SIZE *psize,
CDC* pDCSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
#endif // _WIN32_WINNT >= 0x0500
#if(_WIN32_WINNT >= 0x0501)
BOOL GetLayeredWindowAttributes(COLORREF *pcrKey, BYTE *pbAlpha, DWORD *pdwFlags) const;
#endif // _WIN32_WINNT >= 0x0501
// Timer Functions
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse,
void (CALLBACK* lpfnTimer)(HWND, UINT, UINT_PTR, DWORD));
BOOL KillTimer(UINT_PTR nIDEvent);
// ToolTip Functions
BOOL EnableToolTips(BOOL bEnable = TRUE);
BOOL EnableTrackingToolTips(BOOL bEnable = TRUE);
static void PASCAL CancelToolTips(BOOL bKeys = FALSE);
void FilterToolTipMessage(MSG* pMsg);
// for command hit testing (used for automatic tooltips)
virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
// Window State Functions
BOOL IsWindowEnabled() const;
BOOL EnableWindow(BOOL bEnable = TRUE);
// the active window applies only to top-level (frame windows)
static CWnd* PASCAL GetActiveWindow();
CWnd* SetActiveWindow();
// the foreground window applies only to top-level windows (frame windows)
BOOL SetForegroundWindow();
static CWnd* PASCAL GetForegroundWindow();
// capture and focus apply to all windows
static CWnd* PASCAL GetCapture();
CWnd* SetCapture();
static CWnd* PASCAL GetFocus();
CWnd* SetFocus();
static CWnd* PASCAL GetDesktopWindow();
// Obsolete and non-portable APIs - not recommended for new code
void CloseWindow();
BOOL OpenIcon();
// Dialog-Box Item Functions
// (NOTE: Dialog-Box Items/Controls are not necessarily in dialog boxes!)
void CheckDlgButton(int nIDButton, UINT nCheck);
void CheckRadioButton(int nIDFirstButton, int nIDLastButton,
int nIDCheckButton);
int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton);
int DlgDirList(__inout_z LPTSTR lpPathSpec, __in int nIDListBox,
__in int nIDStaticPath, __in UINT nFileType);
int DlgDirListComboBox(__inout_z LPTSTR lpPathSpec, __in int nIDComboBox,
__in int nIDStaticPath, __in UINT nFileType);
AFX_DEPRECATED("CWnd::DlgDirSelect(lpszOut, nControlId) is no longer supported. Instead, use CWnd::DlgDirSelect(lpszOut, nSize, nControlId)")
BOOL DlgDirSelect(__out_ecount_z(_MAX_PATH) LPTSTR lpString, __in int nIDListBox);
BOOL DlgDirSelect(__out_ecount_z(nSize) LPTSTR lpString, __in int nSize, __in int nIDListBox);
AFX_DEPRECATED("CWnd::DlgDirSelectComboBox(lpszOut, nControlId) is no longer supported. Instead, use CWnd::DlgDirSelectComboBox(lpszOut, nSize, nControlId)")
BOOL DlgDirSelectComboBox(__out_ecount_z(_MAX_PATH) LPTSTR lpString, __in int nIDComboBox);
BOOL DlgDirSelectComboBox(__out_ecount_z(nSize) LPTSTR lpString, __in int nSize, __in int nIDComboBox);
UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL,
BOOL bSigned = TRUE) const;
int GetDlgItemText(__in int nID, __out_ecount_part_z(nMaxCount, return + 1) LPTSTR lpStr, __in int nMaxCount) const;
int GetDlgItemText(int nID, CString& rString) const;
CWnd* GetNextDlgGroupItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
COleControlSiteOrWnd* GetNextDlgGroupItem(COleControlSiteOrWnd *pCurSiteOrWnd = NULL) const;
COleControlSiteOrWnd* GetPrevDlgGroupItem(COleControlSiteOrWnd *pCurSiteOrWnd = NULL) const;
void RemoveRadioCheckFromGroup(const COleControlSiteOrWnd *pSiteOrWnd) const;
CWnd* GetNextDlgTabItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
COleControlSiteOrWnd* GetNextDlgTabItem(COleControlSiteOrWnd *pCurSiteOrWnd, BOOL bPrevious) const;
UINT IsDlgButtonChecked(int nIDButton) const;
LRESULT SendDlgItemMessage(int nID, UINT message,
WPARAM wParam = 0, LPARAM lParam = 0);
void SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE);
void SetDlgItemText(int nID, LPCTSTR lpszString);
POSITION FindSiteOrWnd(const COleControlSiteOrWnd *pSiteOrWnd) const;
POSITION FindSiteOrWndWithFocus() const;
// Scrolling Functions
int GetScrollPos(int nBar) const;
void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const;
void ScrollWindow(int xAmount, int yAmount,
LPCRECT lpRect = NULL,
LPCRECT lpClipRect = NULL);
int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
void SetScrollRange(int nBar, int nMinPos, int nMaxPos,
BOOL bRedraw = TRUE);
void ShowScrollBar(UINT nBar, BOOL bShow = TRUE);
void EnableScrollBarCtrl(int nBar, BOOL bEnable = TRUE);
virtual CScrollBar* GetScrollBarCtrl(int nBar) const;
// return sibling scrollbar control (or NULL if none)
int ScrollWindowEx(int dx, int dy,
LPCRECT lpRectScroll, LPCRECT lpRectClip,
CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags);
BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo,
BOOL bRedraw = TRUE);
BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL);
int GetScrollLimit(int nBar);
#if(WINVER >= 0x0500)
BOOL GetScrollBarInfo(LONG idObject, PSCROLLBARINFO psbi) const;
#endif // WINVER >= 0x0500
// Window Access Functions
CWnd* ChildWindowFromPoint(POINT point) const;
CWnd* ChildWindowFromPoint(POINT point, UINT nFlags) const;
static CWnd* PASCAL FindWindow(LPCTSTR lpszClassName, LPCTSTR lpszWindowName);
static CWnd* FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPCTSTR lpszClass, LPCTSTR lpszWindow);
CWnd* GetNextWindow(UINT nFlag = GW_HWNDNEXT) const;
CWnd* GetTopWindow() const;
CWnd* GetWindow(UINT nCmd) const;
CWnd* GetLastActivePopup() const;
BOOL IsChild(const CWnd* pWnd) const;
CWnd* GetParent() const;
CWnd* SetParent(CWnd* pWndNewParent);
static CWnd* PASCAL WindowFromPoint(POINT point);
// Alert Functions
BOOL FlashWindow(BOOL bInvert);
#pragma push_macro("MessageBox")
#undef MessageBox
int _AFX_FUNCNAME(MessageBox)(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
UINT nType = MB_OK);
int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
UINT nType = MB_OK);
#pragma pop_macro("MessageBox")
#if(WINVER >= 0x0500)
BOOL FlashWindowEx(DWORD dwFlags, UINT uCount, DWORD dwTimeout);
#endif // WINVER >= 0x0500
// Clipboard Functions
BOOL ChangeClipboardChain(HWND hWndNext);
HWND SetClipboardViewer();
BOOL OpenClipboard();
static CWnd* PASCAL GetClipboardOwner();
static CWnd* PASCAL GetClipboardViewer();
static CWnd* PASCAL GetOpenClipboardWindow();
// Caret Functions
void CreateCaret(CBitmap* pBitmap);
void CreateSolidCaret(int nWidth, int nHeight);
void CreateGrayCaret(int nWidth, int nHeight);
static CPoint PASCAL GetCaretPos();
static void PASCAL SetCaretPos(POINT point);
void HideCaret();
void ShowCaret();
// Shell Interaction Functions
void DragAcceptFiles(BOOL bAccept = TRUE);
// Icon Functions
HICON SetIcon(HICON hIcon, BOOL bBigIcon);
HICON GetIcon(BOOL bBigIcon) const;
// Context Help Functions
BOOL SetWindowContextHelpId(DWORD dwContextHelpId);
DWORD GetWindowContextHelpId() const;
// Dialog Data support
public:
BOOL UpdateData(BOOL bSaveAndValidate = TRUE);
// data wnd must be same type as this
// Help Command Handlers
afx_msg void OnHelp(); // F1 (uses current context)
afx_msg void OnHelpIndex(); // ID_HELP_INDEX
afx_msg void OnHelpFinder(); // ID_HELP_FINDER, ID_DEFAULT_HELP
afx_msg void OnHelpUsing(); // ID_HELP_USING
virtual void WinHelp(DWORD_PTR dwData, UINT nCmd = HELP_CONTEXT);
virtual void HtmlHelp(DWORD_PTR dwData, UINT nCmd = 0x000F);
virtual void WinHelpInternal(DWORD_PTR dwData, UINT nCmd = HELP_CONTEXT);
// Layout and other functions
public:
enum RepositionFlags
{ reposDefault = 0, reposQuery = 1, reposExtra = 2, reposNoPosLeftOver=0x8000 };
void RepositionBars(UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver,
UINT nFlag = reposDefault, LPRECT lpRectParam = NULL,
LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE);
// dialog support
void UpdateDialogControls(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
void CenterWindow(CWnd* pAlternateOwner = NULL);
int RunModalLoop(DWORD dwFlags = 0);
virtual BOOL ContinueModal();
virtual void EndModalLoop(int nResult);
#ifndef _AFX_NO_OCC_SUPPORT
// OLE control wrapper functions
COleControlSite* GetOleControlSite(UINT idControl) const;
void AFX_CDECL InvokeHelper(DISPID dwDispID, WORD wFlags,
VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);
void AFX_CDECL SetProperty(DISPID dwDispID, VARTYPE vtProp, ...);
void GetProperty(DISPID dwDispID, VARTYPE vtProp, void* pvProp) const;
IUnknown* GetDSCCursor();
void BindDefaultProperty(DISPID dwDispID, VARTYPE vtProp, LPCTSTR szFieldName, CWnd* pDSCWnd);
void BindProperty(DISPID dwDispId, CWnd* pWndDSC);
#endif
// Accessibility Support
public :
void EnableActiveAccessibility();
void NotifyWinEvent(DWORD event, LONG idObjectType, LONG idObject);
protected :
bool m_bEnableActiveAccessibility;
IAccessible* m_pStdObject;
typedef VOID (WINAPI *PFNNOTIFYWINEVENT)(DWORD, HWND, LONG, LONG);
static PFNNOTIFYWINEVENT m_pfnNotifyWinEvent;
friend BOOL AFXAPI AfxWinInit(__in HINSTANCE hInstance, __in HINSTANCE hPrevInstance,
__in_z LPTSTR lpCmdLine, __in int nCmdShow);
protected:
IAccessibleProxy* m_pProxy;
afx_msg LRESULT OnGetObject(WPARAM, LPARAM);
#ifndef _AFX_NO_OLE_SUPPORT
DECLARE_INTERFACE_MAP()
#endif
class XAccessible //: public IAccessible
{
public:
#ifndef _AFX_NO_NESTED_DERIVATION
size_t m_nOffset;
XAccessible()
{ m_nOffset = offsetof(CWnd, m_xAccessible); }
#endif
virtual ULONG __stdcall AddRef();
virtual ULONG __stdcall Release();
virtual HRESULT __stdcall QueryInterface(REFIID iid, LPVOID* ppvObj);
virtual HRESULT __stdcall Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
virtual HRESULT __stdcall GetIDsOfNames(REFIID, LPOLESTR *, UINT, LCID, DISPID *);
virtual HRESULT __stdcall GetTypeInfoCount(unsigned int *);
virtual HRESULT __stdcall GetTypeInfo(unsigned int, LCID, ITypeInfo**);
virtual HRESULT __stdcall get_accParent(IDispatch **ppdispParent);
virtual HRESULT __stdcall get_accChildCount(long *pcountChildren);
virtual HRESULT __stdcall get_accChild(VARIANT varChild, IDispatch **ppdispChild);
virtual HRESULT __stdcall get_accName(VARIANT varChild, BSTR *pszName);
virtual HRESULT __stdcall get_accValue(VARIANT varChild, BSTR *pszValue);
virtual HRESULT __stdcall get_accDescription(VARIANT varChild, BSTR *pszDescription);
virtual HRESULT __stdcall get_accRole(VARIANT varChild, VARIANT *pvarRole);
virtual HRESULT __stdcall get_accState(VARIANT varChild, VARIANT *pvarState);
virtual HRESULT __stdcall get_accHelp(VARIANT varChild, BSTR *pszHelp);
virtual HRESULT __stdcall get_accHelpTopic(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic);
virtual HRESULT __stdcall get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
virtual HRESULT __stdcall get_accFocus(VARIANT *pvarChild);
virtual HRESULT __stdcall get_accSelection(VARIANT *pvarChildren);
virtual HRESULT __stdcall get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);
virtual HRESULT __stdcall accSelect(long flagsSelect, VARIANT varChild);
virtual HRESULT __stdcall accLocation(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild);
virtual HRESULT __stdcall accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
virtual HRESULT __stdcall accHitTest(long xLeft, long yTop, VARIANT *pvarChild);
virtual HRESULT __stdcall accDoDefaultAction(VARIANT varChild);
virtual HRESULT __stdcall put_accName(VARIANT varChild, BSTR szName);
virtual HRESULT __stdcall put_accValue(VARIANT varChild, BSTR szValue);
} m_xAccessible;
friend class XAccessible;
class XAccessibleServer //: public IAccessibleServer
{
public:
#ifndef _AFX_NO_NESTED_DERIVATION
size_t m_nOffset;
XAccessibleServer()
{ m_nOffset = offsetof(CWnd, m_xAccessibleServer); }
#endif
virtual ULONG __stdcall AddRef();
virtual ULONG __stdcall Release();
virtual HRESULT __stdcall QueryInterface(REFIID iid, LPVOID* ppvObj);
virtual HRESULT __stdcall SetProxy(IAccessibleProxy *pProxy);
virtual HRESULT __stdcall GetHWND(HWND *phWnd);
virtual HRESULT __stdcall GetEnumVariant(IEnumVARIANT **ppEnumVariant);
} m_xAccessibleServer;
friend class XAccessibleServer;
public :
virtual HRESULT EnsureStdObj();
virtual HRESULT get_accParent(IDispatch **ppdispParent);
virtual HRESULT get_accChildCount(long *pcountChildren);
virtual HRESULT get_accChild(VARIANT varChild, IDispatch **ppdispChild);
virtual HRESULT get_accName(VARIANT varChild, BSTR *pszName);
virtual HRESULT get_accValue(VARIANT varChild, BSTR *pszValue);
virtual HRESULT get_accDescription(VARIANT varChild, BSTR *pszDescription);
virtual HRESULT get_accRole(VARIANT varChild, VARIANT *pvarRole);
virtual HRESULT get_accState(VARIANT varChild, VARIANT *pvarState);
virtual HRESULT get_accHelp(VARIANT varChild, BSTR *pszHelp);
virtual HRESULT get_accHelpTopic(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic);
virtual HRESULT get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
virtual HRESULT get_accFocus(VARIANT *pvarChild);
virtual HRESULT get_accSelection(VARIANT *pvarChildren);
virtual HRESULT get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);
virtual HRESULT accSelect(long flagsSelect, VARIANT varChild);
virtual HRESULT accLocation(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild);
virtual HRESULT accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
virtual HRESULT accHitTest(long xLeft, long yTop, VARIANT *pvarChild);
virtual HRESULT accDoDefaultAction(VARIANT varChild);
//Obsolete
virtual HRESULT put_accName(VARIANT varChild, BSTR szName);
//Obsolete
virtual HRESULT put_accValue(VARIANT varChild, BSTR szValue);
virtual HRESULT SetProxy(IAccessibleProxy *pProxy);
virtual HRESULT CreateAccessibleProxy(WPARAM wParam, LPARAM lParam, LRESULT *pResult);
// Helpers for windows that contain windowless controls
long GetWindowLessChildCount();
long GetWindowedChildCount();
long GetAccessibleChildCount();
HRESULT GetAccessibleChild(VARIANT varChild, IDispatch** ppdispChild);
HRESULT GetAccessibleName(VARIANT varChild, BSTR* pszName);
HRESULT GetAccessibilityLocation(VARIANT varChild, long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight);
HRESULT GetAccessibilityHitTest(long xLeft, long yTop, VARIANT *pvarChild);
// Window-Management message handler member functions
protected:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
afx_msg LRESULT OnActivateTopLevel(WPARAM, LPARAM);
afx_msg void OnCancelMode();
afx_msg void OnChildActivate();
afx_msg void OnClose();
afx_msg void OnContextMenu(CWnd* pWnd, CPoint pos);
afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnDestroy();
afx_msg void OnEnable(BOOL bEnable);
afx_msg void OnEndSession(BOOL bEnding);
afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg void OnIconEraseBkgnd(CDC* pDC);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
afx_msg void OnMove(int x, int y);
afx_msg void OnPaint();
afx_msg void OnParentNotify(UINT message, LPARAM lParam);
afx_msg HCURSOR OnQueryDragIcon();
afx_msg BOOL OnQueryEndSession();
afx_msg BOOL OnQueryNewPalette();
afx_msg BOOL OnQueryOpen();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnTCard(UINT idAction, DWORD dwActionData);
afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
afx_msg void OnChangeUIState(UINT nAction, UINT nUIElement);
afx_msg void OnUpdateUIState(UINT nAction, UINT nUIElement);
afx_msg UINT OnQueryUIState();
// Nonclient-Area message handler member functions
afx_msg BOOL OnNcActivate(BOOL bActive);
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnNcDestroy();
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnNcMButtonDblClk(UINT nHitTest, CPoint point);
afx_msg void OnNcMButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcMButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
afx_msg void OnNcPaint();
afx_msg void OnNcRButtonDblClk(UINT nHitTest, CPoint point);
afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
// System message handler member functions
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnPaletteIsChanging(CWnd* pRealizeWnd);
afx_msg void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnCompacting(UINT nCpuTime);
afx_msg void OnDevModeChange(__in_z LPTSTR lpDeviceName);
afx_msg void OnFontChange();
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
afx_msg void OnSpoolerStatus(UINT nStatus, UINT nJobs);
afx_msg void OnSysColorChange();
afx_msg void OnTimeChange();
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
afx_msg void OnWinIniChange(LPCTSTR lpszSection);
// Input message handler member functions
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnTimer(UINT_PTR nIDEvent);
// Initialization message handler member functions
afx_msg void OnInitMenu(CMenu* pMenu);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
// Clipboard message handler member functions
afx_msg void OnAskCbFormatName(__in UINT nMaxCount, __out_ecount_z(nMaxCount) LPTSTR lpszString);
afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
afx_msg void OnDestroyClipboard();
afx_msg void OnDrawClipboard();
afx_msg void OnHScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
afx_msg void OnPaintClipboard(CWnd* pClipAppWnd, HGLOBAL hPaintStruct);
afx_msg void OnRenderAllFormats();
afx_msg void OnRenderFormat(UINT nFormat);
afx_msg void OnSizeClipboard(CWnd* pClipAppWnd, HGLOBAL hRect);
afx_msg void OnVScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
// Control message handler member functions
afx_msg int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct);
afx_msg void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct);
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg UINT OnGetDlgCode();
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex);
afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
// MDI message handler member functions
afx_msg void OnMDIActivate(BOOL bActivate,
CWnd* pActivateWnd, CWnd* pDeactivateWnd);
// Menu loop notification messages
afx_msg void OnEnterMenuLoop(BOOL bIsTrackPopupMenu);
afx_msg void OnExitMenuLoop(BOOL bIsTrackPopupMenu);
// Win4 messages
afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
afx_msg void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
afx_msg void OnSizing(UINT nSide, LPRECT lpRect);
afx_msg void OnMoving(UINT nSide, LPRECT lpRect);
afx_msg void OnCaptureChanged(CWnd* pWnd);
afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData);
// Overridables and other helpers (for implementation of derived classes)
protected:
// for deriving from a standard control
virtual WNDPROC* GetSuperWndProcAddr();
// for dialog data exchange and validation
virtual void DoDataExchange(CDataExchange* pDX);
public:
// for modality
virtual void BeginModalState();
virtual void EndModalState();
// for translating Windows messages in main message pump
virtual BOOL PreTranslateMessage(MSG* pMsg);
#ifndef _AFX_NO_OCC_SUPPORT
// for ambient properties exposed to contained OLE controls
virtual BOOL OnAmbientProperty(COleControlSite* pSite, DISPID dispid,
VARIANT* pvar);
#endif
protected:
// for processing Windows messages
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
// for handling default processing
LRESULT Default();
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
// for custom cleanup after WM_NCDESTROY
virtual void PostNcDestroy();
// for notifications from parent
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
// return TRUE if parent should not process this message
BOOL ReflectChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
static BOOL PASCAL ReflectLastMsg(HWND hWndChild, LRESULT* pResult = NULL);
// Implementation
public:
virtual ~CWnd();
virtual BOOL CheckAutoCenter();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
static BOOL PASCAL GrayCtlColor(HDC hDC, HWND hWnd, UINT nCtlColor,
HBRUSH hbrGray, COLORREF clrText);
// helper routines for implementation
BOOL HandleFloatingSysCommand(UINT nID, LPARAM lParam);
BOOL IsTopParentActive() const;
void ActivateTopParent();
static BOOL PASCAL WalkPreTranslateTree(HWND hWndStop, MSG* pMsg);
static CWnd* PASCAL GetDescendantWindow(HWND hWnd, int nID,
BOOL bOnlyPerm);
static void PASCAL SendMessageToDescendants(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam, BOOL bDeep, BOOL bOnlyPerm);
virtual BOOL IsFrameWnd() const; // IsKindOf(RUNTIME_CLASS(CFrameWnd)))
virtual void OnFinalRelease();
BOOL PreTranslateInput(LPMSG lpMsg);
static BOOL PASCAL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
UINT nFlags);
static BOOL PASCAL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
UINT nFlags);
static void PASCAL _FilterToolTipMessage(MSG* pMsg, CWnd* pWnd);
BOOL _EnableToolTips(BOOL bEnable, UINT nFlag);
static HWND PASCAL GetSafeOwner_(HWND hWnd, HWND* pWndTop);
void PrepareForHelp();
COleControlContainer* GetControlContainer();
public:
HWND m_hWndOwner; // implementation of SetOwner and GetOwner
UINT m_nFlags; // see WF_ flags above
protected:
WNDPROC m_pfnSuper; // for subclassing of controls
static const UINT m_nMsgDragList;
int m_nModalResult; // for return values from CWnd::RunModalLoop
COleDropTarget* m_pDropTarget; // for automatic cleanup of drop target
friend class COleDropTarget;
friend class CFrameWnd;
// for creating dialogs and dialog-like windows
BOOL CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd);
BOOL CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
HINSTANCE hInst);
#ifndef _AFX_NO_OCC_SUPPORT
COleControlContainer* m_pCtrlCont; // for containing OLE controls
COleControlSite* m_pCtrlSite; // for wrapping an OLE control
friend class COccManager;
friend class COleControlSite;
friend class COleControlContainer;
BOOL InitControlContainer(BOOL bCreateFromResource=FALSE);
virtual BOOL CreateControlContainer(COleControlContainer** ppContainer);
virtual BOOL CreateControlSite(COleControlContainer* pContainer,
COleControlSite** ppSite, UINT nID, REFCLSID clsid);
virtual BOOL SetOccDialogInfo(struct _AFX_OCC_DIALOG_INFO* pOccDialogInfo);
virtual _AFX_OCC_DIALOG_INFO* GetOccDialogInfo();
void AttachControlSite(CHandleMap* pMap);
public:
void AttachControlSite(CWnd* pWndParent, UINT nIDC = 0);
COleControlSite* GetControlSite() const
{
return m_pCtrlSite;
}
#endif
protected:
// implementation of message dispatch/hooking
friend LRESULT CALLBACK _AfxSendMsgHook(int, WPARAM, LPARAM);
friend void AFXAPI _AfxStandardSubclass(HWND);
friend LRESULT CALLBACK _AfxCbtFilterHook(int, WPARAM, LPARAM);
friend LRESULT AFXAPI AfxCallWndProc(CWnd*, HWND, UINT, WPARAM, LPARAM);
// standard message implementation
afx_msg LRESULT OnNTCtlColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnDisplayChange(WPARAM, LPARAM);
afx_msg LRESULT OnDragList(WPARAM, LPARAM);
//{{AFX_MSG(CWnd)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CWnd(HWND hWnd); // just for special initialization
};
拓展CEdit类(文本输入控件)