📄 afxwin.h
字号:
LPUNKNOWN GetControllingUnknown();
// get controlling IUnknown for aggregate creation
// these versions do not delegate to m_pOuterUnknown
DWORD InternalQueryInterface(const void*, LPVOID* ppvObj);
DWORD InternalAddRef();
DWORD InternalRelease();
// these versions delegate to m_pOuterUnknown
DWORD ExternalQueryInterface(const void*, LPVOID* ppvObj);
DWORD ExternalAddRef();
DWORD ExternalRelease();
// implementation helpers
LPUNKNOWN GetInterface(const void*);
LPUNKNOWN QueryAggregates(const void*);
// advanced overrideables for implementation
virtual BOOL OnCreateAggregates();
virtual LPUNKNOWN GetInterfaceHook(const void*);
// OLE automation implementation
protected:
struct XDispatch
{
DWORD m_vtbl; // place-holder for IDispatch vtable
#ifndef _AFX_NO_NESTED_DERIVATION
size_t m_nOffset;
#endif
} m_xDispatch;
BOOL m_bResultExpected;
// member variable-based properties
void GetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
VARIANT* pvarResult, UINT* puArgErr);
SCODE SetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
DISPPARAMS* pDispParams, UINT* puArgErr);
// DISPID to dispatch map lookup
static UINT PASCAL GetEntryCount(const AFX_DISPMAP* pDispMap);
const AFX_DISPMAP_ENTRY* PASCAL GetDispEntry(LONG memid);
static LONG PASCAL MemberIDFromName(const AFX_DISPMAP* pDispMap, LPCTSTR lpszName);
// helpers for member function calling implementation
static UINT PASCAL GetStackSize(const BYTE* pbParams, VARTYPE vtResult);
#ifdef _PPC_
SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
UINT* puArgErr, VARIANT* rgTempVars, UINT nSizeArgs);
#else
SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
UINT* puArgErr, VARIANT* rgTempVars);
#endif
SCODE CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags,
VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr);
friend class COleDispatchImpl;
#ifndef _AFX_NO_OCC_SUPPORT
public:
// OLE event sink implementation
BOOL OnEvent(UINT idCtrl, AFX_EVENT* pEvent,
AFX_CMDHANDLERINFO* pHandlerInfo);
protected:
const AFX_EVENTSINKMAP_ENTRY* PASCAL GetEventSinkEntry(UINT idCtrl,
AFX_EVENT* pEvent);
#endif // !_AFX_NO_OCC_SUPPORT
// OLE connection implementation
struct XConnPtContainer
{
DWORD m_vtbl; // place-holder for IConnectionPointContainer vtable
#ifndef _AFX_NO_NESTED_DERIVATION
size_t m_nOffset;
#endif
} m_xConnPtContainer;
#ifdef _AFXDLL
AFX_MODULE_STATE* m_pModuleState;
friend class CInnerUnknown;
friend UINT APIENTRY _AfxThreadEntry(void* pParam);
#endif
virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints);
virtual LPCONNECTIONPOINT GetConnectionHook(const IID& iid);
friend class COleConnPtContainer;
#endif //!_AFX_NO_OLE_SUPPORT
};
class CCmdUI // simple helper class
{
public:
// Attributes
UINT m_nID;
UINT m_nIndex; // menu item or other index
// if a menu item
CMenu* m_pMenu; // NULL if not a menu
CMenu* m_pSubMenu; // sub containing menu item
// if a popup sub menu - ID is for first in popup
// if from some other window
CWnd* m_pOther; // NULL if a menu or not a CWnd
// Operations to do in ON_UPDATE_COMMAND_UI
virtual void Enable(BOOL bOn = TRUE);
virtual void SetCheck(int nCheck = 1); // 0, 1 or 2 (indeterminate)
virtual void SetRadio(BOOL bOn = TRUE);
virtual void SetText(LPCTSTR lpszText);
// Advanced operation
void ContinueRouting();
// Implementation
CCmdUI();
BOOL m_bEnableChanged;
BOOL m_bContinueRouting;
UINT m_nIndexMax; // last + 1 for iterating m_nIndex
CMenu* m_pParentMenu; // NULL if parent menu not easily determined
// (probably a secondary popup menu)
BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
};
// special CCmdUI derived classes are used for other UI paradigms
// like toolbar buttons and status indicators
// pointer to afx_msg member function
#ifndef AFX_MSG_CALL
#define AFX_MSG_CALL
#endif
typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
enum AFX_DISPMAP_FLAGS
{
afxDispCustom = 0,
afxDispStock = 1
};
struct AFX_DISPMAP_ENTRY
{
LPCTSTR lpszName; // member/property name
long lDispID; // DISPID (may be DISPID_UNKNOWN)
LPCSTR lpszParams; // member parameter description
WORD vt; // return value type / or type of property
AFX_PMSG pfn; // normal member On<membercall> or, OnGet<property>
AFX_PMSG pfnSet; // special member for OnSet<property>
size_t nPropOffset; // property offset
AFX_DISPMAP_FLAGS flags;// flags (e.g. stock/custom)
};
struct AFX_EVENTSINKMAP_ENTRY
{
AFX_DISPMAP_ENTRY dispEntry;
UINT nCtrlIDFirst;
UINT nCtrlIDLast;
};
// DSC Sink state/reason codes passed to MFC user event handlers
enum DSCSTATE
{
dscNoState = 0,
dscOKToDo,
dscCancelled,
dscSyncBefore,
dscAboutToDo,
dscFailedToDo,
dscSyncAfter,
dscDidEvent
};
enum DSCREASON
{
dscNoReason = 0,
dscClose,
dscCommit,
dscDelete,
dscEdit,
dscInsert,
dscModify,
dscMove
};
/////////////////////////////////////////////////////////////////////////////
// CWnd implementation
// structures (see afxext.h)
struct CCreateContext; // context for creating things
struct CPrintInfo; // print preview customization info
struct AFX_MSGMAP_ENTRY
{
UINT nMessage; // windows message
UINT nCode; // control code or WM_NOTIFY code
UINT nID; // control ID (or 0 for windows messages)
UINT nLastID; // used for entries specifying a range of control id's
UINT nSig; // signature type (action) or pointer to message #
AFX_PMSG pfn; // routine to call (or special value)
};
/////////////////////////////////////////////////////////////////////////////
// CWnd - a Microsoft Windows application window
class COleDropTarget; // for more information see AFXOLE.H
class COleControlContainer;
class COleControlSite;
// CWnd::m_nFlags (generic to CWnd)
#define WF_TOOLTIPS 0x0001 // window is enabled for tooltips
#define WF_TEMPHIDE 0x0002 // window is temporarily hidden
#define WF_STAYDISABLED 0x0004 // window should stay disabled
#define WF_MODALLOOP 0x0008 // currently in modal loop
#define WF_CONTINUEMODAL 0x0010 // modal loop should continue running
#define WF_OLECTLCONTAINER 0x0100 // some descendant is an OLE control
#define WF_TRACKINGTOOLTIPS 0x0400 // window is enabled for tracking tooltips
// CWnd::m_nFlags (specific to CFrameWnd)
#define WF_STAYACTIVE 0x0020 // look active even though not active
#define WF_NOPOPMSG 0x0040 // ignore WM_POPMESSAGESTRING calls
#define WF_MODALDISABLE 0x0080 // window is disabled
#define WF_KEEPMINIACTIVE 0x0200 // stay activate even though you are deactivated
// flags for CWnd::RunModalLoop
#define MLF_NOIDLEMSG 0x0001 // don't send WM_ENTERIDLE messages
#define MLF_NOKICKIDLE 0x0002 // don't send WM_KICKIDLE messages
#define MLF_SHOWONIDLE 0x0004 // show window if not visible at idle time
// extra MFC defined TTF_ flags for TOOLINFO::uFlags
#define TTF_NOTBUTTON 0x80000000L // no status help on buttondown
#define TTF_ALWAYSTIP 0x40000000L // always show the tip even if not active
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);
// 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)
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);
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 );
LPUNKNOWN GetControlUnknown();
#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;
CWnd* GetTopLevelParent() const;
CWnd* GetTopLevelOwner() const;
CWnd* GetParentOwner() const;
CFrameWnd* GetTopLevelFrame() const;
static CWnd* PASCAL GetSafeOwner(CWnd* pParent = NULL, HWND* pWndTop = NULL);
// 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, LPARAM lParam);
BOOL SendChildNotifyLastMsg(LRESULT* pResult = NULL);
// Message processing for modeless dialog-like windows
BOOL IsDialogMessage(LPMSG lpMsg);
// Window Text Functions
void SetWindowText(LPCTSTR lpszString);
int GetWindowText(LPTSTR lpszStringBuf, 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);
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -