home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / include / afxwin.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  154KB  |  4,662 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXWIN_H__
  12. #ifndef RC_INVOKED
  13. #define __AFXWIN_H__
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // Make sure 'afx.h' is included first
  17.  
  18. #ifndef __AFX_H__
  19.     #include <afx.h>
  20. #endif
  21.  
  22. // Note: WINDOWS.H already included from AFXV_W32.H
  23.  
  24. #ifndef _INC_SHELLAPI
  25.     #include <shellapi.h>
  26. #endif
  27.  
  28. #ifndef __AFXRES_H__
  29.     #include <afxres.h>     // standard resource IDs
  30. #endif
  31.  
  32. #ifndef __AFXCOLL_H__
  33.     #include <afxcoll.h>    // standard collections
  34. #endif
  35.  
  36. #ifdef _AFX_MINREBUILD
  37. #pragma component(minrebuild, off)
  38. #endif
  39. #ifndef _AFX_FULLTYPEINFO
  40. #pragma component(mintypeinfo, on)
  41. #endif
  42.  
  43. #ifndef _AFX_NOFORCE_LIBS
  44. #pragma comment(lib, "uuid.lib")
  45. #endif
  46.  
  47. #ifdef _INC_WINDOWSX
  48. // The following names from WINDOWSX.H collide with names in this header
  49. #undef SubclassWindow
  50. #undef CopyRgn
  51. #endif
  52.  
  53. #ifdef _AFX_PACKING
  54. #pragma pack(push, _AFX_PACKING)
  55. #endif
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Classes declared in this file
  59.  
  60. class CSize;
  61. class CPoint;
  62. class CRect;
  63.  
  64. //CObject
  65.     //CException
  66.         //CSimpleException
  67.             class CResourceException;// Win resource failure exception
  68.             class CUserException;    // Message Box alert and stop operation
  69.  
  70.     class CGdiObject;            // CDC drawing tool
  71.         class CPen;              // a pen / HPEN wrapper
  72.         class CBrush;            // a brush / HBRUSH wrapper
  73.         class CFont;             // a font / HFONT wrapper
  74.         class CBitmap;           // a bitmap / HBITMAP wrapper
  75.         class CPalette;          // a palette / HPALLETE wrapper
  76.         class CRgn;              // a region / HRGN wrapper
  77.  
  78.     class CDC;                   // a Display Context / HDC wrapper
  79.         class CClientDC;         // CDC for client of window
  80.         class CWindowDC;         // CDC for entire window
  81.         class CPaintDC;          // embeddable BeginPaint struct helper
  82.  
  83.     class CMenu;                 // a menu / HMENU wrapper
  84.  
  85.     class CCmdTarget;            // a target for user commands
  86.         class CWnd;                 // a window / HWND wrapper
  87.             class CDialog;          // a dialog
  88.  
  89.             // standard windows controls
  90.             class CStatic;          // Static control
  91.             class CButton;          // Button control
  92.             class CListBox;         // ListBox control
  93.                 class CCheckListBox;// special listbox with checks
  94.             class CComboBox;        // ComboBox control
  95.             class CEdit;            // Edit control
  96.             class CScrollBar;       // ScrollBar control
  97.  
  98.             // frame windows
  99.             class CFrameWnd;        // standard SDI frame
  100.                 class CMDIFrameWnd; // standard MDI frame
  101.                 class CMDIChildWnd; // standard MDI child
  102.                 class CMiniFrameWnd;// half-height caption frame wnd
  103.  
  104.             // views on a document
  105.             class CView;            // a view on a document
  106.                 class CScrollView;  // a scrolling view
  107.  
  108.         class CWinThread;           // thread base class
  109.             class CWinApp;          // application base class
  110.  
  111.         class CDocTemplate;         // template for document creation
  112.             class CSingleDocTemplate;// SDI support
  113.             class CMultiDocTemplate; // MDI support
  114.  
  115.         class CDocument;            // main document abstraction
  116.  
  117.  
  118. // Helper classes
  119. class CCmdUI;           // Menu/button enabling
  120. class CDataExchange;    // Data exchange and validation context
  121. class CCommandLineInfo; // CommandLine parsing helper
  122. class CDocManager;      // CDocTemplate manager object
  123.  
  124. /////////////////////////////////////////////////////////////////////////////
  125.  
  126. // Type modifier for message handlers
  127. #ifndef afx_msg
  128. #define afx_msg         // intentional placeholder
  129. #endif
  130.  
  131. #undef AFX_DATA
  132. #define AFX_DATA AFX_CORE_DATA
  133.  
  134. /////////////////////////////////////////////////////////////////////////////
  135. // CSize - An extent, similar to Windows SIZE structure.
  136.  
  137. class CSize : public tagSIZE
  138. {
  139. public:
  140.  
  141. // Constructors
  142.     // construct an uninitialized size
  143.     CSize();
  144.     // create from two integers
  145.     CSize(int initCX, int initCY);
  146.     // create from another size
  147.     CSize(SIZE initSize);
  148.     // create from a point
  149.     CSize(POINT initPt);
  150.     // create from a DWORD: cx = LOWORD(dw) cy = HIWORD(dw)
  151.     CSize(DWORD dwSize);
  152.  
  153. // Operations
  154.     BOOL operator==(SIZE size) const;
  155.     BOOL operator!=(SIZE size) const;
  156.     void operator+=(SIZE size);
  157.     void operator-=(SIZE size);
  158.  
  159. // Operators returning CSize values
  160.     CSize operator+(SIZE size) const;
  161.     CSize operator-(SIZE size) const;
  162.     CSize operator-() const;
  163.  
  164. // Operators returning CPoint values
  165.     CPoint operator+(POINT point) const;
  166.     CPoint operator-(POINT point) const;
  167.  
  168. // Operators returning CRect values
  169.     CRect operator+(const RECT* lpRect) const;
  170.     CRect operator-(const RECT* lpRect) const;
  171. };
  172.  
  173. /////////////////////////////////////////////////////////////////////////////
  174. // CPoint - A 2-D point, similar to Windows POINT structure.
  175.  
  176. class CPoint : public tagPOINT
  177. {
  178. public:
  179. // Constructors
  180.  
  181.     // create an uninitialized point
  182.     CPoint();
  183.     // create from two integers
  184.     CPoint(int initX, int initY);
  185.     // create from another point
  186.     CPoint(POINT initPt);
  187.     // create from a size
  188.     CPoint(SIZE initSize);
  189.     // create from a dword: x = LOWORD(dw) y = HIWORD(dw)
  190.     CPoint(DWORD dwPoint);
  191.  
  192. // Operations
  193.  
  194. // translate the point
  195.     void Offset(int xOffset, int yOffset);
  196.     void Offset(POINT point);
  197.     void Offset(SIZE size);
  198.  
  199.     BOOL operator==(POINT point) const;
  200.     BOOL operator!=(POINT point) const;
  201.     void operator+=(SIZE size);
  202.     void operator-=(SIZE size);
  203.     void operator+=(POINT point);
  204.     void operator-=(POINT point);
  205.  
  206. // Operators returning CPoint values
  207.     CPoint operator+(SIZE size) const;
  208.     CPoint operator-(SIZE size) const;
  209.     CPoint operator-() const;
  210.     CPoint operator+(POINT point) const;
  211.  
  212. // Operators returning CSize values
  213.     CSize operator-(POINT point) const;
  214.  
  215. // Operators returning CRect values
  216.     CRect operator+(const RECT* lpRect) const;
  217.     CRect operator-(const RECT* lpRect) const;
  218. };
  219.  
  220. /////////////////////////////////////////////////////////////////////////////
  221. // CRect - A 2-D rectangle, similar to Windows RECT structure.
  222.  
  223. typedef const RECT* LPCRECT;    // pointer to read/only RECT
  224.  
  225. class CRect : public tagRECT
  226. {
  227. public:
  228.  
  229. // Constructors
  230.  
  231.     // uninitialized rectangle
  232.     CRect();
  233.     // from left, top, right, and bottom
  234.     CRect(int l, int t, int r, int b);
  235.     // copy constructor
  236.     CRect(const RECT& srcRect);
  237.     // from a pointer to another rect
  238.     CRect(LPCRECT lpSrcRect);
  239.     // from a point and size
  240.     CRect(POINT point, SIZE size);
  241.     // from two points
  242.     CRect(POINT topLeft, POINT bottomRight);
  243.  
  244. // Attributes (in addition to RECT members)
  245.  
  246.     // retrieves the width
  247.     int Width() const;
  248.     // returns the height
  249.     int Height() const;
  250.     // returns the size
  251.     CSize Size() const;
  252.     // reference to the top-left point
  253.     CPoint& TopLeft();
  254.     // reference to the bottom-right point
  255.     CPoint& BottomRight();
  256.     // const reference to the top-left point
  257.     const CPoint& TopLeft() const;
  258.     // const reference to the bottom-right point
  259.     const CPoint& BottomRight() const;
  260.     // the geometric center point of the rectangle
  261.     CPoint CenterPoint() const;
  262.     // swap the left and right
  263.     void SwapLeftRight();
  264.     static void SwapLeftRight(LPRECT lpRect);
  265.  
  266.     // convert between CRect and LPRECT/LPCRECT (no need for &)
  267.     operator LPRECT();
  268.     operator LPCRECT() const;
  269.  
  270.     // returns TRUE if rectangle has no area
  271.     BOOL IsRectEmpty() const;
  272.     // returns TRUE if rectangle is at (0,0) and has no area
  273.     BOOL IsRectNull() const;
  274.     // returns TRUE if point is within rectangle
  275.     BOOL PtInRect(POINT point) const;
  276.  
  277. // Operations
  278.  
  279.     // set rectangle from left, top, right, and bottom
  280.     void SetRect(int x1, int y1, int x2, int y2);
  281.     void SetRect(POINT topLeft, POINT bottomRight);
  282.     // empty the rectangle
  283.     void SetRectEmpty();
  284.     // copy from another rectangle
  285.     void CopyRect(LPCRECT lpSrcRect);
  286.     // TRUE if exactly the same as another rectangle
  287.     BOOL EqualRect(LPCRECT lpRect) const;
  288.  
  289.     // inflate rectangle's width and height without
  290.     // moving its top or left
  291.     void InflateRect(int x, int y);
  292.     void InflateRect(SIZE size);
  293.     void InflateRect(LPCRECT lpRect);
  294.     void InflateRect(int l, int t, int r, int b);
  295.     // deflate the rectangle's width and height without
  296.     // moving its top or left
  297.     void DeflateRect(int x, int y);
  298.     void DeflateRect(SIZE size);
  299.     void DeflateRect(LPCRECT lpRect);
  300.     void DeflateRect(int l, int t, int r, int b);
  301.  
  302.     // translate the rectangle by moving its top and left
  303.     void OffsetRect(int x, int y);
  304.     void OffsetRect(SIZE size);
  305.     void OffsetRect(POINT point);
  306.     void NormalizeRect();
  307.  
  308.     // set this rectangle to intersection of two others
  309.     BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2);
  310.  
  311.     // set this rectangle to bounding union of two others
  312.     BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2);
  313.  
  314.     // set this rectangle to minimum of two others
  315.     BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2);
  316.  
  317. // Additional Operations
  318.     void operator=(const RECT& srcRect);
  319.     BOOL operator==(const RECT& rect) const;
  320.     BOOL operator!=(const RECT& rect) const;
  321.     void operator+=(POINT point);
  322.     void operator+=(SIZE size);
  323.     void operator+=(LPCRECT lpRect);
  324.     void operator-=(POINT point);
  325.     void operator-=(SIZE size);
  326.     void operator-=(LPCRECT lpRect);
  327.     void operator&=(const RECT& rect);
  328.     void operator|=(const RECT& rect);
  329.  
  330. // Operators returning CRect values
  331.     CRect operator+(POINT point) const;
  332.     CRect operator-(POINT point) const;
  333.     CRect operator+(LPCRECT lpRect) const;
  334.     CRect operator+(SIZE size) const;
  335.     CRect operator-(SIZE size) const;
  336.     CRect operator-(LPCRECT lpRect) const;
  337.     CRect operator&(const RECT& rect2) const;
  338.     CRect operator|(const RECT& rect2) const;
  339.     CRect MulDiv(int nMultiplier, int nDivisor) const;
  340. };
  341.  
  342. #ifdef _DEBUG
  343. // Diagnostic Output
  344. CDumpContext& AFXAPI operator<<(CDumpContext& dc, SIZE size);
  345. CDumpContext& AFXAPI operator<<(CDumpContext& dc, POINT point);
  346. CDumpContext& AFXAPI operator<<(CDumpContext& dc, const RECT& rect);
  347. #endif //_DEBUG
  348.  
  349. // Serialization
  350. CArchive& AFXAPI operator<<(CArchive& ar, SIZE size);
  351. CArchive& AFXAPI operator<<(CArchive& ar, POINT point);
  352. CArchive& AFXAPI operator<<(CArchive& ar, const RECT& rect);
  353. CArchive& AFXAPI operator>>(CArchive& ar, SIZE& size);
  354. CArchive& AFXAPI operator>>(CArchive& ar, POINT& point);
  355. CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect);
  356.  
  357. /////////////////////////////////////////////////////////////////////////////
  358. // Standard exceptions
  359.  
  360. class CResourceException : public CSimpleException    // resource failure
  361. {
  362.     DECLARE_DYNAMIC(CResourceException)
  363. public:
  364.     CResourceException();
  365.  
  366. // Implementation
  367. public:
  368.     CResourceException(BOOL bAutoDelete);
  369.     CResourceException(BOOL bAutoDelete, UINT nResourceID);
  370.     virtual ~CResourceException();
  371. };
  372.  
  373. class CUserException : public CSimpleException   // general user visible alert
  374. {
  375.     DECLARE_DYNAMIC(CUserException)
  376. public:
  377.     CUserException();
  378.  
  379. // Implementation
  380. public:
  381.     CUserException(BOOL bAutoDelete);
  382.     CUserException(BOOL bAutoDelete, UINT nResourceID);
  383.     virtual ~CUserException();
  384. };
  385.  
  386. void AFXAPI AfxThrowResourceException();
  387. void AFXAPI AfxThrowUserException();
  388.  
  389. /////////////////////////////////////////////////////////////////////////////
  390. // CGdiObject abstract class for CDC SelectObject
  391.  
  392. class CGdiObject : public CObject
  393. {
  394.     DECLARE_DYNCREATE(CGdiObject)
  395. public:
  396.  
  397. // Attributes
  398.     HGDIOBJ m_hObject;                  // must be first data member
  399.     operator HGDIOBJ() const;
  400.     HGDIOBJ GetSafeHandle() const;
  401.  
  402.     static CGdiObject* PASCAL FromHandle(HGDIOBJ hObject);
  403.     static void PASCAL DeleteTempMap();
  404.     BOOL Attach(HGDIOBJ hObject);
  405.     HGDIOBJ Detach();
  406.  
  407. // Constructors
  408.     CGdiObject(); // must Create a derived class object
  409.     BOOL DeleteObject();
  410.  
  411. // Operations
  412.     int GetObject(int nCount, LPVOID lpObject) const;
  413.     UINT GetObjectType() const;
  414.     BOOL CreateStockObject(int nIndex);
  415.     BOOL UnrealizeObject();
  416.     BOOL operator==(const CGdiObject& obj) const;
  417.     BOOL operator!=(const CGdiObject& obj) const;
  418.  
  419. // Implementation
  420. public:
  421.     virtual ~CGdiObject();
  422. #ifdef _DEBUG
  423.     virtual void Dump(CDumpContext& dc) const;
  424.     virtual void AssertValid() const;
  425. #endif
  426. };
  427.  
  428. /////////////////////////////////////////////////////////////////////////////
  429. // CGdiObject subclasses (drawing tools)
  430.  
  431. class CPen : public CGdiObject
  432. {
  433.     DECLARE_DYNAMIC(CPen)
  434.  
  435. public:
  436.     static CPen* PASCAL FromHandle(HPEN hPen);
  437.  
  438. // Constructors
  439.     CPen();
  440.     CPen(int nPenStyle, int nWidth, COLORREF crColor);
  441.     CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
  442.         int nStyleCount = 0, const DWORD* lpStyle = NULL);
  443.     BOOL CreatePen(int nPenStyle, int nWidth, COLORREF crColor);
  444.     BOOL CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
  445.         int nStyleCount = 0, const DWORD* lpStyle = NULL);
  446.     BOOL CreatePenIndirect(LPLOGPEN lpLogPen);
  447.  
  448. // Attributes
  449.     operator HPEN() const;
  450.     int GetLogPen(LOGPEN* pLogPen);
  451.     int GetExtLogPen(EXTLOGPEN* pLogPen);
  452.  
  453. // Implementation
  454. public:
  455.     virtual ~CPen();
  456. #ifdef _DEBUG
  457.     virtual void Dump(CDumpContext& dc) const;
  458. #endif
  459. };
  460.  
  461. class CBrush : public CGdiObject
  462. {
  463.     DECLARE_DYNAMIC(CBrush)
  464.  
  465. public:
  466.     static CBrush* PASCAL FromHandle(HBRUSH hBrush);
  467.  
  468. // Constructors
  469.     CBrush();
  470.     CBrush(COLORREF crColor);             // CreateSolidBrush
  471.     CBrush(int nIndex, COLORREF crColor); // CreateHatchBrush
  472.     CBrush(CBitmap* pBitmap);          // CreatePatternBrush
  473.  
  474.     BOOL CreateSolidBrush(COLORREF crColor);
  475.     BOOL CreateHatchBrush(int nIndex, COLORREF crColor);
  476.     BOOL CreateBrushIndirect(const LOGBRUSH* lpLogBrush);
  477.     BOOL CreatePatternBrush(CBitmap* pBitmap);
  478.     BOOL CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage);
  479.     BOOL CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage);
  480.     BOOL CreateSysColorBrush(int nIndex);
  481.  
  482. // Attributes
  483.     operator HBRUSH() const;
  484.     int GetLogBrush(LOGBRUSH* pLogBrush);
  485.  
  486. // Implementation
  487. public:
  488.     virtual ~CBrush();
  489. #ifdef _DEBUG
  490.     virtual void Dump(CDumpContext& dc) const;
  491. #endif
  492. };
  493.  
  494. class CFont : public CGdiObject
  495. {
  496.     DECLARE_DYNAMIC(CFont)
  497.  
  498. public:
  499.     static CFont* PASCAL FromHandle(HFONT hFont);
  500.  
  501. // Constructors
  502.     CFont();
  503.     BOOL CreateFontIndirect(const LOGFONT* lpLogFont);
  504.     BOOL CreateFont(int nHeight, int nWidth, int nEscapement,
  505.             int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline,
  506.             BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
  507.             BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
  508.             LPCTSTR lpszFacename);
  509.     BOOL CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL);
  510.     BOOL CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC = NULL);
  511.  
  512. // Attributes
  513.     operator HFONT() const;
  514.     int GetLogFont(LOGFONT* pLogFont);
  515.  
  516. // Implementation
  517. public:
  518.     virtual ~CFont();
  519. #ifdef _DEBUG
  520.     virtual void Dump(CDumpContext& dc) const;
  521. #endif
  522. };
  523.  
  524. class CBitmap : public CGdiObject
  525. {
  526.     DECLARE_DYNAMIC(CBitmap)
  527.  
  528. public:
  529.     static CBitmap* PASCAL FromHandle(HBITMAP hBitmap);
  530.  
  531. // Constructors
  532.     CBitmap();
  533.  
  534.     BOOL LoadBitmap(LPCTSTR lpszResourceName);
  535.     BOOL LoadBitmap(UINT nIDResource);
  536.     BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_
  537.     BOOL LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0,
  538.         LPCOLORMAP lpColorMap = NULL, int nMapSize = 0);
  539.     BOOL CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount,
  540.             const void* lpBits);
  541.     BOOL CreateBitmapIndirect(LPBITMAP lpBitmap);
  542.     BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight);
  543.     BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight);
  544.  
  545. // Attributes
  546.     operator HBITMAP() const;
  547.     int GetBitmap(BITMAP* pBitMap);
  548.  
  549. // Operations
  550.     DWORD SetBitmapBits(DWORD dwCount, const void* lpBits);
  551.     DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const;
  552.     CSize SetBitmapDimension(int nWidth, int nHeight);
  553.     CSize GetBitmapDimension() const;
  554.  
  555. // Implementation
  556. public:
  557.     virtual ~CBitmap();
  558. #ifdef _DEBUG
  559.     virtual void Dump(CDumpContext& dc) const;
  560. #endif
  561. };
  562.  
  563. class CPalette : public CGdiObject
  564. {
  565.     DECLARE_DYNAMIC(CPalette)
  566.  
  567. public:
  568.     static CPalette* PASCAL FromHandle(HPALETTE hPalette);
  569.  
  570. // Constructors
  571.     CPalette();
  572.     BOOL CreatePalette(LPLOGPALETTE lpLogPalette);
  573.     BOOL CreateHalftonePalette(CDC* pDC);
  574.  
  575. // Attributes
  576.     operator HPALETTE() const;
  577.     int GetEntryCount();
  578.     UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  579.             LPPALETTEENTRY lpPaletteColors) const;
  580.     UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  581.             LPPALETTEENTRY lpPaletteColors);
  582.  
  583. // Operations
  584.     void AnimatePalette(UINT nStartIndex, UINT nNumEntries,
  585.             LPPALETTEENTRY lpPaletteColors);
  586.     UINT GetNearestPaletteIndex(COLORREF crColor) const;
  587.     BOOL ResizePalette(UINT nNumEntries);
  588.  
  589. // Implementation
  590.     virtual ~CPalette();
  591. };
  592.  
  593. class CRgn : public CGdiObject
  594. {
  595.     DECLARE_DYNAMIC(CRgn)
  596.  
  597. public:
  598.     static CRgn* PASCAL FromHandle(HRGN hRgn);
  599.     operator HRGN() const;
  600.  
  601. // Constructors
  602.     CRgn();
  603.     BOOL CreateRectRgn(int x1, int y1, int x2, int y2);
  604.     BOOL CreateRectRgnIndirect(LPCRECT lpRect);
  605.     BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2);
  606.     BOOL CreateEllipticRgnIndirect(LPCRECT lpRect);
  607.     BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode);
  608.     BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
  609.             int nCount, int nPolyFillMode);
  610.     BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
  611.     BOOL CreateFromPath(CDC* pDC);
  612.     BOOL CreateFromData(const XFORM* lpXForm, int nCount,
  613.         const RGNDATA* pRgnData);
  614.  
  615. // Operations
  616.     void SetRectRgn(int x1, int y1, int x2, int y2);
  617.     void SetRectRgn(LPCRECT lpRect);
  618.     int CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode);
  619.     int CopyRgn(CRgn* pRgnSrc);
  620.     BOOL EqualRgn(CRgn* pRgn) const;
  621.     int OffsetRgn(int x, int y);
  622.     int OffsetRgn(POINT point);
  623.     int GetRgnBox(LPRECT lpRect) const;
  624.     BOOL PtInRegion(int x, int y) const;
  625.     BOOL PtInRegion(POINT point) const;
  626.     BOOL RectInRegion(LPCRECT lpRect) const;
  627.     int GetRegionData(LPRGNDATA lpRgnData, int nCount) const;
  628.  
  629. // Implementation
  630.     virtual ~CRgn();
  631. };
  632.  
  633. /////////////////////////////////////////////////////////////////////////////
  634. // The device context
  635.  
  636. class CDC : public CObject
  637. {
  638.     DECLARE_DYNCREATE(CDC)
  639. public:
  640.  
  641. // Attributes
  642.     HDC m_hDC;          // The output DC (must be first data member)
  643.     HDC m_hAttribDC;    // The Attribute DC
  644.     operator HDC() const;
  645.     HDC GetSafeHdc() const; // Always returns the Output DC
  646.     CWnd* GetWindow() const;
  647.  
  648.     static CDC* PASCAL FromHandle(HDC hDC);
  649.     static void PASCAL DeleteTempMap();
  650.     BOOL Attach(HDC hDC);   // Attach/Detach affects only the Output DC
  651.     HDC Detach();
  652.  
  653.     virtual void SetAttribDC(HDC hDC);  // Set the Attribute DC
  654.     virtual void SetOutputDC(HDC hDC);  // Set the Output DC
  655.     virtual void ReleaseAttribDC();     // Release the Attribute DC
  656.     virtual void ReleaseOutputDC();     // Release the Output DC
  657.  
  658.     BOOL IsPrinting() const;            // TRUE if being used for printing
  659.  
  660.     CPen* GetCurrentPen() const;
  661.     CBrush* GetCurrentBrush() const;
  662.     CPalette* GetCurrentPalette() const;
  663.     CFont* GetCurrentFont() const;
  664.     CBitmap* GetCurrentBitmap() const;
  665.  
  666.     // for bidi and mirrored localization
  667.     DWORD GetLayout() const;
  668.     DWORD SetLayout(DWORD dwLayout);
  669.  
  670. // Constructors
  671.     CDC();
  672.     BOOL CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName,
  673.         LPCTSTR lpszOutput, const void* lpInitData);
  674.     BOOL CreateIC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName,
  675.         LPCTSTR lpszOutput, const void* lpInitData);
  676.     BOOL CreateCompatibleDC(CDC* pDC);
  677.  
  678.     BOOL DeleteDC();
  679.  
  680. // Device-Context Functions
  681.     virtual int SaveDC();
  682.     virtual BOOL RestoreDC(int nSavedDC);
  683.     int GetDeviceCaps(int nIndex) const;
  684.     UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags);
  685.     UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags);
  686.     BOOL ResetDC(const DEVMODE* lpDevMode);
  687.  
  688. // Drawing-Tool Functions
  689.     CPoint GetBrushOrg() const;
  690.     CPoint SetBrushOrg(int x, int y);
  691.     CPoint SetBrushOrg(POINT point);
  692.     int EnumObjects(int nObjectType,
  693.             int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData);
  694.  
  695. // Type-safe selection helpers
  696. public:
  697.     virtual CGdiObject* SelectStockObject(int nIndex);
  698.     CPen* SelectObject(CPen* pPen);
  699.     CBrush* SelectObject(CBrush* pBrush);
  700.     virtual CFont* SelectObject(CFont* pFont);
  701.     CBitmap* SelectObject(CBitmap* pBitmap);
  702.     int SelectObject(CRgn* pRgn);       // special return for regions
  703.     CGdiObject* SelectObject(CGdiObject* pObject);
  704.         // CGdiObject* provided so compiler doesn't use SelectObject(HGDIOBJ)
  705.  
  706. // Color and Color Palette Functions
  707.     COLORREF GetNearestColor(COLORREF crColor) const;
  708.     CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground);
  709.     UINT RealizePalette();
  710.     void UpdateColors();
  711.  
  712. // Drawing-Attribute Functions
  713.     COLORREF GetBkColor() const;
  714.     int GetBkMode() const;
  715.     int GetPolyFillMode() const;
  716.     int GetROP2() const;
  717.     int GetStretchBltMode() const;
  718.     COLORREF GetTextColor() const;
  719.  
  720.     virtual COLORREF SetBkColor(COLORREF crColor);
  721.     int SetBkMode(int nBkMode);
  722.     int SetPolyFillMode(int nPolyFillMode);
  723.     int SetROP2(int nDrawMode);
  724.     int SetStretchBltMode(int nStretchMode);
  725.     virtual COLORREF SetTextColor(COLORREF crColor);
  726.  
  727.     BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const;
  728.     BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust);
  729.  
  730. // Mapping Functions
  731.     int GetMapMode() const;
  732.     CPoint GetViewportOrg() const;
  733.     virtual int SetMapMode(int nMapMode);
  734.     // Viewport Origin
  735.     virtual CPoint SetViewportOrg(int x, int y);
  736.             CPoint SetViewportOrg(POINT point);
  737.     virtual CPoint OffsetViewportOrg(int nWidth, int nHeight);
  738.  
  739.     // Viewport Extent
  740.     CSize GetViewportExt() const;
  741.     virtual CSize SetViewportExt(int cx, int cy);
  742.             CSize SetViewportExt(SIZE size);
  743.     virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
  744.  
  745.     // Window Origin
  746.     CPoint GetWindowOrg() const;
  747.     CPoint SetWindowOrg(int x, int y);
  748.     CPoint SetWindowOrg(POINT point);
  749.     CPoint OffsetWindowOrg(int nWidth, int nHeight);
  750.  
  751.     // Window extent
  752.     CSize GetWindowExt() const;
  753.     virtual CSize SetWindowExt(int cx, int cy);
  754.             CSize SetWindowExt(SIZE size);
  755.     virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
  756.  
  757. // Coordinate Functions
  758.     void DPtoLP(LPPOINT lpPoints, int nCount = 1) const;
  759.     void DPtoLP(LPRECT lpRect) const;
  760.     void DPtoLP(LPSIZE lpSize) const;
  761.     void LPtoDP(LPPOINT lpPoints, int nCount = 1) const;
  762.     void LPtoDP(LPRECT lpRect) const;
  763.     void LPtoDP(LPSIZE lpSize) const;
  764.  
  765. // Special Coordinate Functions (useful for dealing with metafiles and OLE)
  766.     void DPtoHIMETRIC(LPSIZE lpSize) const;
  767.     void LPtoHIMETRIC(LPSIZE lpSize) const;
  768.     void HIMETRICtoDP(LPSIZE lpSize) const;
  769.     void HIMETRICtoLP(LPSIZE lpSize) const;
  770.  
  771. // Region Functions
  772.     BOOL FillRgn(CRgn* pRgn, CBrush* pBrush);
  773.     BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight);
  774.     BOOL InvertRgn(CRgn* pRgn);
  775.     BOOL PaintRgn(CRgn* pRgn);
  776.  
  777. // Clipping Functions
  778.     virtual int GetClipBox(LPRECT lpRect) const;
  779.     virtual BOOL PtVisible(int x, int y) const;
  780.             BOOL PtVisible(POINT point) const;
  781.     virtual BOOL RectVisible(LPCRECT lpRect) const;
  782.             int SelectClipRgn(CRgn* pRgn);
  783.             int ExcludeClipRect(int x1, int y1, int x2, int y2);
  784.             int ExcludeClipRect(LPCRECT lpRect);
  785.             int ExcludeUpdateRgn(CWnd* pWnd);
  786.             int IntersectClipRect(int x1, int y1, int x2, int y2);
  787.             int IntersectClipRect(LPCRECT lpRect);
  788.             int OffsetClipRgn(int x, int y);
  789.             int OffsetClipRgn(SIZE size);
  790.     int SelectClipRgn(CRgn* pRgn, int nMode);
  791.  
  792. // Line-Output Functions
  793.     CPoint GetCurrentPosition() const;
  794.     CPoint MoveTo(int x, int y);
  795.     CPoint MoveTo(POINT point);
  796.     BOOL LineTo(int x, int y);
  797.     BOOL LineTo(POINT point);
  798.     BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  799.     BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
  800.     BOOL Polyline(LPPOINT lpPoints, int nCount);
  801.  
  802.     BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle);
  803.     BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  804.     BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
  805.     int GetArcDirection() const;
  806.     int SetArcDirection(int nArcDirection);
  807.  
  808.     BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount);
  809.     BOOL PolylineTo(const POINT* lpPoints, int nCount);
  810.     BOOL PolyPolyline(const POINT* lpPoints,
  811.         const DWORD* lpPolyPoints, int nCount);
  812.  
  813.     BOOL PolyBezier(const POINT* lpPoints, int nCount);
  814.     BOOL PolyBezierTo(const POINT* lpPoints, int nCount);
  815.  
  816. // Simple Drawing Functions
  817.     void FillRect(LPCRECT lpRect, CBrush* pBrush);
  818.     void FrameRect(LPCRECT lpRect, CBrush* pBrush);
  819.     void InvertRect(LPCRECT lpRect);
  820.     BOOL DrawIcon(int x, int y, HICON hIcon);
  821.     BOOL DrawIcon(POINT point, HICON hIcon);
  822. #if (WINVER >= 0x400)
  823.     BOOL DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags,
  824.         HBRUSH hBrush = NULL);
  825.     BOOL DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags,
  826.         CBrush* pBrush = NULL);
  827.     BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,
  828.         HBRUSH hBrush = NULL);
  829.     BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,
  830.         CBrush* pBrush = NULL);
  831.     BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,
  832.         BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL);
  833.     BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,
  834.         BOOL bPrefixText = TRUE, int nTextLen = 0, CBrush* pBrush = NULL);
  835.     BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,
  836.         LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL);
  837.     BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,
  838.         LPARAM lData, UINT nFlags, CBrush* pBrush = NULL);
  839. #endif
  840.  
  841. // Ellipse and Polygon Functions
  842.     BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3,
  843.         int x4, int y4);
  844.     BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
  845.     void DrawFocusRect(LPCRECT lpRect);
  846.     BOOL Ellipse(int x1, int y1, int x2, int y2);
  847.     BOOL Ellipse(LPCRECT lpRect);
  848.     BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  849.     BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
  850.     BOOL Polygon(LPPOINT lpPoints, int nCount);
  851.     BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount);
  852.     BOOL Rectangle(int x1, int y1, int x2, int y2);
  853.     BOOL Rectangle(LPCRECT lpRect);
  854.     BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
  855.     BOOL RoundRect(LPCRECT lpRect, POINT point);
  856.  
  857. // Bitmap Functions
  858.     BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop);
  859.     BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  860.         int xSrc, int ySrc, DWORD dwRop);
  861.     BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  862.         int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop);
  863.     COLORREF GetPixel(int x, int y) const;
  864.     COLORREF GetPixel(POINT point) const;
  865.     COLORREF SetPixel(int x, int y, COLORREF crColor);
  866.     COLORREF SetPixel(POINT point, COLORREF crColor);
  867.     BOOL FloodFill(int x, int y, COLORREF crColor);
  868.     BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType);
  869.     BOOL MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  870.         int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask,
  871.         DWORD dwRop);
  872.     BOOL PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc,
  873.         int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask);
  874.     BOOL SetPixelV(int x, int y, COLORREF crColor);
  875.     BOOL SetPixelV(POINT point, COLORREF crColor);
  876.  
  877. // Text Functions
  878.     virtual BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount);
  879.             BOOL TextOut(int x, int y, const CString& str);
  880.     virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
  881.                 LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths);
  882.             BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
  883.                 const CString& str, LPINT lpDxWidths);
  884.     virtual CSize TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount,
  885.                 int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
  886.             CSize TabbedTextOut(int x, int y, const CString& str,
  887.                 int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
  888.     virtual int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect,
  889.                 UINT nFormat);
  890.             int DrawText(const CString& str, LPRECT lpRect, UINT nFormat);
  891.     CSize GetTextExtent(LPCTSTR lpszString, int nCount) const;
  892.     CSize GetTextExtent(const CString& str) const;
  893.     CSize GetOutputTextExtent(LPCTSTR lpszString, int nCount) const;
  894.     CSize GetOutputTextExtent(const CString& str) const;
  895.     CSize GetTabbedTextExtent(LPCTSTR lpszString, int nCount,
  896.         int nTabPositions, LPINT lpnTabStopPositions) const;
  897.     CSize GetTabbedTextExtent(const CString& str,
  898.         int nTabPositions, LPINT lpnTabStopPositions) const;
  899.     CSize GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount,
  900.         int nTabPositions, LPINT lpnTabStopPositions) const;
  901.     CSize GetOutputTabbedTextExtent(const CString& str,
  902.         int nTabPositions, LPINT lpnTabStopPositions) const;
  903.     virtual BOOL GrayString(CBrush* pBrush,
  904.         BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData,
  905.             int nCount, int x, int y, int nWidth, int nHeight);
  906.     UINT GetTextAlign() const;
  907.     UINT SetTextAlign(UINT nFlags);
  908.     int GetTextFace(int nCount, LPTSTR lpszFacename) const;
  909.     int GetTextFace(CString& rString) const;
  910.     BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const;
  911.     BOOL GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const;
  912.     int SetTextJustification(int nBreakExtra, int nBreakCount);
  913.     int GetTextCharacterExtra() const;
  914.     int SetTextCharacterExtra(int nCharExtra);
  915.  
  916. // Advanced Drawing
  917. #if (WINVER >= 0x400)
  918.     BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags);
  919.     BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState);
  920. #endif
  921.  
  922. // Scrolling Functions
  923.     BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip,
  924.         CRgn* pRgnUpdate, LPRECT lpRectUpdate);
  925.  
  926. // Font Functions
  927.     BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
  928.     BOOL GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
  929.     DWORD SetMapperFlags(DWORD dwFlag);
  930.     CSize GetAspectRatioFilter() const;
  931.  
  932.     BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const;
  933.     DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const;
  934.     int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const;
  935.     UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const;
  936.     DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm,
  937.         DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const;
  938.  
  939.     BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar,
  940.         LPABCFLOAT lpABCF) const;
  941.     BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar,
  942.         float* lpFloatBuffer) const;
  943.  
  944. // Printer/Device Escape Functions
  945.     virtual int Escape(int nEscape, int nCount,
  946.         LPCSTR lpszInData, LPVOID lpOutData);
  947.     int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData,
  948.         int nOutputSize, LPSTR lpszOutputData);
  949.     int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData);
  950.  
  951.     // Escape helpers
  952.     int StartDoc(LPCTSTR lpszDocName);  // old Win3.0 version
  953.     int StartDoc(LPDOCINFO lpDocInfo);
  954.     int StartPage();
  955.     int EndPage();
  956.     int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int));
  957.     int AbortDoc();
  958.     int EndDoc();
  959.  
  960. // MetaFile Functions
  961.     BOOL PlayMetaFile(HMETAFILE hMF);
  962.     BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds);
  963.     BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData);
  964.         // can be used for enhanced metafiles only
  965.  
  966. // Path Functions
  967.     BOOL AbortPath();
  968.     BOOL BeginPath();
  969.     BOOL CloseFigure();
  970.     BOOL EndPath();
  971.     BOOL FillPath();
  972.     BOOL FlattenPath();
  973.     BOOL StrokeAndFillPath();
  974.     BOOL StrokePath();
  975.     BOOL WidenPath();
  976.     float GetMiterLimit() const;
  977.     BOOL SetMiterLimit(float fMiterLimit);
  978.     int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const;
  979.     BOOL SelectClipPath(int nMode);
  980.  
  981. // Misc Helper Functions
  982.     static CBrush* PASCAL GetHalftoneBrush();
  983.     void DrawDragRect(LPCRECT lpRect, SIZE size,
  984.         LPCRECT lpRectLast, SIZE sizeLast,
  985.         CBrush* pBrush = NULL, CBrush* pBrushLast = NULL);
  986.     void FillSolidRect(LPCRECT lpRect, COLORREF clr);
  987.     void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr);
  988.     void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight);
  989.     void Draw3dRect(int x, int y, int cx, int cy,
  990.         COLORREF clrTopLeft, COLORREF clrBottomRight);
  991.  
  992. // Implementation
  993. public:
  994.     virtual ~CDC();
  995. #ifdef _DEBUG
  996.     virtual void AssertValid() const;
  997.     virtual void Dump(CDumpContext& dc) const;
  998. #endif
  999.  
  1000.     // advanced use and implementation
  1001.     BOOL m_bPrinting;
  1002.     HGDIOBJ SelectObject(HGDIOBJ);      // do not use for regions
  1003.  
  1004. protected:
  1005.     // used for implementation of non-virtual SelectObject calls
  1006.     static CGdiObject* PASCAL SelectGdiObject(HDC hDC, HGDIOBJ h);
  1007. };
  1008.  
  1009. /////////////////////////////////////////////////////////////////////////////
  1010. // CDC Helpers
  1011.  
  1012. class CPaintDC : public CDC
  1013. {
  1014.     DECLARE_DYNAMIC(CPaintDC)
  1015.  
  1016. // Constructors
  1017. public:
  1018.     CPaintDC(CWnd* pWnd);   // BeginPaint
  1019.  
  1020. // Attributes
  1021. protected:
  1022.     HWND m_hWnd;
  1023. public:
  1024.     PAINTSTRUCT m_ps;       // actual paint struct!
  1025.  
  1026. // Implementation
  1027. public:
  1028.     virtual ~CPaintDC();
  1029. #ifdef _DEBUG
  1030.     virtual void AssertValid() const;
  1031.     virtual void Dump(CDumpContext& dc) const;
  1032. #endif
  1033. };
  1034.  
  1035. class CClientDC : public CDC
  1036. {
  1037.     DECLARE_DYNAMIC(CClientDC)
  1038.  
  1039. // Constructors
  1040. public:
  1041.     CClientDC(CWnd* pWnd);
  1042.  
  1043. // Attributes
  1044. protected:
  1045.     HWND m_hWnd;
  1046.  
  1047. // Implementation
  1048. public:
  1049.     virtual ~CClientDC();
  1050. #ifdef _DEBUG
  1051.     virtual void AssertValid() const;
  1052.     virtual void Dump(CDumpContext& dc) const;
  1053. #endif
  1054. };
  1055.  
  1056. class CWindowDC : public CDC
  1057. {
  1058.     DECLARE_DYNAMIC(CWindowDC)
  1059.  
  1060. // Constructors
  1061. public:
  1062.     CWindowDC(CWnd* pWnd);
  1063.  
  1064. // Attributes
  1065. protected:
  1066.     HWND m_hWnd;
  1067.  
  1068. // Implementation
  1069. public:
  1070.     virtual ~CWindowDC();
  1071. #ifdef _DEBUG
  1072.     virtual void AssertValid() const;
  1073.     virtual void Dump(CDumpContext& dc) const;
  1074. #endif
  1075. };
  1076.  
  1077. /////////////////////////////////////////////////////////////////////////////
  1078. // CMenu
  1079.  
  1080. class CMenu : public CObject
  1081. {
  1082.     DECLARE_DYNCREATE(CMenu)
  1083. public:
  1084.  
  1085. // Constructors
  1086.     CMenu();
  1087.  
  1088.     BOOL CreateMenu();
  1089.     BOOL CreatePopupMenu();
  1090.     BOOL LoadMenu(LPCTSTR lpszResourceName);
  1091.     BOOL LoadMenu(UINT nIDResource);
  1092.     BOOL LoadMenuIndirect(const void* lpMenuTemplate);
  1093.     BOOL DestroyMenu();
  1094.  
  1095. // Attributes
  1096.     HMENU m_hMenu;          // must be first data member
  1097.     HMENU GetSafeHmenu() const;
  1098.     operator HMENU() const;
  1099.  
  1100.     static CMenu* PASCAL FromHandle(HMENU hMenu);
  1101.     static void PASCAL DeleteTempMap();
  1102.     BOOL Attach(HMENU hMenu);
  1103.     HMENU Detach();
  1104.  
  1105. // CMenu Operations
  1106.     BOOL DeleteMenu(UINT nPosition, UINT nFlags);
  1107.     BOOL TrackPopupMenu(UINT nFlags, int x, int y,
  1108.                         CWnd* pWnd, LPCRECT lpRect = 0);
  1109.     BOOL operator==(const CMenu& menu) const;
  1110.     BOOL operator!=(const CMenu& menu) const;
  1111.  
  1112. // CMenuItem Operations
  1113.     BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0,
  1114.                     LPCTSTR lpszNewItem = NULL);
  1115.     BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp);
  1116.     UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck);
  1117.     UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable);
  1118.     UINT GetMenuItemCount() const;
  1119.     UINT GetMenuItemID(int nPos) const;
  1120.     UINT GetMenuState(UINT nID, UINT nFlags) const;
  1121.     int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount,
  1122.                     UINT nFlags) const;
  1123.     int GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const;
  1124.     BOOL GetMenuItemInfo(UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo,
  1125.                     BOOL fByPos = FALSE);
  1126.     CMenu* GetSubMenu(int nPos) const;
  1127.     BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
  1128.                     LPCTSTR lpszNewItem = NULL);
  1129.     BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
  1130.                     const CBitmap* pBmp);
  1131.     BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
  1132.                     LPCTSTR lpszNewItem = NULL);
  1133.     BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
  1134.                     const CBitmap* pBmp);
  1135.     BOOL RemoveMenu(UINT nPosition, UINT nFlags);
  1136.     BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags,
  1137.                     const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked);
  1138.     BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags);
  1139.     BOOL SetDefaultItem(UINT uItem, BOOL fByPos = FALSE);
  1140.     UINT GetDefaultItem(UINT gmdiFlags, BOOL fByPos = FALSE);
  1141.  
  1142. // Context Help Functions
  1143.     BOOL SetMenuContextHelpId(DWORD dwContextHelpId);
  1144.     DWORD GetMenuContextHelpId() const;
  1145.  
  1146. // Overridables (must override draw and measure for owner-draw menu items)
  1147.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1148.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  1149.  
  1150. // Implementation
  1151. public:
  1152.     virtual ~CMenu();
  1153. #ifdef _DEBUG
  1154.     virtual void AssertValid() const;
  1155.     virtual void Dump(CDumpContext& dc) const;
  1156. #endif
  1157.     static CMenu* PASCAL CMenu::FromHandlePermanent(HMENU hMenu);
  1158. };
  1159.  
  1160. /////////////////////////////////////////////////////////////////////////////
  1161. // Window message map handling
  1162.  
  1163. struct AFX_MSGMAP_ENTRY;       // declared below after CWnd
  1164.  
  1165. struct AFX_MSGMAP
  1166. {
  1167. #ifdef _AFXDLL
  1168.     const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)();
  1169. #else
  1170.     const AFX_MSGMAP* pBaseMap;
  1171. #endif
  1172.     const AFX_MSGMAP_ENTRY* lpEntries;
  1173. };
  1174.  
  1175. #ifdef _AFXDLL
  1176. #define DECLARE_MESSAGE_MAP() \
  1177. private: \
  1178.     static const AFX_MSGMAP_ENTRY _messageEntries[]; \
  1179. protected: \
  1180.     static AFX_DATA const AFX_MSGMAP messageMap; \
  1181.     static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \
  1182.     virtual const AFX_MSGMAP* GetMessageMap() const; \
  1183.  
  1184. #else
  1185. #define DECLARE_MESSAGE_MAP() \
  1186. private: \
  1187.     static const AFX_MSGMAP_ENTRY _messageEntries[]; \
  1188. protected: \
  1189.     static AFX_DATA const AFX_MSGMAP messageMap; \
  1190.     virtual const AFX_MSGMAP* GetMessageMap() const; \
  1191.  
  1192. #endif
  1193.  
  1194. #ifdef _AFXDLL
  1195. #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
  1196.     const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \
  1197.         { return &baseClass::messageMap; } \
  1198.     const AFX_MSGMAP* theClass::GetMessageMap() const \
  1199.         { return &theClass::messageMap; } \
  1200.     AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
  1201.     { &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \
  1202.     AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
  1203.     { \
  1204.  
  1205. #else
  1206. #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
  1207.     const AFX_MSGMAP* theClass::GetMessageMap() const \
  1208.         { return &theClass::messageMap; } \
  1209.     AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
  1210.     { &baseClass::messageMap, &theClass::_messageEntries[0] }; \
  1211.     AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
  1212.     { \
  1213.  
  1214. #endif
  1215.  
  1216. #define END_MESSAGE_MAP() \
  1217.         {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \
  1218.     }; \
  1219.  
  1220. // Message map signature values and macros in separate header
  1221. #include <afxmsg_.h>
  1222.  
  1223. /////////////////////////////////////////////////////////////////////////////
  1224. // Dialog data exchange (DDX_) and validation (DDV_)
  1225.  
  1226. // CDataExchange - for data exchange and validation
  1227. class CDataExchange
  1228. {
  1229. // Attributes
  1230. public:
  1231.     BOOL m_bSaveAndValidate;   // TRUE => save and validate data
  1232.     CWnd* m_pDlgWnd;           // container usually a dialog
  1233.  
  1234. // Operations (for implementors of DDX and DDV procs)
  1235.     HWND PrepareCtrl(int nIDC);     // return HWND of control
  1236.     HWND PrepareEditCtrl(int nIDC); // return HWND of control
  1237.     void Fail();                    // will throw exception
  1238.  
  1239. #ifndef _AFX_NO_OCC_SUPPORT
  1240.     CWnd* PrepareOleCtrl(int nIDC); // for OLE controls in dialog
  1241. #endif
  1242.  
  1243. // Implementation
  1244.     CDataExchange(CWnd* pDlgWnd, BOOL bSaveAndValidate);
  1245.  
  1246.     HWND m_hWndLastControl;    // last control used (for validation)
  1247.     BOOL m_bEditLastControl;   // last control was an edit item
  1248. };
  1249.  
  1250. #include <afxdd_.h>     // standard DDX_ and DDV_ routines
  1251.  
  1252. /////////////////////////////////////////////////////////////////////////////
  1253. // OLE types
  1254.  
  1255. typedef LONG HRESULT;
  1256.  
  1257. struct IUnknown;
  1258. typedef IUnknown* LPUNKNOWN;
  1259.  
  1260. struct IDispatch;
  1261. typedef IDispatch* LPDISPATCH;
  1262.  
  1263. struct IConnectionPoint;
  1264. typedef IConnectionPoint* LPCONNECTIONPOINT;
  1265.  
  1266. struct IEnumOLEVERB;
  1267. typedef IEnumOLEVERB* LPENUMOLEVERB;
  1268.  
  1269. typedef struct _GUID GUID;
  1270. typedef GUID IID;
  1271. typedef GUID CLSID;
  1272. #ifndef _REFCLSID_DEFINED
  1273. #define REFCLSID const CLSID &
  1274. #endif
  1275.  
  1276. typedef long DISPID;
  1277. typedef unsigned short VARTYPE;
  1278. typedef long SCODE;
  1279.  
  1280. #if defined(WIN32) && !defined(OLE2ANSI)
  1281. typedef WCHAR OLECHAR;
  1282. #else
  1283. typedef char OLECHAR;
  1284. #endif
  1285. typedef OLECHAR* BSTR;
  1286.  
  1287. struct tagDISPPARAMS;
  1288. typedef tagDISPPARAMS DISPPARAMS;
  1289.  
  1290. struct tagVARIANT;
  1291. typedef tagVARIANT VARIANT;
  1292.  
  1293. struct ITypeInfo;
  1294. typedef ITypeInfo* LPTYPEINFO;
  1295.  
  1296. struct ITypeLib;
  1297. typedef ITypeLib* LPTYPELIB;
  1298.  
  1299. /////////////////////////////////////////////////////////////////////////////
  1300. // CCmdTarget
  1301.  
  1302. // private structures
  1303. struct AFX_CMDHANDLERINFO;  // info about where the command is handled
  1304. struct AFX_EVENT;           // info about an event
  1305. class CTypeLibCache;        // cache for OLE type libraries
  1306.  
  1307. /////////////////////////////////////////////////////////////////////////////
  1308. // OLE interface map handling (more in AFXDISP.H)
  1309.  
  1310. #ifndef _AFX_NO_OLE_SUPPORT
  1311.  
  1312. struct AFX_INTERFACEMAP_ENTRY
  1313. {
  1314.     const void* piid;       // the interface id (IID) (NULL for aggregate)
  1315.     size_t nOffset;         // offset of the interface vtable from m_unknown
  1316. };
  1317.  
  1318. struct AFX_INTERFACEMAP
  1319. {
  1320. #ifdef _AFXDLL
  1321.     const AFX_INTERFACEMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class
  1322. #else
  1323.     const AFX_INTERFACEMAP* pBaseMap;
  1324. #endif
  1325.     const AFX_INTERFACEMAP_ENTRY* pEntry; // map for this class
  1326. };
  1327.  
  1328.  
  1329. #ifdef _AFXDLL
  1330. #define DECLARE_INTERFACE_MAP() \
  1331. private: \
  1332.     static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \
  1333. protected: \
  1334.     static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \
  1335.     static const AFX_INTERFACEMAP* PASCAL _GetBaseInterfaceMap(); \
  1336.     virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \
  1337.  
  1338. #else
  1339. #define DECLARE_INTERFACE_MAP() \
  1340. private: \
  1341.     static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \
  1342. protected: \
  1343.     static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \
  1344.     virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \
  1345.  
  1346. #endif
  1347.  
  1348. #endif //!_AFX_NO_OLE_SUPPORT
  1349.  
  1350. /////////////////////////////////////////////////////////////////////////////
  1351. // OLE dispatch map handling (more in AFXDISP.H)
  1352.  
  1353. #ifndef _AFX_NO_OLE_SUPPORT
  1354.  
  1355. struct AFX_DISPMAP_ENTRY;
  1356.  
  1357. struct AFX_DISPMAP
  1358. {
  1359. #ifdef _AFXDLL
  1360.     const AFX_DISPMAP* (PASCAL* pfnGetBaseMap)();
  1361. #else
  1362.     const AFX_DISPMAP* pBaseMap;
  1363. #endif
  1364.     const AFX_DISPMAP_ENTRY* lpEntries;
  1365.     UINT* lpEntryCount;
  1366.     DWORD* lpStockPropMask;
  1367. };
  1368.  
  1369. #ifdef _AFXDLL
  1370. #define DECLARE_DISPATCH_MAP() \
  1371. private: \
  1372.     static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \
  1373.     static UINT _dispatchEntryCount; \
  1374.     static DWORD _dwStockPropMask; \
  1375. protected: \
  1376.     static AFX_DATA const AFX_DISPMAP dispatchMap; \
  1377.     static const AFX_DISPMAP* PASCAL _GetBaseDispatchMap(); \
  1378.     virtual const AFX_DISPMAP* GetDispatchMap() const; \
  1379.  
  1380. #else
  1381. #define DECLARE_DISPATCH_MAP() \
  1382. private: \
  1383.     static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \
  1384.     static UINT _dispatchEntryCount; \
  1385.     static DWORD _dwStockPropMask; \
  1386. protected: \
  1387.     static AFX_DATA const AFX_DISPMAP dispatchMap; \
  1388.     virtual const AFX_DISPMAP* GetDispatchMap() const; \
  1389.  
  1390. #endif
  1391.  
  1392. #endif //!_AFX_NO_OLE_SUPPORT
  1393.  
  1394. /////////////////////////////////////////////////////////////////////////////
  1395. // OLE Document Object command target handling
  1396.  
  1397. #ifndef _AFX_NO_DOCOBJECT_SUPPORT
  1398.  
  1399. struct AFX_OLECMDMAP_ENTRY
  1400. {
  1401.    const GUID* pguid;   // id of the command group
  1402.    ULONG       cmdID;   // OLECMD ID
  1403.    UINT        nID;     // corresponding WM_COMMAND message ID
  1404. };
  1405.  
  1406. struct AFX_OLECMDMAP
  1407. {
  1408. #ifdef _AFXDLL
  1409.     const AFX_OLECMDMAP* (PASCAL* pfnGetBaseMap)();
  1410. #else
  1411.     const AFX_OLECMDMAP* pBaseMap;
  1412. #endif
  1413.     const AFX_OLECMDMAP_ENTRY* lpEntries;
  1414. };
  1415.  
  1416. #ifdef _AFXDLL
  1417. #define DECLARE_OLECMD_MAP() \
  1418. private: \
  1419.     static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \
  1420. protected: \
  1421.     static AFX_DATA const AFX_OLECMDMAP commandMap; \
  1422.     static const AFX_OLECMDMAP* PASCAL _GetBaseCommandMap(); \
  1423.     virtual const AFX_OLECMDMAP* GetCommandMap() const; \
  1424.  
  1425. #else
  1426. #define DECLARE_OLECMD_MAP() \
  1427. private: \
  1428.     static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \
  1429. protected: \
  1430.     static AFX_DATA const AFX_OLECMDMAP commandMap; \
  1431.     virtual const AFX_OLECMDMAP* GetCommandMap() const; \
  1432.  
  1433. #endif
  1434.  
  1435. #ifdef _AFXDLL
  1436. #define BEGIN_OLECMD_MAP(theClass, baseClass) \
  1437.     const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \
  1438.         { return &baseClass::commandMap; } \
  1439.     const AFX_OLECMDMAP* theClass::GetCommandMap() const \
  1440.         { return &theClass::commandMap; } \
  1441.     AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
  1442.     { &theClass::_GetBaseCommandMap, &theClass::_commandEntries[0] }; \
  1443.     AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
  1444.     { \
  1445.  
  1446. #else
  1447. #define BEGIN_OLECMD_MAP(theClass, baseClass) \
  1448.     const AFX_OLECMDMAP* theClass::GetCommandMap() const \
  1449.         { return &theClass::commandMap; } \
  1450.     AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
  1451.     { &baseClass::commandMap, &theClass::_commandEntries[0] }; \
  1452.     AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
  1453.     { \
  1454.  
  1455. #endif
  1456.  
  1457. #define END_OLECMD_MAP() \
  1458.         {NULL, 0, 0} \
  1459.     }; \
  1460.  
  1461. class COleCmdUI;
  1462.  
  1463. #endif //!_AFX_NO_DOCOBJECT_SUPPORT
  1464.  
  1465. /////////////////////////////////////////////////////////////////////////////
  1466. // OLE event sink map handling (more in AFXDISP.H)
  1467.  
  1468. #ifndef _AFX_NO_OCC_SUPPORT
  1469.  
  1470. struct AFX_EVENTSINKMAP_ENTRY;
  1471.  
  1472. struct AFX_EVENTSINKMAP
  1473. {
  1474. #ifdef _AFXDLL
  1475.     const AFX_EVENTSINKMAP* (PASCAL* pfnGetBaseMap)();
  1476. #else
  1477.     const AFX_EVENTSINKMAP* pBaseMap;
  1478. #endif
  1479.     const AFX_EVENTSINKMAP_ENTRY* lpEntries;
  1480.     UINT* lpEntryCount;
  1481. };
  1482.  
  1483. #ifdef _AFXDLL
  1484. #define DECLARE_EVENTSINK_MAP() \
  1485. private: \
  1486.     static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \
  1487.     static UINT _eventsinkEntryCount; \
  1488. protected: \
  1489.     static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \
  1490.     static const AFX_EVENTSINKMAP* PASCAL _GetBaseEventSinkMap(); \
  1491.     virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \
  1492.  
  1493. #else
  1494. #define DECLARE_EVENTSINK_MAP() \
  1495. private: \
  1496.     static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \
  1497.     static UINT _eventsinkEntryCount; \
  1498. protected: \
  1499.     static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \
  1500.     virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \
  1501.  
  1502. #endif
  1503.  
  1504. #endif //!_AFX_NO_OCC_SUPPORT
  1505.  
  1506. /////////////////////////////////////////////////////////////////////////////
  1507. // OLE connection map handling (more in AFXDISP.H)
  1508.  
  1509. #ifndef _AFX_NO_OLE_SUPPORT
  1510.  
  1511. struct AFX_CONNECTIONMAP_ENTRY
  1512. {
  1513.     const void* piid;   // the interface id (IID)
  1514.     size_t nOffset;         // offset of the interface vtable from m_unknown
  1515. };
  1516.  
  1517. struct AFX_CONNECTIONMAP
  1518. {
  1519. #ifdef _AFXDLL
  1520.     const AFX_CONNECTIONMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class
  1521. #else
  1522.     const AFX_CONNECTIONMAP* pBaseMap;
  1523. #endif
  1524.     const AFX_CONNECTIONMAP_ENTRY* pEntry; // map for this class
  1525. };
  1526.  
  1527. #ifdef _AFXDLL
  1528. #define DECLARE_CONNECTION_MAP() \
  1529. private: \
  1530.     static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \
  1531. protected: \
  1532.     static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \
  1533.     static const AFX_CONNECTIONMAP* PASCAL _GetBaseConnectionMap(); \
  1534.     virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \
  1535.  
  1536. #else
  1537. #define DECLARE_CONNECTION_MAP() \
  1538. private: \
  1539.     static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \
  1540. protected: \
  1541.     static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \
  1542.     virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \
  1543.  
  1544. #endif
  1545.  
  1546. #endif //!_AFX_NO_OLE_SUPPORT
  1547.  
  1548. /////////////////////////////////////////////////////////////////////////////
  1549. // CCmdTarget proper
  1550.  
  1551. #ifndef _AFX_NO_OCC_SUPPORT
  1552. class COccManager;      // forward reference (see ..\src\occimpl.h)
  1553. #endif
  1554.  
  1555. #ifdef _AFXDLL
  1556. class CCmdTarget : public CObject
  1557. #else
  1558. class AFX_NOVTABLE CCmdTarget : public CObject
  1559. #endif
  1560. {
  1561.     DECLARE_DYNAMIC(CCmdTarget)
  1562. protected:
  1563.  
  1564. public:
  1565. // Constructors
  1566.     CCmdTarget();
  1567.  
  1568. // Attributes
  1569.     LPDISPATCH GetIDispatch(BOOL bAddRef);
  1570.         // retrieve IDispatch part of CCmdTarget
  1571.     static CCmdTarget* PASCAL FromIDispatch(LPDISPATCH lpDispatch);
  1572.         // map LPDISPATCH back to CCmdTarget* (inverse of GetIDispatch)
  1573.     BOOL IsResultExpected();
  1574.         // returns TRUE if automation function should return a value
  1575.  
  1576. // Operations
  1577.     void EnableAutomation();
  1578.         // call in constructor to wire up IDispatch
  1579.     void EnableConnections();
  1580.         // call in constructor to wire up IConnectionPointContainer
  1581.  
  1582.     void BeginWaitCursor();
  1583.     void EndWaitCursor();
  1584.     void RestoreWaitCursor();       // call after messagebox
  1585.  
  1586. #ifndef _AFX_NO_OLE_SUPPORT
  1587.     // dispatch OLE verbs through the message map
  1588.     BOOL EnumOleVerbs(LPENUMOLEVERB* ppenumOleVerb);
  1589.     BOOL DoOleVerb(LONG iVerb, LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect);
  1590. #endif
  1591.  
  1592. // Overridables
  1593.     // route and dispatch standard command message types
  1594.     //   (more sophisticated than OnCommand)
  1595.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  1596.         AFX_CMDHANDLERINFO* pHandlerInfo);
  1597.  
  1598. #ifndef _AFX_NO_OLE_SUPPORT
  1599.     // called when last OLE reference is released
  1600.     virtual void OnFinalRelease();
  1601. #endif
  1602.  
  1603. #ifndef _AFX_NO_OLE_SUPPORT
  1604.     // called before dispatching to an automation handler function
  1605.     virtual BOOL IsInvokeAllowed(DISPID dispid);
  1606. #endif
  1607.  
  1608. #ifndef _AFX_NO_OLE_SUPPORT
  1609.     // support for OLE type libraries
  1610.     void EnableTypeLib();
  1611.     HRESULT GetTypeInfoOfGuid(LCID lcid, const GUID& guid,
  1612.         LPTYPEINFO* ppTypeInfo);
  1613.     virtual BOOL GetDispatchIID(IID* pIID);
  1614.     virtual UINT GetTypeInfoCount();
  1615.     virtual CTypeLibCache* GetTypeLibCache();
  1616.     virtual HRESULT GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib);
  1617. #endif
  1618.  
  1619. // Implementation
  1620. public:
  1621.     virtual ~CCmdTarget();
  1622. #ifdef _DEBUG
  1623.     virtual void Dump(CDumpContext& dc) const;
  1624.     virtual void AssertValid() const;
  1625. #endif
  1626. #ifndef _AFX_NO_OLE_SUPPORT
  1627.     void GetNotSupported();
  1628.     void SetNotSupported();
  1629. #endif
  1630.  
  1631. protected:
  1632.     friend class CView;
  1633.  
  1634.     CView* GetRoutingView();
  1635.     CFrameWnd* GetRoutingFrame();
  1636.     static CView* PASCAL GetRoutingView_();
  1637.     static CFrameWnd* PASCAL GetRoutingFrame_();
  1638.     DECLARE_MESSAGE_MAP()       // base class - no {{ }} macros
  1639.  
  1640. #ifndef _AFX_NO_DOCOBJECT_SUPPORT
  1641.     DECLARE_OLECMD_MAP()
  1642.     friend class COleCmdUI;
  1643. #endif
  1644.  
  1645. #ifndef _AFX_NO_OLE_SUPPORT
  1646.     DECLARE_DISPATCH_MAP()
  1647.     DECLARE_CONNECTION_MAP()
  1648.     DECLARE_INTERFACE_MAP()
  1649.  
  1650. #ifndef _AFX_NO_OCC_SUPPORT
  1651.     DECLARE_EVENTSINK_MAP()
  1652. #endif // !_AFX_NO_OCC_SUPPORT
  1653.  
  1654.     // OLE interface map implementation
  1655. public:
  1656.     // data used when CCmdTarget is made OLE aware
  1657.     long m_dwRef;
  1658.     LPUNKNOWN m_pOuterUnknown;  // external controlling unknown if != NULL
  1659.     DWORD m_xInnerUnknown;  // place-holder for inner controlling unknown
  1660.  
  1661. public:
  1662.     // advanced operations
  1663.     void EnableAggregation();       // call to enable aggregation
  1664.     void ExternalDisconnect();      // forcibly disconnect
  1665.     LPUNKNOWN GetControllingUnknown();
  1666.         // get controlling IUnknown for aggregate creation
  1667.  
  1668.     // these versions do not delegate to m_pOuterUnknown
  1669.     DWORD InternalQueryInterface(const void*, LPVOID* ppvObj);
  1670.     DWORD InternalAddRef();
  1671.     DWORD InternalRelease();
  1672.     // these versions delegate to m_pOuterUnknown
  1673.     DWORD ExternalQueryInterface(const void*, LPVOID* ppvObj);
  1674.     DWORD ExternalAddRef();
  1675.     DWORD ExternalRelease();
  1676.  
  1677.     // implementation helpers
  1678.     LPUNKNOWN GetInterface(const void*);
  1679.     LPUNKNOWN QueryAggregates(const void*);
  1680.  
  1681.     // advanced overrideables for implementation
  1682.     virtual BOOL OnCreateAggregates();
  1683.     virtual LPUNKNOWN GetInterfaceHook(const void*);
  1684.  
  1685.     // OLE automation implementation
  1686. protected:
  1687.     struct XDispatch
  1688.     {
  1689.         DWORD m_vtbl;   // place-holder for IDispatch vtable
  1690. #ifndef _AFX_NO_NESTED_DERIVATION
  1691.         size_t m_nOffset;
  1692. #endif
  1693.     } m_xDispatch;
  1694.     BOOL m_bResultExpected;
  1695.  
  1696.     // member variable-based properties
  1697.     void GetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
  1698.         VARIANT* pvarResult, UINT* puArgErr);
  1699.     SCODE SetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
  1700.         DISPPARAMS* pDispParams, UINT* puArgErr);
  1701.  
  1702.     // DISPID to dispatch map lookup
  1703.     static UINT PASCAL GetEntryCount(const AFX_DISPMAP* pDispMap);
  1704.     const AFX_DISPMAP_ENTRY* PASCAL GetDispEntry(LONG memid);
  1705.     static LONG PASCAL MemberIDFromName(const AFX_DISPMAP* pDispMap, LPCTSTR lpszName);
  1706.  
  1707.     // helpers for member function calling implementation
  1708.     static UINT PASCAL GetStackSize(const BYTE* pbParams, VARTYPE vtResult);
  1709. #ifdef _PPC_
  1710.     SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
  1711.         void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
  1712.         UINT* puArgErr, VARIANT* rgTempVars, UINT nSizeArgs);
  1713. #else
  1714.     SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
  1715.         void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
  1716.         UINT* puArgErr, VARIANT* rgTempVars);
  1717. #endif
  1718.     SCODE CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags,
  1719.         VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr);
  1720.  
  1721.     friend class COleDispatchImpl;
  1722.  
  1723. #ifndef _AFX_NO_OCC_SUPPORT
  1724. public:
  1725.     // OLE event sink implementation
  1726.     BOOL OnEvent(UINT idCtrl, AFX_EVENT* pEvent,
  1727.         AFX_CMDHANDLERINFO* pHandlerInfo);
  1728. protected:
  1729.     const AFX_EVENTSINKMAP_ENTRY* PASCAL GetEventSinkEntry(UINT idCtrl,
  1730.         AFX_EVENT* pEvent);
  1731. #endif // !_AFX_NO_OCC_SUPPORT
  1732.  
  1733.     // OLE connection implementation
  1734.     struct XConnPtContainer
  1735.     {
  1736.         DWORD m_vtbl;   // place-holder for IConnectionPointContainer vtable
  1737. #ifndef _AFX_NO_NESTED_DERIVATION
  1738.         size_t m_nOffset;
  1739. #endif
  1740.     } m_xConnPtContainer;
  1741.  
  1742. #ifdef _AFXDLL
  1743.     AFX_MODULE_STATE* m_pModuleState;
  1744.     friend class CInnerUnknown;
  1745.     friend UINT APIENTRY _AfxThreadEntry(void* pParam);
  1746. #endif
  1747.  
  1748.     virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints);
  1749.     virtual LPCONNECTIONPOINT GetConnectionHook(const IID& iid);
  1750.  
  1751.     friend class COleConnPtContainer;
  1752.  
  1753. #endif //!_AFX_NO_OLE_SUPPORT
  1754. };
  1755.  
  1756. class CCmdUI        // simple helper class
  1757. {
  1758. public:
  1759. // Attributes
  1760.     UINT m_nID;
  1761.     UINT m_nIndex;          // menu item or other index
  1762.  
  1763.     // if a menu item
  1764.     CMenu* m_pMenu;         // NULL if not a menu
  1765.     CMenu* m_pSubMenu;      // sub containing menu item
  1766.                             // if a popup sub menu - ID is for first in popup
  1767.  
  1768.     // if from some other window
  1769.     CWnd* m_pOther;         // NULL if a menu or not a CWnd
  1770.  
  1771. // Operations to do in ON_UPDATE_COMMAND_UI
  1772.     virtual void Enable(BOOL bOn = TRUE);
  1773.     virtual void SetCheck(int nCheck = 1);   // 0, 1 or 2 (indeterminate)
  1774.     virtual void SetRadio(BOOL bOn = TRUE);
  1775.     virtual void SetText(LPCTSTR lpszText);
  1776.  
  1777. // Advanced operation
  1778.     void ContinueRouting();
  1779.  
  1780. // Implementation
  1781.     CCmdUI();
  1782.     BOOL m_bEnableChanged;
  1783.     BOOL m_bContinueRouting;
  1784.     UINT m_nIndexMax;       // last + 1 for iterating m_nIndex
  1785.  
  1786.     CMenu* m_pParentMenu;   // NULL if parent menu not easily determined
  1787.                             //  (probably a secondary popup menu)
  1788.  
  1789.     BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
  1790. };
  1791.  
  1792. // special CCmdUI derived classes are used for other UI paradigms
  1793. //  like toolbar buttons and status indicators
  1794.  
  1795. // pointer to afx_msg member function
  1796. #ifndef AFX_MSG_CALL
  1797. #define AFX_MSG_CALL
  1798. #endif
  1799. typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
  1800.  
  1801. enum AFX_DISPMAP_FLAGS
  1802. {
  1803.     afxDispCustom = 0,
  1804.     afxDispStock = 1
  1805. };
  1806.  
  1807. struct AFX_DISPMAP_ENTRY
  1808. {
  1809.     LPCTSTR lpszName;       // member/property name
  1810.     long lDispID;           // DISPID (may be DISPID_UNKNOWN)
  1811.     LPCSTR lpszParams;      // member parameter description
  1812.     WORD vt;                // return value type / or type of property
  1813.     AFX_PMSG pfn;           // normal member On<membercall> or, OnGet<property>
  1814.     AFX_PMSG pfnSet;        // special member for OnSet<property>
  1815.     size_t nPropOffset;     // property offset
  1816.     AFX_DISPMAP_FLAGS flags;// flags (e.g. stock/custom)
  1817. };
  1818.  
  1819. struct AFX_EVENTSINKMAP_ENTRY
  1820. {
  1821.     AFX_DISPMAP_ENTRY dispEntry;
  1822.     UINT nCtrlIDFirst;
  1823.     UINT nCtrlIDLast;
  1824. };
  1825.  
  1826. // DSC Sink state/reason codes passed to MFC user event handlers
  1827. enum DSCSTATE
  1828. {
  1829.     dscNoState = 0,
  1830.     dscOKToDo,
  1831.     dscCancelled,
  1832.     dscSyncBefore,
  1833.     dscAboutToDo,
  1834.     dscFailedToDo,
  1835.     dscSyncAfter,
  1836.     dscDidEvent
  1837. };
  1838.  
  1839. enum DSCREASON
  1840. {
  1841.     dscNoReason = 0,
  1842.     dscClose,
  1843.     dscCommit,
  1844.     dscDelete,
  1845.     dscEdit,
  1846.     dscInsert,
  1847.     dscModify,
  1848.     dscMove
  1849. };
  1850.  
  1851. /////////////////////////////////////////////////////////////////////////////
  1852. // CWnd implementation
  1853.  
  1854. // structures (see afxext.h)
  1855. struct CCreateContext;      // context for creating things
  1856. struct CPrintInfo;          // print preview customization info
  1857.  
  1858. struct AFX_MSGMAP_ENTRY
  1859. {
  1860.     UINT nMessage;   // windows message
  1861.     UINT nCode;      // control code or WM_NOTIFY code
  1862.     UINT nID;        // control ID (or 0 for windows messages)
  1863.     UINT nLastID;    // used for entries specifying a range of control id's
  1864.     UINT nSig;       // signature type (action) or pointer to message #
  1865.     AFX_PMSG pfn;    // routine to call (or special value)
  1866. };
  1867.  
  1868. /////////////////////////////////////////////////////////////////////////////
  1869. // CWnd - a Microsoft Windows application window
  1870.  
  1871. class COleDropTarget;   // for more information see AFXOLE.H
  1872. class COleControlContainer;
  1873. class COleControlSite;
  1874.  
  1875. // CWnd::m_nFlags (generic to CWnd)
  1876. #define WF_TOOLTIPS         0x0001  // window is enabled for tooltips
  1877. #define WF_TEMPHIDE         0x0002  // window is temporarily hidden
  1878. #define WF_STAYDISABLED     0x0004  // window should stay disabled
  1879. #define WF_MODALLOOP        0x0008  // currently in modal loop
  1880. #define WF_CONTINUEMODAL    0x0010  // modal loop should continue running
  1881. #define WF_OLECTLCONTAINER  0x0100  // some descendant is an OLE control
  1882. #define WF_TRACKINGTOOLTIPS 0x0400  // window is enabled for tracking tooltips
  1883.  
  1884. // CWnd::m_nFlags (specific to CFrameWnd)
  1885. #define WF_STAYACTIVE       0x0020  // look active even though not active
  1886. #define WF_NOPOPMSG         0x0040  // ignore WM_POPMESSAGESTRING calls
  1887. #define WF_MODALDISABLE     0x0080  // window is disabled
  1888. #define WF_KEEPMINIACTIVE   0x0200  // stay activate even though you are deactivated
  1889.  
  1890. // flags for CWnd::RunModalLoop
  1891. #define MLF_NOIDLEMSG       0x0001  // don't send WM_ENTERIDLE messages
  1892. #define MLF_NOKICKIDLE      0x0002  // don't send WM_KICKIDLE messages
  1893. #define MLF_SHOWONIDLE      0x0004  // show window if not visible at idle time
  1894.  
  1895. // extra MFC defined TTF_ flags for TOOLINFO::uFlags
  1896. #define TTF_NOTBUTTON       0x80000000L // no status help on buttondown
  1897. #define TTF_ALWAYSTIP       0x40000000L // always show the tip even if not active
  1898.  
  1899. class CWnd : public CCmdTarget
  1900. {
  1901.     DECLARE_DYNCREATE(CWnd)
  1902. protected:
  1903.     static const MSG* PASCAL GetCurrentMessage();
  1904.  
  1905. // Attributes
  1906. public:
  1907.     HWND m_hWnd;            // must be first data member
  1908.     operator HWND() const;
  1909.     BOOL operator==(const CWnd& wnd) const;
  1910.     BOOL operator!=(const CWnd& wnd) const;
  1911.  
  1912.     HWND GetSafeHwnd() const;
  1913.     DWORD GetStyle() const;
  1914.     DWORD GetExStyle() const;
  1915.     BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
  1916.     BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
  1917.  
  1918.     CWnd* GetOwner() const;
  1919.     void SetOwner(CWnd* pOwnerWnd);
  1920.  
  1921. // Constructors and other creation
  1922.     CWnd();
  1923.  
  1924.     static CWnd* PASCAL FromHandle(HWND hWnd);
  1925.     static CWnd* PASCAL FromHandlePermanent(HWND hWnd);
  1926.     static void PASCAL DeleteTempMap();
  1927.     BOOL Attach(HWND hWndNew);
  1928.     HWND Detach();
  1929.  
  1930.     // subclassing/unsubclassing functions
  1931.     virtual void PreSubclassWindow();
  1932.     BOOL SubclassWindow(HWND hWnd);
  1933.     BOOL SubclassDlgItem(UINT nID, CWnd* pParent);
  1934.     HWND UnsubclassWindow();
  1935.  
  1936.     // handling of RT_DLGINIT resource (extension to RT_DIALOG)
  1937.     BOOL ExecuteDlgInit(LPCTSTR lpszResourceName);
  1938.     BOOL ExecuteDlgInit(LPVOID lpResource);
  1939.  
  1940. public:
  1941.     // for child windows, views, panes etc
  1942.     virtual BOOL Create(LPCTSTR lpszClassName,
  1943.         LPCTSTR lpszWindowName, DWORD dwStyle,
  1944.         const RECT& rect,
  1945.         CWnd* pParentWnd, UINT nID,
  1946.         CCreateContext* pContext = NULL);
  1947.  
  1948.     // advanced creation (allows access to extended styles)
  1949.     BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
  1950.         LPCTSTR lpszWindowName, DWORD dwStyle,
  1951.         int x, int y, int nWidth, int nHeight,
  1952.         HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL);
  1953.  
  1954.     BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
  1955.         LPCTSTR lpszWindowName, DWORD dwStyle,
  1956.         const RECT& rect,
  1957.         CWnd* pParentWnd, UINT nID,
  1958.         LPVOID lpParam = NULL);
  1959.  
  1960. #ifndef _AFX_NO_OCC_SUPPORT
  1961.     // for wrapping OLE controls
  1962.     BOOL CreateControl(REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
  1963.         const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
  1964.         BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
  1965.  
  1966.     BOOL CreateControl(LPCTSTR pszClass, LPCTSTR pszWindowName, DWORD dwStyle,
  1967.         const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
  1968.         BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
  1969.  
  1970.    // Another overload for creating controls that use default extents.
  1971.    BOOL CreateControl( REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
  1972.       const POINT* ppt, const SIZE* psize, CWnd* pParentWnd, UINT nID,
  1973.       CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );
  1974.  
  1975.     LPUNKNOWN GetControlUnknown();
  1976. #endif
  1977.  
  1978.     virtual BOOL DestroyWindow();
  1979.  
  1980.     // special pre-creation and window rect adjustment hooks
  1981.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  1982.  
  1983.     // Advanced: virtual AdjustWindowRect
  1984.     enum AdjustType { adjustBorder = 0, adjustOutside = 1 };
  1985.     virtual void CalcWindowRect(LPRECT lpClientRect,
  1986.         UINT nAdjustType = adjustBorder);
  1987.  
  1988. // Window tree access
  1989.     int GetDlgCtrlID() const;
  1990.     int SetDlgCtrlID(int nID);
  1991.         // get and set window ID, for child windows only
  1992.     CWnd* GetDlgItem(int nID) const;
  1993.         // get immediate child with given ID
  1994.     void GetDlgItem(int nID, HWND* phWnd) const;
  1995.         // as above, but returns HWND
  1996.     CWnd* GetDescendantWindow(int nID, BOOL bOnlyPerm = FALSE) const;
  1997.         // like GetDlgItem but recursive
  1998.     void SendMessageToDescendants(UINT message, WPARAM wParam = 0,
  1999.         LPARAM lParam = 0, BOOL bDeep = TRUE, BOOL bOnlyPerm = FALSE);
  2000.     CFrameWnd* GetParentFrame() const;
  2001.     CWnd* GetTopLevelParent() const;
  2002.     CWnd* GetTopLevelOwner() const;
  2003.     CWnd* GetParentOwner() const;
  2004.     CFrameWnd* GetTopLevelFrame() const;
  2005.     static CWnd* PASCAL GetSafeOwner(CWnd* pParent = NULL, HWND* pWndTop = NULL);
  2006.  
  2007. // Message Functions
  2008.     LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
  2009.     BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
  2010.  
  2011.     BOOL SendNotifyMessage(UINT message, WPARAM wParam, LPARAM lParam);
  2012.     BOOL SendChildNotifyLastMsg(LRESULT* pResult = NULL);
  2013.  
  2014. // Message processing for modeless dialog-like windows
  2015.     BOOL IsDialogMessage(LPMSG lpMsg);
  2016.  
  2017. // Window Text Functions
  2018.     void SetWindowText(LPCTSTR lpszString);
  2019.     int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount) const;
  2020.     void GetWindowText(CString& rString) const;
  2021.     int GetWindowTextLength() const;
  2022.     void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
  2023.     CFont* GetFont() const;
  2024.  
  2025. // CMenu Functions - non-Child windows only
  2026.     CMenu* GetMenu() const;
  2027.     BOOL SetMenu(CMenu* pMenu);
  2028.     void DrawMenuBar();
  2029.     CMenu* GetSystemMenu(BOOL bRevert) const;
  2030.     BOOL HiliteMenuItem(CMenu* pMenu, UINT nIDHiliteItem, UINT nHilite);
  2031.  
  2032. // Window Size and Position Functions
  2033.     BOOL IsIconic() const;
  2034.     BOOL IsZoomed() const;
  2035.     void MoveWindow(int x, int y, int nWidth, int nHeight,
  2036.                 BOOL bRepaint = TRUE);
  2037.     void MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE);
  2038.     int SetWindowRgn(HRGN hRgn, BOOL bRedraw);
  2039.     int GetWindowRgn(HRGN hRgn) const;
  2040.  
  2041.     static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
  2042.     static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
  2043.     static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
  2044.     static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter
  2045.  
  2046.     BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
  2047.                 int cx, int cy, UINT nFlags);
  2048.     UINT ArrangeIconicWindows();
  2049.     void BringWindowToTop();
  2050.     void GetWindowRect(LPRECT lpRect) const;
  2051.     void GetClientRect(LPRECT lpRect) const;
  2052.  
  2053.     BOOL GetWindowPlacement(WINDOWPLACEMENT* lpwndpl) const;
  2054.     BOOL SetWindowPlacement(const WINDOWPLACEMENT* lpwndpl);
  2055.  
  2056. // Coordinate Mapping Functions
  2057.     void ClientToScreen(LPPOINT lpPoint) const;
  2058.     void ClientToScreen(LPRECT lpRect) const;
  2059.     void ScreenToClient(LPPOINT lpPoint) const;
  2060.     void ScreenToClient(LPRECT lpRect) const;
  2061.     void MapWindowPoints(CWnd* pwndTo, LPPOINT lpPoint, UINT nCount) const;
  2062.     void MapWindowPoints(CWnd* pwndTo, LPRECT lpRect) const;
  2063.  
  2064. // Update/Painting Functions
  2065.     CDC* BeginPaint(LPPAINTSTRUCT lpPaint);
  2066.     void EndPaint(LPPAINTSTRUCT lpPaint);
  2067.     CDC* GetDC();
  2068.     CDC* GetWindowDC();
  2069.     int ReleaseDC(CDC* pDC);
  2070.     void Print(CDC* pDC, DWORD dwFlags) const;
  2071.     void PrintClient(CDC* pDC, DWORD dwFlags) const;
  2072.  
  2073.     void UpdateWindow();
  2074.     void SetRedraw(BOOL bRedraw = TRUE);
  2075.     BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE);
  2076.     int GetUpdateRgn(CRgn* pRgn, BOOL bErase = FALSE);
  2077.     void Invalidate(BOOL bErase = TRUE);
  2078.     void InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE);
  2079.     void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
  2080.     void ValidateRect(LPCRECT lpRect);
  2081.     void ValidateRgn(CRgn* pRgn);
  2082.     BOOL ShowWindow(int nCmdShow);
  2083.     BOOL IsWindowVisible() const;
  2084.     void ShowOwnedPopups(BOOL bShow = TRUE);
  2085.  
  2086.     CDC* GetDCEx(CRgn* prgnClip, DWORD flags);
  2087.     BOOL LockWindowUpdate();    // for backward compatibility
  2088.     void UnlockWindowUpdate();
  2089.     BOOL RedrawWindow(LPCRECT lpRectUpdate = NULL,
  2090.         CRgn* prgnUpdate = NULL,
  2091.         UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
  2092.     BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH);
  2093.  
  2094. // Timer Functions
  2095.     UINT SetTimer(UINT nIDEvent, UINT nElapse,
  2096.         void (CALLBACK* lpfnTimer)(HWND, UINT, UINT, DWORD));
  2097.     BOOL KillTimer(int nIDEvent);
  2098.  
  2099. // ToolTip Functions
  2100.     BOOL EnableToolTips(BOOL bEnable = TRUE);
  2101.     BOOL EnableTrackingToolTips(BOOL bEnable = TRUE);
  2102.     static void PASCAL CancelToolTips(BOOL bKeys = FALSE);
  2103.     void FilterToolTipMessage(MSG* pMsg);
  2104.  
  2105.     // for command hit testing (used for automatic tooltips)
  2106.     virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
  2107.  
  2108. // Window State Functions
  2109.     BOOL IsWindowEnabled() const;
  2110.     BOOL EnableWindow(BOOL bEnable = TRUE);
  2111.  
  2112.     // the active window applies only to top-level (frame windows)
  2113.     static CWnd* PASCAL GetActiveWindow();
  2114.     CWnd* SetActiveWindow();
  2115.  
  2116.     // the foreground window applies only to top-level windows (frame windows)
  2117.     BOOL SetForegroundWindow();
  2118.     static CWnd* PASCAL GetForegroundWindow();
  2119.  
  2120.     // capture and focus apply to all windows
  2121.     static CWnd* PASCAL GetCapture();
  2122.     CWnd* SetCapture();
  2123.     static CWnd* PASCAL GetFocus();
  2124.     CWnd* SetFocus();
  2125.  
  2126.     static CWnd* PASCAL GetDesktopWindow();
  2127.  
  2128. // Obsolete and non-portable APIs - not recommended for new code
  2129.     void CloseWindow();
  2130.     BOOL OpenIcon();
  2131.  
  2132. // Dialog-Box Item Functions
  2133. // (NOTE: Dialog-Box Items/Controls are not necessarily in dialog boxes!)
  2134.     void CheckDlgButton(int nIDButton, UINT nCheck);
  2135.     void CheckRadioButton(int nIDFirstButton, int nIDLastButton,
  2136.                     int nIDCheckButton);
  2137.     int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton);
  2138.     int DlgDirList(LPTSTR lpPathSpec, int nIDListBox,
  2139.                     int nIDStaticPath, UINT nFileType);
  2140.     int DlgDirListComboBox(LPTSTR lpPathSpec, int nIDComboBox,
  2141.                     int nIDStaticPath, UINT nFileType);
  2142.     BOOL DlgDirSelect(LPTSTR lpString, int nIDListBox);
  2143.     BOOL DlgDirSelectComboBox(LPTSTR lpString, int nIDComboBox);
  2144.  
  2145.     UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL,
  2146.                     BOOL bSigned = TRUE) const;
  2147.     int GetDlgItemText(int nID, LPTSTR lpStr, int nMaxCount) const;
  2148.     int GetDlgItemText(int nID, CString& rString) const;
  2149.     CWnd* GetNextDlgGroupItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
  2150.  
  2151.     CWnd* GetNextDlgTabItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
  2152.     UINT IsDlgButtonChecked(int nIDButton) const;
  2153.     LRESULT SendDlgItemMessage(int nID, UINT message,
  2154.                     WPARAM wParam = 0, LPARAM lParam = 0);
  2155.     void SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE);
  2156.     void SetDlgItemText(int nID, LPCTSTR lpszString);
  2157.  
  2158. // Scrolling Functions
  2159.     int GetScrollPos(int nBar) const;
  2160.     void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const;
  2161.     void ScrollWindow(int xAmount, int yAmount,
  2162.                     LPCRECT lpRect = NULL,
  2163.                     LPCRECT lpClipRect = NULL);
  2164.     int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
  2165.     void SetScrollRange(int nBar, int nMinPos, int nMaxPos,
  2166.             BOOL bRedraw = TRUE);
  2167.     void ShowScrollBar(UINT nBar, BOOL bShow = TRUE);
  2168.     void EnableScrollBarCtrl(int nBar, BOOL bEnable = TRUE);
  2169.     virtual CScrollBar* GetScrollBarCtrl(int nBar) const;
  2170.             // return sibling scrollbar control (or NULL if none)
  2171.  
  2172.     int ScrollWindowEx(int dx, int dy,
  2173.                 LPCRECT lpRectScroll, LPCRECT lpRectClip,
  2174.                 CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags);
  2175.     BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo,
  2176.         BOOL bRedraw = TRUE);
  2177.     BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL);
  2178.     int GetScrollLimit(int nBar);
  2179.  
  2180. // Window Access Functions
  2181.     CWnd* ChildWindowFromPoint(POINT point) const;
  2182.     CWnd* ChildWindowFromPoint(POINT point, UINT nFlags) const;
  2183.     static CWnd* PASCAL FindWindow(LPCTSTR lpszClassName, LPCTSTR lpszWindowName);
  2184.     CWnd* GetNextWindow(UINT nFlag = GW_HWNDNEXT) const;
  2185.     CWnd* GetTopWindow() const;
  2186.  
  2187.     CWnd* GetWindow(UINT nCmd) const;
  2188.     CWnd* GetLastActivePopup() const;
  2189.  
  2190.     BOOL IsChild(const CWnd* pWnd) const;
  2191.     CWnd* GetParent() const;
  2192.     CWnd* SetParent(CWnd* pWndNewParent);
  2193.     static CWnd* PASCAL WindowFromPoint(POINT point);
  2194.  
  2195. // Alert Functions
  2196.     BOOL FlashWindow(BOOL bInvert);
  2197.     int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
  2198.             UINT nType = MB_OK);
  2199.  
  2200. // Clipboard Functions
  2201.     BOOL ChangeClipboardChain(HWND hWndNext);
  2202.     HWND SetClipboardViewer();
  2203.     BOOL OpenClipboard();
  2204.     static CWnd* PASCAL GetClipboardOwner();
  2205.     static CWnd* PASCAL GetClipboardViewer();
  2206.     static CWnd* PASCAL GetOpenClipboardWindow();
  2207.  
  2208. // Caret Functions
  2209.     void CreateCaret(CBitmap* pBitmap);
  2210.     void CreateSolidCaret(int nWidth, int nHeight);
  2211.     void CreateGrayCaret(int nWidth, int nHeight);
  2212.     static CPoint PASCAL GetCaretPos();
  2213.     static void PASCAL SetCaretPos(POINT point);
  2214.     void HideCaret();
  2215.     void ShowCaret();
  2216.  
  2217. // Shell Interaction Functions
  2218.     void DragAcceptFiles(BOOL bAccept = TRUE);
  2219.  
  2220. // Icon Functions
  2221.     HICON SetIcon(HICON hIcon, BOOL bBigIcon);
  2222.     HICON GetIcon(BOOL bBigIcon) const;
  2223.  
  2224. // Context Help Functions
  2225.     BOOL SetWindowContextHelpId(DWORD dwContextHelpId);
  2226.     DWORD GetWindowContextHelpId() const;
  2227.  
  2228. // Dialog Data support
  2229. public:
  2230.     BOOL UpdateData(BOOL bSaveAndValidate = TRUE);
  2231.             // data wnd must be same type as this
  2232.  
  2233. // Help Command Handlers
  2234.     afx_msg void OnHelp();          // F1 (uses current context)
  2235.     afx_msg void OnHelpIndex();     // ID_HELP_INDEX
  2236.     afx_msg void OnHelpFinder();    // ID_HELP_FINDER, ID_DEFAULT_HELP
  2237.     afx_msg void OnHelpUsing();     // ID_HELP_USING
  2238.     virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
  2239.  
  2240. // Layout and other functions
  2241. public:
  2242.     enum RepositionFlags
  2243.         { reposDefault = 0, reposQuery = 1, reposExtra = 2 };
  2244.     void RepositionBars(UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver,
  2245.         UINT nFlag = reposDefault, LPRECT lpRectParam = NULL,
  2246.         LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE);
  2247.  
  2248.     // dialog support
  2249.     void UpdateDialogControls(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
  2250.     void CenterWindow(CWnd* pAlternateOwner = NULL);
  2251.     int RunModalLoop(DWORD dwFlags = 0);
  2252.     virtual BOOL ContinueModal();
  2253.     virtual void EndModalLoop(int nResult);
  2254.  
  2255. #ifndef _AFX_NO_OCC_SUPPORT
  2256. // OLE control wrapper functions
  2257.     void AFX_CDECL InvokeHelper(DISPID dwDispID, WORD wFlags,
  2258.         VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);
  2259.     void AFX_CDECL SetProperty(DISPID dwDispID, VARTYPE vtProp, ...);
  2260.     void GetProperty(DISPID dwDispID, VARTYPE vtProp, void* pvProp) const;
  2261.     IUnknown* GetDSCCursor();
  2262.     void BindDefaultProperty(DISPID dwDispID, VARTYPE vtProp, LPCTSTR szFieldName, CWnd* pDSCWnd);
  2263.     void BindProperty(DISPID dwDispId, CWnd* pWndDSC);
  2264. #endif
  2265.  
  2266. // Window-Management message handler member functions
  2267. protected:
  2268.     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  2269.     virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  2270.  
  2271.     afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
  2272.     afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
  2273.     afx_msg LRESULT OnActivateTopLevel(WPARAM, LPARAM);
  2274.     afx_msg void OnCancelMode();
  2275.     afx_msg void OnChildActivate();
  2276.     afx_msg void OnClose();
  2277.     afx_msg void OnContextMenu(CWnd* pWnd, CPoint pos);
  2278.     afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
  2279.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  2280.  
  2281.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  2282.  
  2283.     afx_msg void OnDestroy();
  2284.     afx_msg void OnEnable(BOOL bEnable);
  2285.     afx_msg void OnEndSession(BOOL bEnding);
  2286.     afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
  2287.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  2288.     afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
  2289.     afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
  2290.     afx_msg void OnIconEraseBkgnd(CDC* pDC);
  2291.     afx_msg void OnKillFocus(CWnd* pNewWnd);
  2292.     afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
  2293.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  2294.     afx_msg void OnMove(int x, int y);
  2295.     afx_msg void OnPaint();
  2296.     afx_msg void OnParentNotify(UINT message, LPARAM lParam);
  2297.     afx_msg HCURSOR OnQueryDragIcon();
  2298.     afx_msg BOOL OnQueryEndSession();
  2299.     afx_msg BOOL OnQueryNewPalette();
  2300.     afx_msg BOOL OnQueryOpen();
  2301.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  2302.     afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  2303.     afx_msg void OnSize(UINT nType, int cx, int cy);
  2304.     afx_msg void OnTCard(UINT idAction, DWORD dwActionData);
  2305.     afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
  2306.     afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
  2307.  
  2308. // Nonclient-Area message handler member functions
  2309.     afx_msg BOOL OnNcActivate(BOOL bActive);
  2310.     afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  2311.     afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
  2312.     afx_msg void OnNcDestroy();
  2313.     afx_msg UINT OnNcHitTest(CPoint point);
  2314.     afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  2315.     afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  2316.     afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  2317.     afx_msg void OnNcMButtonDblClk(UINT nHitTest, CPoint point);
  2318.     afx_msg void OnNcMButtonDown(UINT nHitTest, CPoint point);
  2319.     afx_msg void OnNcMButtonUp(UINT nHitTest, CPoint point);
  2320.     afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
  2321.     afx_msg void OnNcPaint();
  2322.     afx_msg void OnNcRButtonDblClk(UINT nHitTest, CPoint point);
  2323.     afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
  2324.     afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
  2325.  
  2326. // System message handler member functions
  2327.     afx_msg void OnDropFiles(HDROP hDropInfo);
  2328.     afx_msg void OnPaletteIsChanging(CWnd* pRealizeWnd);
  2329.     afx_msg void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  2330.     afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  2331.     afx_msg void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  2332.     afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  2333.     afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  2334.     afx_msg void OnCompacting(UINT nCpuTime);
  2335.     afx_msg void OnDevModeChange(LPTSTR lpDeviceName);
  2336.     afx_msg void OnFontChange();
  2337.     afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  2338.     afx_msg void OnSpoolerStatus(UINT nStatus, UINT nJobs);
  2339.     afx_msg void OnSysColorChange();
  2340.     afx_msg void OnTimeChange();
  2341.     afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  2342.     afx_msg void OnWinIniChange(LPCTSTR lpszSection);
  2343.  
  2344. // Input message handler member functions
  2345.     afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  2346.     afx_msg void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  2347.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  2348.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  2349.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  2350.     afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  2351.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  2352.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  2353.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  2354.     afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
  2355.     afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  2356.     afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  2357.     afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
  2358.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  2359.     afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  2360.     afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
  2361.     afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  2362.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  2363.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  2364.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  2365.     afx_msg void OnTimer(UINT nIDEvent);
  2366.  
  2367. // Initialization message handler member functions
  2368.     afx_msg void OnInitMenu(CMenu* pMenu);
  2369.     afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
  2370.  
  2371. // Clipboard message handler member functions
  2372.     afx_msg void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString);
  2373.     afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
  2374.     afx_msg void OnDestroyClipboard();
  2375.     afx_msg void OnDrawClipboard();
  2376.     afx_msg void OnHScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
  2377.     afx_msg void OnPaintClipboard(CWnd* pClipAppWnd, HGLOBAL hPaintStruct);
  2378.     afx_msg void OnRenderAllFormats();
  2379.     afx_msg void OnRenderFormat(UINT nFormat);
  2380.     afx_msg void OnSizeClipboard(CWnd* pClipAppWnd, HGLOBAL hRect);
  2381.     afx_msg void OnVScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
  2382.  
  2383. // Control message handler member functions
  2384.     afx_msg int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  2385.     afx_msg void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct);
  2386.     afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
  2387.     afx_msg UINT OnGetDlgCode();
  2388.     afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  2389.     afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex);
  2390.     afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
  2391.  
  2392. // MDI message handler member functions
  2393.     afx_msg void OnMDIActivate(BOOL bActivate,
  2394.         CWnd* pActivateWnd, CWnd* pDeactivateWnd);
  2395.  
  2396. // Menu loop notification messages
  2397.     afx_msg void OnEnterMenuLoop(BOOL bIsTrackPopupMenu);
  2398.     afx_msg void OnExitMenuLoop(BOOL bIsTrackPopupMenu);
  2399.  
  2400. // Win4 messages
  2401.     afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
  2402.     afx_msg void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
  2403.     afx_msg void OnSizing(UINT nSide, LPRECT lpRect);
  2404.     afx_msg void OnMoving(UINT nSide, LPRECT lpRect);
  2405.     afx_msg void OnCaptureChanged(CWnd* pWnd);
  2406.     afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData);
  2407.  
  2408. // Overridables and other helpers (for implementation of derived classes)
  2409. protected:
  2410.     // for deriving from a standard control
  2411.     virtual WNDPROC* GetSuperWndProcAddr();
  2412.  
  2413.     // for dialog data exchange and validation
  2414.     virtual void DoDataExchange(CDataExchange* pDX);
  2415.  
  2416. public:
  2417.     // for modality
  2418.     virtual void BeginModalState();
  2419.     virtual void EndModalState();
  2420.  
  2421.     // for translating Windows messages in main message pump
  2422.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  2423.  
  2424. #ifndef _AFX_NO_OCC_SUPPORT
  2425.     // for ambient properties exposed to contained OLE controls
  2426.     virtual BOOL OnAmbientProperty(COleControlSite* pSite, DISPID dispid,
  2427.         VARIANT* pvar);
  2428. #endif
  2429.  
  2430. protected:
  2431.     // for processing Windows messages
  2432.     virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  2433.     virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  2434.  
  2435.     // for handling default processing
  2436.     LRESULT Default();
  2437.     virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  2438.  
  2439.     // for custom cleanup after WM_NCDESTROY
  2440.     virtual void PostNcDestroy();
  2441.  
  2442.     // for notifications from parent
  2443.     virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  2444.         // return TRUE if parent should not process this message
  2445.     BOOL ReflectChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  2446.     static BOOL PASCAL ReflectLastMsg(HWND hWndChild, LRESULT* pResult = NULL);
  2447.  
  2448. // Implementation
  2449. public:
  2450.     virtual ~CWnd();
  2451.     virtual BOOL CheckAutoCenter();
  2452. #ifdef _DEBUG
  2453.     virtual void AssertValid() const;
  2454.     virtual void Dump(CDumpContext& dc) const;
  2455. #endif
  2456. #ifndef _AFX_NO_CTL3D_SUPPORT
  2457.     // 3D support (these APIs will be obsolete with next version of Windows)
  2458.     BOOL SubclassCtl3d(int nControlType = -1);
  2459.         // see CTL3D.H for list of control types
  2460.     BOOL SubclassDlg3d(DWORD dwMask = 0xFFFF /*CTL3D_ALL*/);
  2461.         // see CTL3D.H for list of mask values
  2462. #endif
  2463.     static BOOL PASCAL GrayCtlColor(HDC hDC, HWND hWnd, UINT nCtlColor,
  2464.         HBRUSH hbrGray, COLORREF clrText);
  2465. #ifndef _AFX_NO_GRAYDLG_SUPPORT
  2466.     HBRUSH OnGrayCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  2467. #endif
  2468.  
  2469.     // helper routines for implementation
  2470.     BOOL HandleFloatingSysCommand(UINT nID, LPARAM lParam);
  2471.     BOOL IsTopParentActive() const;
  2472.     void ActivateTopParent();
  2473.     static BOOL PASCAL WalkPreTranslateTree(HWND hWndStop, MSG* pMsg);
  2474.     static CWnd* PASCAL GetDescendantWindow(HWND hWnd, int nID,
  2475.         BOOL bOnlyPerm);
  2476.     static void PASCAL SendMessageToDescendants(HWND hWnd, UINT message,
  2477.         WPARAM wParam, LPARAM lParam, BOOL bDeep, BOOL bOnlyPerm);
  2478.     virtual BOOL IsFrameWnd() const; // IsKindOf(RUNTIME_CLASS(CFrameWnd)))
  2479.     virtual void OnFinalRelease();
  2480.     BOOL PreTranslateInput(LPMSG lpMsg);
  2481.     static BOOL PASCAL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
  2482.         UINT nFlags);
  2483.     static BOOL PASCAL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
  2484.         UINT nFlags);
  2485.     static void PASCAL _FilterToolTipMessage(MSG* pMsg, CWnd* pWnd);
  2486.     BOOL _EnableToolTips(BOOL bEnable, UINT nFlag);
  2487.     static HWND PASCAL GetSafeOwner_(HWND hWnd, HWND* pWndTop);
  2488.  
  2489. public:
  2490.     HWND m_hWndOwner;   // implementation of SetOwner and GetOwner
  2491.     UINT m_nFlags;      // see WF_ flags above
  2492.  
  2493. protected:
  2494.     WNDPROC m_pfnSuper; // for subclassing of controls
  2495.     static const UINT m_nMsgDragList;
  2496.     int m_nModalResult; // for return values from CWnd::RunModalLoop
  2497.  
  2498.     COleDropTarget* m_pDropTarget;  // for automatic cleanup of drop target
  2499.     friend class COleDropTarget;
  2500.     friend class CFrameWnd;
  2501.  
  2502.     // for creating dialogs and dialog-like windows
  2503.     BOOL CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd);
  2504.     BOOL CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd);
  2505.     BOOL CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
  2506.         HINSTANCE hInst);
  2507.  
  2508. #ifndef _AFX_NO_OCC_SUPPORT
  2509.     COleControlContainer* m_pCtrlCont;  // for containing OLE controls
  2510.     COleControlSite* m_pCtrlSite;       // for wrapping an OLE control
  2511.     friend class COccManager;
  2512.     friend class COleControlSite;
  2513.     friend class COleControlContainer;
  2514.     BOOL InitControlContainer();
  2515.     virtual BOOL SetOccDialogInfo(struct _AFX_OCC_DIALOG_INFO* pOccDialogInfo);
  2516.     void AttachControlSite(CHandleMap* pMap);
  2517. public:
  2518.     void AttachControlSite(CWnd* pWndParent);
  2519. #endif
  2520.  
  2521. protected:
  2522.     // implementation of message dispatch/hooking
  2523.     friend LRESULT CALLBACK _AfxSendMsgHook(int, WPARAM, LPARAM);
  2524.     friend void AFXAPI _AfxStandardSubclass(HWND);
  2525.     friend LRESULT CALLBACK _AfxCbtFilterHook(int, WPARAM, LPARAM);
  2526.     friend LRESULT AFXAPI AfxCallWndProc(CWnd*, HWND, UINT, WPARAM, LPARAM);
  2527.  
  2528.     // standard message implementation
  2529.     afx_msg LRESULT OnNTCtlColor(WPARAM wParam, LPARAM lParam);
  2530. #ifndef _AFX_NO_CTL3D_SUPPORT
  2531.     afx_msg LRESULT OnQuery3dControls(WPARAM, LPARAM);
  2532. #endif
  2533.     afx_msg LRESULT OnDisplayChange(WPARAM, LPARAM);
  2534.     afx_msg LRESULT OnDragList(WPARAM, LPARAM);
  2535.  
  2536.     //{{AFX_MSG(CWnd)
  2537.     //}}AFX_MSG
  2538.     DECLARE_MESSAGE_MAP()
  2539.  
  2540. private:
  2541.     CWnd(HWND hWnd);    // just for special initialization
  2542. };
  2543.  
  2544. // helpers for registering your own WNDCLASSes
  2545. LPCTSTR AFXAPI AfxRegisterWndClass(UINT nClassStyle,
  2546.     HCURSOR hCursor = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0);
  2547.  
  2548. BOOL AFXAPI AfxRegisterClass(WNDCLASS* lpWndClass);
  2549.  
  2550. // helper to initialize rich edit control
  2551. BOOL AFXAPI AfxInitRichEdit();
  2552.  
  2553. // Implementation
  2554. LRESULT CALLBACK AfxWndProc(HWND, UINT, WPARAM, LPARAM);
  2555.  
  2556. WNDPROC AFXAPI AfxGetAfxWndProc();
  2557. #define AfxWndProc (*AfxGetAfxWndProc())
  2558.  
  2559. typedef void (AFX_MSG_CALL CWnd::*AFX_PMSGW)(void);
  2560.     // like 'AFX_PMSG' but for CWnd derived classes only
  2561.  
  2562. typedef void (AFX_MSG_CALL CWinThread::*AFX_PMSGT)(void);
  2563.     // like 'AFX_PMSG' but for CWinThread-derived classes only
  2564.  
  2565. /////////////////////////////////////////////////////////////////////////////
  2566. // CDialog - a modal or modeless dialog
  2567.  
  2568. class CDialog : public CWnd
  2569. {
  2570.     DECLARE_DYNAMIC(CDialog)
  2571.  
  2572.     // Modeless construct
  2573. public:
  2574.     CDialog();
  2575.  
  2576.     BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
  2577.     BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
  2578.     BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL,
  2579.         void* lpDialogInit = NULL);
  2580.     BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL);
  2581.  
  2582.     // Modal construct
  2583. public:
  2584.     CDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
  2585.     CDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);
  2586.     BOOL InitModalIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL,
  2587.         void* lpDialogInit = NULL);
  2588.     BOOL InitModalIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL);
  2589.  
  2590. // Attributes
  2591. public:
  2592.     void MapDialogRect(LPRECT lpRect) const;
  2593.     void SetHelpID(UINT nIDR);
  2594.  
  2595. // Operations
  2596. public:
  2597.     // modal processing
  2598.     virtual int DoModal();
  2599.  
  2600.     // support for passing on tab control - use 'PostMessage' if needed
  2601.     void NextDlgCtrl() const;
  2602.     void PrevDlgCtrl() const;
  2603.     void GotoDlgCtrl(CWnd* pWndCtrl);
  2604.  
  2605.     // default button access
  2606.     void SetDefID(UINT nID);
  2607.     DWORD GetDefID() const;
  2608.  
  2609.     // termination
  2610.     void EndDialog(int nResult);
  2611.  
  2612. // Overridables (special message map entries)
  2613.     virtual BOOL OnInitDialog();
  2614.     virtual void OnSetFont(CFont* pFont);
  2615. protected:
  2616.     virtual void OnOK();
  2617.     virtual void OnCancel();
  2618.  
  2619. // Implementation
  2620. public:
  2621.     virtual ~CDialog();
  2622. #ifdef _DEBUG
  2623.     virtual void AssertValid() const;
  2624.     virtual void Dump(CDumpContext& dc) const;
  2625. #endif
  2626.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  2627.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  2628.         AFX_CMDHANDLERINFO* pHandlerInfo);
  2629.     virtual BOOL CheckAutoCenter();
  2630.  
  2631. protected:
  2632.     UINT m_nIDHelp;                 // Help ID (0 for none, see HID_BASE_RESOURCE)
  2633.  
  2634.     // parameters for 'DoModal'
  2635.     LPCTSTR m_lpszTemplateName;     // name or MAKEINTRESOURCE
  2636.     HGLOBAL m_hDialogTemplate;      // indirect (m_lpDialogTemplate == NULL)
  2637.     LPCDLGTEMPLATE m_lpDialogTemplate;  // indirect if (m_lpszTemplateName == NULL)
  2638.     void* m_lpDialogInit;           // DLGINIT resource data
  2639.     CWnd* m_pParentWnd;             // parent/owner window
  2640.     HWND m_hWndTop;                 // top level parent window (may be disabled)
  2641.  
  2642. #ifndef _AFX_NO_OCC_SUPPORT
  2643.     _AFX_OCC_DIALOG_INFO* m_pOccDialogInfo;
  2644.     virtual BOOL SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo);
  2645. #endif
  2646.     virtual void PreInitDialog();
  2647.  
  2648.     // implementation helpers
  2649.     HWND PreModal();
  2650.     void PostModal();
  2651.  
  2652.     BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
  2653.         void* lpDialogInit, HINSTANCE hInst);
  2654.     BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd,
  2655.         HINSTANCE hInst);
  2656.  
  2657. protected:
  2658.     //{{AFX_MSG(CDialog)
  2659.     afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
  2660.     afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
  2661.     afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM);
  2662.     afx_msg LRESULT HandleSetFont(WPARAM, LPARAM);
  2663.     //}}AFX_MSG
  2664. #ifndef _AFX_NO_GRAYDLG_SUPPORT
  2665.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  2666. #endif
  2667.     DECLARE_MESSAGE_MAP()
  2668. };
  2669.  
  2670. // all CModalDialog functionality is now in CDialog
  2671. #define CModalDialog    CDialog
  2672.  
  2673. /////////////////////////////////////////////////////////////////////////////
  2674. // Standard Windows controls
  2675.  
  2676. class CStatic : public CWnd
  2677. {
  2678.     DECLARE_DYNAMIC(CStatic)
  2679.  
  2680. // Constructors
  2681. public:
  2682.     CStatic();
  2683.     BOOL Create(LPCTSTR lpszText, DWORD dwStyle,
  2684.                 const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff);
  2685.  
  2686. // Operations
  2687.     HICON SetIcon(HICON hIcon);
  2688.     HICON GetIcon() const;
  2689.  
  2690. #if (WINVER >= 0x400)
  2691.     HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile);
  2692.     HENHMETAFILE GetEnhMetaFile() const;
  2693.     HBITMAP SetBitmap(HBITMAP hBitmap);
  2694.     HBITMAP GetBitmap() const;
  2695.     HCURSOR SetCursor(HCURSOR hCursor);
  2696.     HCURSOR GetCursor();
  2697. #endif
  2698.  
  2699. // Implementation
  2700. public:
  2701.     virtual ~CStatic();
  2702. };
  2703.  
  2704. class CButton : public CWnd
  2705. {
  2706.     DECLARE_DYNAMIC(CButton)
  2707.  
  2708. // Constructors
  2709. public:
  2710.     CButton();
  2711.     BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle,
  2712.                 const RECT& rect, CWnd* pParentWnd, UINT nID);
  2713.  
  2714. // Attributes
  2715.     UINT GetState() const;
  2716.     void SetState(BOOL bHighlight);
  2717.     int GetCheck() const;
  2718.     void SetCheck(int nCheck);
  2719.     UINT GetButtonStyle() const;
  2720.     void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);
  2721.  
  2722. #if (WINVER >= 0x400)
  2723.     HICON SetIcon(HICON hIcon);
  2724.     HICON GetIcon() const;
  2725.     HBITMAP SetBitmap(HBITMAP hBitmap);
  2726.     HBITMAP GetBitmap() const;
  2727.     HCURSOR SetCursor(HCURSOR hCursor);
  2728.     HCURSOR GetCursor();
  2729. #endif
  2730.  
  2731. // Overridables (for owner draw only)
  2732.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  2733.  
  2734. // Implementation
  2735. public:
  2736.     virtual ~CButton();
  2737. protected:
  2738.     virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
  2739. };
  2740.  
  2741. class CListBox : public CWnd
  2742. {
  2743.     DECLARE_DYNAMIC(CListBox)
  2744.  
  2745. // Constructors
  2746. public:
  2747.     CListBox();
  2748.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  2749.  
  2750. // Attributes
  2751.  
  2752.     // for entire listbox
  2753.     int GetCount() const;
  2754.     int GetHorizontalExtent() const;
  2755.     void SetHorizontalExtent(int cxExtent);
  2756.     int GetTopIndex() const;
  2757.     int SetTopIndex(int nIndex);
  2758.     LCID GetLocale() const;
  2759.     LCID SetLocale(LCID nNewLocale);
  2760. #if (WINVER >= 0x400)
  2761.     int InitStorage(int nItems, UINT nBytes);
  2762.     UINT ItemFromPoint(CPoint pt, BOOL& bOutside) const;
  2763. #endif
  2764.     // for single-selection listboxes
  2765.     int GetCurSel() const;
  2766.     int SetCurSel(int nSelect);
  2767.  
  2768.     // for multiple-selection listboxes
  2769.     int GetSel(int nIndex) const;           // also works for single-selection
  2770.     int SetSel(int nIndex, BOOL bSelect = TRUE);
  2771.     int GetSelCount() const;
  2772.     int GetSelItems(int nMaxItems, LPINT rgIndex) const;
  2773.     void SetAnchorIndex(int nIndex);
  2774.     int GetAnchorIndex() const;
  2775.  
  2776.     // for listbox items
  2777.     DWORD GetItemData(int nIndex) const;
  2778.     int SetItemData(int nIndex, DWORD dwItemData);
  2779.     void* GetItemDataPtr(int nIndex) const;
  2780.     int SetItemDataPtr(int nIndex, void* pData);
  2781.     int GetItemRect(int nIndex, LPRECT lpRect) const;
  2782.     int GetText(int nIndex, LPTSTR lpszBuffer) const;
  2783.     void GetText(int nIndex, CString& rString) const;
  2784.     int GetTextLen(int nIndex) const;
  2785.  
  2786.     // Settable only attributes
  2787.     void SetColumnWidth(int cxWidth);
  2788.     BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
  2789.     void SetTabStops();
  2790.     BOOL SetTabStops(const int& cxEachStop);    // takes an 'int'
  2791.  
  2792.     int SetItemHeight(int nIndex, UINT cyItemHeight);
  2793.     int GetItemHeight(int nIndex) const;
  2794.     int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
  2795.     int GetCaretIndex() const;
  2796.     int SetCaretIndex(int nIndex, BOOL bScroll = TRUE);
  2797.  
  2798. // Operations
  2799.     // manipulating listbox items
  2800.     int AddString(LPCTSTR lpszItem);
  2801.     int DeleteString(UINT nIndex);
  2802.     int InsertString(int nIndex, LPCTSTR lpszItem);
  2803.     void ResetContent();
  2804.     int Dir(UINT attr, LPCTSTR lpszWildCard);
  2805.  
  2806.     // selection helpers
  2807.     int FindString(int nStartAfter, LPCTSTR lpszItem) const;
  2808.     int SelectString(int nStartAfter, LPCTSTR lpszItem);
  2809.     int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem);
  2810.  
  2811. // Overridables (must override draw, measure and compare for owner draw)
  2812.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  2813.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  2814.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  2815.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  2816.     virtual int VKeyToItem(UINT nKey, UINT nIndex);
  2817.     virtual int CharToItem(UINT nKey, UINT nIndex);
  2818.  
  2819. // Implementation
  2820. public:
  2821.     virtual ~CListBox();
  2822. protected:
  2823.     virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
  2824. };
  2825.  
  2826. class CCheckListBox : public CListBox
  2827. {
  2828.     DECLARE_DYNAMIC(CCheckListBox)
  2829.  
  2830. // Constructors
  2831. public:
  2832.     CCheckListBox();
  2833.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  2834.  
  2835. // Attributes
  2836.     void SetCheckStyle(UINT nStyle);
  2837.     UINT GetCheckStyle();
  2838.     void SetCheck(int nIndex, int nCheck);
  2839.     int GetCheck(int nIndex);
  2840.     void Enable(int nIndex, BOOL bEnabled = TRUE);
  2841.     BOOL IsEnabled(int nIndex);
  2842.  
  2843.     virtual CRect OnGetCheckPosition(CRect rectItem, CRect rectCheckBox);
  2844.  
  2845. // Overridables (must override draw, measure and compare for owner draw)
  2846.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  2847.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  2848.  
  2849. // Implementation
  2850. protected:
  2851.     void PreDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  2852.     void PreMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  2853.     int PreCompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  2854.     void PreDeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  2855.  
  2856.     virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
  2857.  
  2858.    void SetSelectionCheck( int nCheck );
  2859.  
  2860. #ifdef _DEBUG
  2861.     virtual void PreSubclassWindow();
  2862. #endif
  2863.  
  2864.     int CalcMinimumItemHeight();
  2865.     void InvalidateCheck(int nIndex);
  2866.     void InvalidateItem(int nIndex);
  2867.     int CheckFromPoint(CPoint point, BOOL& bInCheck);
  2868.  
  2869.     int m_cyText;
  2870.     UINT m_nStyle;
  2871.  
  2872.     // Message map functions
  2873. protected:
  2874.     //{{AFX_MSG(CCheckListBox)
  2875.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  2876.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  2877.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  2878.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  2879.     afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
  2880.     afx_msg LRESULT OnLBAddString(WPARAM wParam, LPARAM lParam);
  2881.     afx_msg LRESULT OnLBFindString(WPARAM wParam, LPARAM lParam);
  2882.     afx_msg LRESULT OnLBFindStringExact(WPARAM wParam, LPARAM lParam);
  2883.     afx_msg LRESULT OnLBGetItemData(WPARAM wParam, LPARAM lParam);
  2884.     afx_msg LRESULT OnLBGetText(WPARAM wParam, LPARAM lParam);
  2885.     afx_msg LRESULT OnLBInsertString(WPARAM wParam, LPARAM lParam);
  2886.     afx_msg LRESULT OnLBSelectString(WPARAM wParam, LPARAM lParam);
  2887.     afx_msg LRESULT OnLBSetItemData(WPARAM wParam, LPARAM lParam);
  2888.     afx_msg LRESULT OnLBSetItemHeight(WPARAM wParam, LPARAM lParam);
  2889.     //}}AFX_MSG
  2890.     DECLARE_MESSAGE_MAP()
  2891. };
  2892.  
  2893. class CComboBox : public CWnd
  2894. {
  2895.     DECLARE_DYNAMIC(CComboBox)
  2896.  
  2897. // Constructors
  2898. public:
  2899.     CComboBox();
  2900.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  2901.  
  2902. // Attributes
  2903.     // for entire combo box
  2904.     int GetCount() const;
  2905.     int GetCurSel() const;
  2906.     int SetCurSel(int nSelect);
  2907.     LCID GetLocale() const;
  2908.     LCID SetLocale(LCID nNewLocale);
  2909. // Win4
  2910.     int GetTopIndex() const;
  2911.     int SetTopIndex(int nIndex);
  2912.     int InitStorage(int nItems, UINT nBytes);
  2913.     void SetHorizontalExtent(UINT nExtent);
  2914.     UINT GetHorizontalExtent() const;
  2915.     int SetDroppedWidth(UINT nWidth);
  2916.     int GetDroppedWidth() const;
  2917.  
  2918.     // for edit control
  2919.     DWORD GetEditSel() const;
  2920.     BOOL LimitText(int nMaxChars);
  2921.     BOOL SetEditSel(int nStartChar, int nEndChar);
  2922.  
  2923.     // for combobox item
  2924.     DWORD GetItemData(int nIndex) const;
  2925.     int SetItemData(int nIndex, DWORD dwItemData);
  2926.     void* GetItemDataPtr(int nIndex) const;
  2927.     int SetItemDataPtr(int nIndex, void* pData);
  2928.     int GetLBText(int nIndex, LPTSTR lpszText) const;
  2929.     void GetLBText(int nIndex, CString& rString) const;
  2930.     int GetLBTextLen(int nIndex) const;
  2931.  
  2932.     int SetItemHeight(int nIndex, UINT cyItemHeight);
  2933.     int GetItemHeight(int nIndex) const;
  2934.     int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
  2935.     int SetExtendedUI(BOOL bExtended = TRUE);
  2936.     BOOL GetExtendedUI() const;
  2937.     void GetDroppedControlRect(LPRECT lprect) const;
  2938.     BOOL GetDroppedState() const;
  2939.  
  2940. // Operations
  2941.     // for drop-down combo boxes
  2942.     void ShowDropDown(BOOL bShowIt = TRUE);
  2943.  
  2944.     // manipulating listbox items
  2945.     int AddString(LPCTSTR lpszString);
  2946.     int DeleteString(UINT nIndex);
  2947.     int InsertString(int nIndex, LPCTSTR lpszString);
  2948.     void ResetContent();
  2949.     int Dir(UINT attr, LPCTSTR lpszWildCard);
  2950.  
  2951.     // selection helpers
  2952.     int FindString(int nStartAfter, LPCTSTR lpszString) const;
  2953.     int SelectString(int nStartAfter, LPCTSTR lpszString);
  2954.  
  2955.     // Clipboard operations
  2956.     void Clear();
  2957.     void Copy();
  2958.     void Cut();
  2959.     void Paste();
  2960.  
  2961. // Overridables (must override draw, measure and compare for owner draw)
  2962.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  2963.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  2964.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  2965.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  2966.  
  2967. // Implementation
  2968. public:
  2969.     virtual ~CComboBox();
  2970. protected:
  2971.     virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
  2972. };
  2973.  
  2974. class CEdit : public CWnd
  2975. {
  2976.     DECLARE_DYNAMIC(CEdit)
  2977.  
  2978. // Constructors
  2979. public:
  2980.     CEdit();
  2981.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  2982.  
  2983. // Attributes
  2984.     BOOL CanUndo() const;
  2985.     int GetLineCount() const;
  2986.     BOOL GetModify() const;
  2987.     void SetModify(BOOL bModified = TRUE);
  2988.     void GetRect(LPRECT lpRect) const;
  2989.     DWORD GetSel() const;
  2990.     void GetSel(int& nStartChar, int& nEndChar) const;
  2991.     HLOCAL GetHandle() const;
  2992.     void SetHandle(HLOCAL hBuffer);
  2993. #if (WINVER >= 0x400)
  2994.     void SetMargins(UINT nLeft, UINT nRight);
  2995.     DWORD GetMargins() const;
  2996.     void SetLimitText(UINT nMax);
  2997.     UINT GetLimitText() const;
  2998.     CPoint PosFromChar(UINT nChar) const;
  2999.     int CharFromPos(CPoint pt) const;
  3000. #endif
  3001.  
  3002.     // NOTE: first word in lpszBuffer must contain the size of the buffer!
  3003.     int GetLine(int nIndex, LPTSTR lpszBuffer) const;
  3004.     int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
  3005.  
  3006. // Operations
  3007.     void EmptyUndoBuffer();
  3008.     BOOL FmtLines(BOOL bAddEOL);
  3009.  
  3010.     void LimitText(int nChars = 0);
  3011.     int LineFromChar(int nIndex = -1) const;
  3012.     int LineIndex(int nLine = -1) const;
  3013.     int LineLength(int nLine = -1) const;
  3014.     void LineScroll(int nLines, int nChars = 0);
  3015.     void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE);
  3016.     void SetPasswordChar(TCHAR ch);
  3017.     void SetRect(LPCRECT lpRect);
  3018.     void SetRectNP(LPCRECT lpRect);
  3019.     void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE);
  3020.     void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE);
  3021.     BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
  3022.     void SetTabStops();
  3023.     BOOL SetTabStops(const int& cxEachStop);    // takes an 'int'
  3024.  
  3025.     // Clipboard operations
  3026.     BOOL Undo();
  3027.     void Clear();
  3028.     void Copy();
  3029.     void Cut();
  3030.     void Paste();
  3031.  
  3032.     BOOL SetReadOnly(BOOL bReadOnly = TRUE);
  3033.     int GetFirstVisibleLine() const;
  3034.     TCHAR GetPasswordChar() const;
  3035.  
  3036. // Implementation
  3037. public:
  3038.     virtual ~CEdit();
  3039. };
  3040.  
  3041. class CScrollBar : public CWnd
  3042. {
  3043.     DECLARE_DYNAMIC(CScrollBar)
  3044.  
  3045. // Constructors
  3046. public:
  3047.     CScrollBar();
  3048.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  3049.  
  3050. // Attributes
  3051.     int GetScrollPos() const;
  3052.     int SetScrollPos(int nPos, BOOL bRedraw = TRUE);
  3053.     void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const;
  3054.     void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE);
  3055.     void ShowScrollBar(BOOL bShow = TRUE);
  3056.  
  3057.     BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH);
  3058.  
  3059.     BOOL SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE);
  3060.     BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL);
  3061.     int GetScrollLimit();
  3062.  
  3063. // Implementation
  3064. public:
  3065.     virtual ~CScrollBar();
  3066. };
  3067.  
  3068. /////////////////////////////////////////////////////////////////////////////
  3069. // CFrameWnd - base class for SDI and other frame windows
  3070.  
  3071. // Frame window styles
  3072. #define FWS_ADDTOTITLE  0x00008000L // modify title based on content
  3073. #define FWS_PREFIXTITLE 0x00004000L // show document name before app name
  3074. #define FWS_SNAPTOBARS  0x00002000L // snap size to size of contained bars
  3075.  
  3076. struct CPrintPreviewState;  // forward reference (see afxext.h)
  3077. class CControlBar;          // forward reference (see afxext.h)
  3078. class CReBar;               // forward reference (see afxext.h)
  3079.  
  3080. class CDockBar;             // forward reference (see afxpriv.h)
  3081. class CMiniDockFrameWnd;    // forward reference (see afxpriv.h)
  3082. class CDockState;           // forward reference (see afxpriv.h)
  3083.  
  3084. class COleFrameHook;        // forward reference (see ..\src\oleimpl2.h)
  3085.  
  3086. class CFrameWnd : public CWnd
  3087. {
  3088.     DECLARE_DYNCREATE(CFrameWnd)
  3089.  
  3090. // Constructors
  3091. public:
  3092.     static AFX_DATA const CRect rectDefault;
  3093.     CFrameWnd();
  3094.  
  3095.     BOOL LoadAccelTable(LPCTSTR lpszResourceName);
  3096.     BOOL Create(LPCTSTR lpszClassName,
  3097.                 LPCTSTR lpszWindowName,
  3098.                 DWORD dwStyle = WS_OVERLAPPEDWINDOW,
  3099.                 const RECT& rect = rectDefault,
  3100.                 CWnd* pParentWnd = NULL,        // != NULL for popups
  3101.                 LPCTSTR lpszMenuName = NULL,
  3102.                 DWORD dwExStyle = 0,
  3103.                 CCreateContext* pContext = NULL);
  3104.  
  3105.     // dynamic creation - load frame and associated resources
  3106.     virtual BOOL LoadFrame(UINT nIDResource,
  3107.                 DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
  3108.                 CWnd* pParentWnd = NULL,
  3109.                 CCreateContext* pContext = NULL);
  3110.  
  3111.     // special helper for view creation
  3112.     CWnd* CreateView(CCreateContext* pContext, UINT nID = AFX_IDW_PANE_FIRST);
  3113.  
  3114. // Attributes
  3115.     virtual CDocument* GetActiveDocument();
  3116.  
  3117.     // Active child view maintenance
  3118.     CView* GetActiveView() const;           // active view or NULL
  3119.     void SetActiveView(CView* pViewNew, BOOL bNotify = TRUE);
  3120.         // active view or NULL, bNotify == FALSE if focus should not be set
  3121.  
  3122.     // Active frame (for frames within frames -- MDI)
  3123.     virtual CFrameWnd* GetActiveFrame();
  3124.  
  3125.     // For customizing the default messages on the status bar
  3126.     virtual void GetMessageString(UINT nID, CString& rMessage) const;
  3127.  
  3128.     BOOL m_bAutoMenuEnable;
  3129.         // TRUE => menu items without handlers will be disabled
  3130.  
  3131.     BOOL IsTracking() const;
  3132.  
  3133. // Operations
  3134.     virtual void RecalcLayout(BOOL bNotify = TRUE);
  3135.     virtual void ActivateFrame(int nCmdShow = -1);
  3136.     void InitialUpdateFrame(CDocument* pDoc, BOOL bMakeVisible);
  3137.     void SetTitle(LPCTSTR lpszTitle);
  3138.     CString GetTitle() const;
  3139.  
  3140.     // to set text of standard status bar
  3141.     void SetMessageText(LPCTSTR lpszText);
  3142.     void SetMessageText(UINT nID);
  3143.  
  3144.     // control bar docking
  3145.     void EnableDocking(DWORD dwDockStyle);
  3146.     void DockControlBar(CControlBar* pBar, UINT nDockBarID = 0,
  3147.         LPCRECT lpRect = NULL);
  3148.     void FloatControlBar(CControlBar* pBar, CPoint point,
  3149.         DWORD dwStyle = CBRS_ALIGN_TOP);
  3150.     CControlBar* GetControlBar(UINT nID);
  3151.  
  3152.     // frame window based modality
  3153.     virtual void BeginModalState();
  3154.     virtual void EndModalState();
  3155.     BOOL InModalState() const;
  3156.     void ShowOwnedWindows(BOOL bShow);
  3157.  
  3158.     // saving and loading control bar state
  3159.     void LoadBarState(LPCTSTR lpszProfileName);
  3160.     void SaveBarState(LPCTSTR lpszProfileName) const;
  3161.     void ShowControlBar(CControlBar* pBar, BOOL bShow, BOOL bDelay);
  3162.     void SetDockState(const CDockState& state);
  3163.     void GetDockState(CDockState& state) const;
  3164.  
  3165. // Overridables
  3166.     virtual void OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState);
  3167.     virtual CWnd* GetMessageBar();
  3168.  
  3169.     // border space negotiation
  3170.     enum BorderCmd
  3171.         { borderGet = 1, borderRequest = 2, borderSet = 3 };
  3172.     virtual BOOL NegotiateBorderSpace(UINT nBorderCmd, LPRECT lpRectBorder);
  3173.  
  3174. protected:
  3175.     virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
  3176.  
  3177. // Command Handlers
  3178. public:
  3179.     afx_msg void OnContextHelp();   // for Shift+F1 help
  3180.     afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);
  3181.     afx_msg BOOL OnBarCheck(UINT nID);
  3182.  
  3183. // Implementation
  3184. public:
  3185.     virtual ~CFrameWnd();
  3186.     int m_nWindow;  // general purpose window number - display as ":n"
  3187.                     // -1 => unknown, 0 => only window viewing document
  3188.                     // 1 => first of many windows viewing document, 2=> second
  3189.  
  3190.     HMENU m_hMenuDefault;       // default menu resource for this frame
  3191.     HACCEL m_hAccelTable;       // accelerator table
  3192.     DWORD m_dwPromptContext;    // current help prompt context for message box
  3193.     BOOL m_bHelpMode;           // if TRUE, then Shift+F1 help mode is active
  3194.     CFrameWnd* m_pNextFrameWnd; // next CFrameWnd in app global list
  3195.     CRect m_rectBorder;         // for OLE border space negotiation
  3196.     COleFrameHook* m_pNotifyHook;
  3197.  
  3198.     CPtrList m_listControlBars; // array of all control bars that have this
  3199.                                 // window as their dock site
  3200.     int m_nShowDelay;           // SW_ command for delay show/hide
  3201.  
  3202.     CMiniDockFrameWnd* CreateFloatingFrame(DWORD dwStyle);
  3203.     DWORD CanDock(CRect rect, DWORD dwDockStyle,
  3204.         CDockBar** ppDockBar = NULL); // called by CDockContext
  3205.     void AddControlBar(CControlBar *pBar);
  3206.     void RemoveControlBar(CControlBar *pBar);
  3207.     void DockControlBar(CControlBar* pBar, CDockBar* pDockBar,
  3208.         LPCRECT lpRect = NULL);
  3209.     void ReDockControlBar(CControlBar* pBar, CDockBar* pDockBar,
  3210.         LPCRECT lpRect = NULL);
  3211.     void NotifyFloatingWindows(DWORD dwFlags);
  3212.     void DestroyDockBars();
  3213.  
  3214. protected:
  3215.     UINT m_nIDHelp;             // Help ID (0 for none, see HID_BASE_RESOURCE)
  3216.     UINT m_nIDTracking;         // tracking command ID or string IDS
  3217.     UINT m_nIDLastMessage;      // last displayed message string IDS
  3218.     CView* m_pViewActive;       // current active view
  3219.     BOOL (CALLBACK* m_lpfnCloseProc)(CFrameWnd* pFrameWnd);
  3220.     UINT m_cModalStack;         // BeginModalState depth
  3221.     HWND* m_phWndDisable;       // windows disabled because of BeginModalState
  3222.     HMENU m_hMenuAlt;           // menu to update to (NULL means default)
  3223.     CString m_strTitle;         // default title (original)
  3224.     BOOL m_bInRecalcLayout;     // avoid recursion in RecalcLayout
  3225.     CRuntimeClass* m_pFloatingFrameClass;
  3226.     static const DWORD dwDockBarMap[4][2];
  3227.  
  3228. public:
  3229. #ifdef _DEBUG
  3230.     virtual void AssertValid() const;
  3231.     virtual void Dump(CDumpContext& dc) const;
  3232. #endif
  3233.     virtual BOOL IsFrameWnd() const;
  3234.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  3235.         AFX_CMDHANDLERINFO* pHandlerInfo);
  3236.     virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
  3237.     virtual void OnUpdateFrameMenu(HMENU hMenuAlt);
  3238.     virtual HACCEL GetDefaultAccelerator();
  3239.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  3240.  
  3241.     // idle update of frame user interface
  3242.     enum IdleFlags
  3243.         { idleMenu = 1, idleTitle = 2, idleNotify = 4, idleLayout = 8 };
  3244.     UINT m_nIdleFlags;          // set of bit flags for idle processing
  3245.     virtual void DelayUpdateFrameMenu(HMENU hMenuAlt);
  3246.     void DelayUpdateFrameTitle();
  3247.     void DelayRecalcLayout(BOOL bNotify = TRUE);
  3248.  
  3249.     // for Shift+F1 help support
  3250.     BOOL CanEnterHelpMode();
  3251.     virtual void ExitHelpMode();
  3252.  
  3253.     // implementation helpers
  3254. public:
  3255.     void UpdateFrameTitleForDocument(LPCTSTR lpszDocName);
  3256. protected:
  3257.     LPCTSTR GetIconWndClass(DWORD dwDefaultStyle, UINT nIDResource);
  3258.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3259.     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  3260.     virtual void PostNcDestroy();   // default to delete this.
  3261.     int OnCreateHelper(LPCREATESTRUCT lpcs, CCreateContext* pContext);
  3262.     void BringToTop(int nCmdShow);
  3263.         // bring window to top for SW_ commands which affect z-order
  3264.  
  3265.     // implementation helpers for Shift+F1 help mode
  3266.     BOOL ProcessHelpMsg(MSG& msg, DWORD* pContext);
  3267.     HWND SetHelpCapture(POINT point, BOOL* pbDescendant);
  3268.  
  3269.     // CFrameWnd list management
  3270.     void AddFrameWnd();
  3271.     void RemoveFrameWnd();
  3272.  
  3273.     friend class CWnd;  // for access to m_bModalDisable
  3274.     friend class CReBar; // for access to m_bInRecalcLayout
  3275.  
  3276.     //{{AFX_MSG(CFrameWnd)
  3277.     // Windows messages
  3278.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  3279.     afx_msg void OnDestroy();
  3280.     afx_msg void OnClose();
  3281.     afx_msg void OnInitMenu(CMenu*);
  3282.     afx_msg void OnInitMenuPopup(CMenu*, UINT, BOOL);
  3283.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  3284.     afx_msg LRESULT OnPopMessageString(WPARAM wParam, LPARAM lParam);
  3285.     afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
  3286.     afx_msg LRESULT OnHelpPromptAddr(WPARAM wParam, LPARAM lParam);
  3287.     afx_msg void OnIdleUpdateCmdUI();
  3288.     afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
  3289.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  3290.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  3291.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  3292.     afx_msg void OnSize(UINT nType, int cx, int cy);
  3293.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  3294.     afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
  3295.     afx_msg BOOL OnNcActivate(BOOL bActive);
  3296.     afx_msg void OnSysCommand(UINT nID, LONG lParam);
  3297.     afx_msg BOOL OnQueryEndSession();
  3298.     afx_msg void OnEndSession(BOOL bEnding);
  3299.     afx_msg void OnDropFiles(HDROP hDropInfo);
  3300.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  3301.     afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
  3302.     afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
  3303.     afx_msg LRESULT OnActivateTopLevel(WPARAM wParam, LPARAM lParam);
  3304.     afx_msg void OnEnable(BOOL bEnable);
  3305.     afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  3306.     afx_msg BOOL OnQueryNewPalette();
  3307.     // standard commands
  3308.     afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
  3309.     afx_msg void OnUpdateKeyIndicator(CCmdUI* pCmdUI);
  3310.     afx_msg void OnHelp();
  3311.     afx_msg void OnUpdateContextHelp(CCmdUI* pCmdUI);
  3312.     //}}AFX_MSG
  3313. protected:
  3314.     afx_msg LRESULT OnDDEInitiate(WPARAM wParam, LPARAM lParam);
  3315.     afx_msg LRESULT OnDDEExecute(WPARAM wParam, LPARAM lParam);
  3316.     afx_msg LRESULT OnDDETerminate(WPARAM wParam, LPARAM lParam);
  3317.     afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
  3318.     DECLARE_MESSAGE_MAP()
  3319.  
  3320.     friend class CWinApp;
  3321. };
  3322.  
  3323. /////////////////////////////////////////////////////////////////////////////
  3324. // MDI Support
  3325.  
  3326. class CMDIFrameWnd : public CFrameWnd
  3327. {
  3328.     DECLARE_DYNCREATE(CMDIFrameWnd)
  3329.  
  3330. public:
  3331. // Constructors
  3332.     CMDIFrameWnd();
  3333.  
  3334. // Operations
  3335.     void MDIActivate(CWnd* pWndActivate);
  3336.     CMDIChildWnd* MDIGetActive(BOOL* pbMaximized = NULL) const;
  3337.     void MDIIconArrange();
  3338.     void MDIMaximize(CWnd* pWnd);
  3339.     void MDINext();
  3340.     void MDIRestore(CWnd* pWnd);
  3341.     CMenu* MDISetMenu(CMenu* pFrameMenu, CMenu* pWindowMenu);
  3342.     void MDITile();
  3343.     void MDICascade();
  3344.     void MDITile(int nType);
  3345.     void MDICascade(int nType);
  3346.     CMDIChildWnd* CreateNewChild(CRuntimeClass* pClass, UINT nResource,
  3347.         HMENU hMenu = NULL, HACCEL hAccel = NULL);
  3348.  
  3349. // Overridables
  3350.     // MFC 1.0 backward compatible CreateClient hook (called by OnCreateClient)
  3351.     virtual BOOL CreateClient(LPCREATESTRUCT lpCreateStruct, CMenu* pWindowMenu);
  3352.     // customize if using an 'Window' menu with non-standard IDs
  3353.     virtual HMENU GetWindowMenuPopup(HMENU hMenuBar);
  3354.  
  3355. // Implementation
  3356. public:
  3357.     HWND m_hWndMDIClient;       // MDI Client window handle
  3358.  
  3359. #ifdef _DEBUG
  3360.     virtual void AssertValid() const;
  3361.     virtual void Dump(CDumpContext& dc) const;
  3362. #endif
  3363.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3364.     virtual BOOL LoadFrame(UINT nIDResource,
  3365.                 DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
  3366.                 CWnd* pParentWnd = NULL,
  3367.                 CCreateContext* pContext = NULL);
  3368.     virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
  3369.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  3370.     virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
  3371.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  3372.         AFX_CMDHANDLERINFO* pHandlerInfo);
  3373.     virtual void OnUpdateFrameMenu(HMENU hMenuAlt);
  3374.     virtual void DelayUpdateFrameMenu(HMENU hMenuAlt);
  3375.     virtual CFrameWnd* GetActiveFrame();
  3376.  
  3377. protected:
  3378.     virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
  3379.     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  3380.  
  3381.     //{{AFX_MSG(CMDIFrameWnd)
  3382.     afx_msg void OnDestroy();
  3383.     afx_msg void OnSize(UINT nType, int cx, int cy);
  3384.     afx_msg void OnUpdateMDIWindowCmd(CCmdUI* pCmdUI);
  3385.     afx_msg BOOL OnMDIWindowCmd(UINT nID);
  3386.     afx_msg void OnWindowNew();
  3387.     afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
  3388.     afx_msg void OnIdleUpdateCmdUI();
  3389.     afx_msg LRESULT OnMenuChar(UINT nChar, UINT, CMenu*);
  3390.     //}}AFX_MSG
  3391.     DECLARE_MESSAGE_MAP()
  3392. };
  3393.  
  3394. class CMDIChildWnd : public CFrameWnd
  3395. {
  3396.     DECLARE_DYNCREATE(CMDIChildWnd)
  3397.  
  3398. // Constructors
  3399. public:
  3400.     CMDIChildWnd();
  3401.  
  3402.     virtual BOOL Create(LPCTSTR lpszClassName,
  3403.                 LPCTSTR lpszWindowName,
  3404.                 DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
  3405.                 const RECT& rect = rectDefault,
  3406.                 CMDIFrameWnd* pParentWnd = NULL,
  3407.                 CCreateContext* pContext = NULL);
  3408.  
  3409. // Attributes
  3410.     CMDIFrameWnd* GetMDIFrame();
  3411.  
  3412. // Operations
  3413.     void MDIDestroy();
  3414.     void MDIActivate();
  3415.     void MDIMaximize();
  3416.     void MDIRestore();
  3417.     void SetHandles(HMENU hMenu, HACCEL hAccel);
  3418.  
  3419. // Implementation
  3420. protected:
  3421.     HMENU m_hMenuShared;        // menu when we are active
  3422.  
  3423. public:
  3424. #ifdef _DEBUG
  3425.     virtual void AssertValid() const;
  3426.     virtual void Dump(CDumpContext& dc) const;
  3427. #endif
  3428.  
  3429.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3430.     virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
  3431.                     CWnd* pParentWnd, CCreateContext* pContext = NULL);
  3432.         // 'pParentWnd' parameter is required for MDI Child
  3433.     virtual BOOL DestroyWindow();
  3434.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  3435.     virtual void ActivateFrame(int nCmdShow = -1);
  3436.     virtual void OnUpdateFrameMenu(BOOL bActive, CWnd* pActivateWnd,
  3437.         HMENU hMenuAlt);
  3438.  
  3439.     BOOL m_bPseudoInactive;     // TRUE if window is MDI active according to
  3440.                                 //  windows, but not according to MFC...
  3441.  
  3442. protected:
  3443.     virtual CWnd* GetMessageBar();
  3444.     virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
  3445.     virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
  3446.     BOOL UpdateClientEdge(LPRECT lpRect = NULL);
  3447.  
  3448.     //{{AFX_MSG(CMDIChildWnd)
  3449.     afx_msg void OnMDIActivate(BOOL bActivate, CWnd*, CWnd*);
  3450.     afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
  3451.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  3452.     afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
  3453.     afx_msg void OnSize(UINT nType, int cx, int cy);
  3454.     afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
  3455.     afx_msg BOOL OnNcActivate(BOOL bActive);
  3456.     afx_msg void OnDestroy();
  3457.     afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
  3458.     //}}AFX_MSG
  3459.     DECLARE_MESSAGE_MAP()
  3460. };
  3461.  
  3462. /////////////////////////////////////////////////////////////////////////////
  3463. // CMiniFrameWnd
  3464.  
  3465. // MiniFrame window styles
  3466. #define MFS_SYNCACTIVE      0x00000100L // syncronize activation w/ parent
  3467. #define MFS_4THICKFRAME     0x00000200L // thick frame all around (no tiles)
  3468. #define MFS_THICKFRAME      0x00000400L // use instead of WS_THICKFRAME
  3469. #define MFS_MOVEFRAME       0x00000800L // no sizing, just moving
  3470. #define MFS_BLOCKSYSMENU    0x00001000L // block hit testing on system menu
  3471.  
  3472. class CMiniFrameWnd : public CFrameWnd
  3473. {
  3474.     DECLARE_DYNCREATE(CMiniFrameWnd)
  3475.  
  3476. // Constructors
  3477. public:
  3478.     CMiniFrameWnd();
  3479.     BOOL Create(LPCTSTR lpClassName, LPCTSTR lpWindowName,
  3480.         DWORD dwStyle, const RECT& rect,
  3481.         CWnd* pParentWnd = NULL, UINT nID = 0);
  3482.     BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
  3483.         DWORD dwStyle, const RECT& rect,
  3484.         CWnd* pParentWnd = NULL, UINT nID = 0);
  3485.  
  3486. // Implementation
  3487. public:
  3488.     ~CMiniFrameWnd();
  3489.  
  3490.     static void AFX_CDECL Initialize();
  3491.  
  3492.     //{{AFX_MSG(CMiniFrameWnd)
  3493.     afx_msg BOOL OnNcActivate(BOOL bActive);
  3494.     afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpParams);
  3495.     afx_msg UINT OnNcHitTest(CPoint point);
  3496.     afx_msg void OnNcPaint();
  3497.     afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint pt);
  3498.     afx_msg void OnLButtonUp(UINT nFlags, CPoint pt);
  3499.     afx_msg void OnMouseMove(UINT nFlags, CPoint pt);
  3500.     afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  3501.     afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
  3502.     afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam);
  3503.     afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam);
  3504.     afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
  3505.     afx_msg LRESULT OnFloatStatus(WPARAM wParam, LPARAM lParam);
  3506.     afx_msg LRESULT OnQueryCenterWnd(WPARAM wParam, LPARAM lParam);
  3507.     afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpcs);
  3508.     //}}AFX_MSG
  3509.     DECLARE_MESSAGE_MAP()
  3510.  
  3511. public:
  3512.     virtual void CalcWindowRect(LPRECT lpClientRect,
  3513.         UINT nAdjustType = adjustBorder);
  3514.  
  3515.     static void PASCAL CalcBorders(LPRECT lpClientRect,
  3516.         DWORD dwStyle = WS_THICKFRAME | WS_CAPTION, DWORD dwExStyle = 0);
  3517.  
  3518. protected:
  3519.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3520.  
  3521. protected:
  3522.     BOOL m_bSysTracking;
  3523.     BOOL m_bInSys;
  3524.     BOOL m_bActive;
  3525.     CString m_strCaption;
  3526.  
  3527.     void InvertSysMenu();
  3528. };
  3529.  
  3530. /////////////////////////////////////////////////////////////////////////////
  3531. // class CView is the client area UI for a document
  3532.  
  3533. class CPrintDialog;     // forward reference (see afxdlgs.h)
  3534. class CPreviewView;     // forward reference (see afxpriv.h)
  3535. class CSplitterWnd;     // forward reference (see afxext.h)
  3536. class COleServerDoc;    // forward reference (see afxole.h)
  3537.  
  3538. typedef DWORD DROPEFFECT;
  3539. class COleDataObject;   // forward reference (see afxole.h)
  3540.  
  3541. #ifdef _AFXDLL
  3542. class CView : public CWnd
  3543. #else
  3544. class AFX_NOVTABLE CView : public CWnd
  3545. #endif
  3546. {
  3547.     DECLARE_DYNAMIC(CView)
  3548.  
  3549. // Constructors
  3550. protected:
  3551.     CView();
  3552.  
  3553. // Attributes
  3554. public:
  3555.     CDocument* GetDocument() const;
  3556.  
  3557. // Operations
  3558. public:
  3559.     // for standard printing setup (override OnPreparePrinting)
  3560.     BOOL DoPreparePrinting(CPrintInfo* pInfo);
  3561.  
  3562. // Overridables
  3563. public:
  3564.     virtual BOOL IsSelected(const CObject* pDocItem) const; // support for OLE
  3565.  
  3566.     // OLE scrolling support (used for drag/drop as well)
  3567.     virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);
  3568.     virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
  3569.  
  3570.     // OLE drag/drop support
  3571.     virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,
  3572.         DWORD dwKeyState, CPoint point);
  3573.     virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,
  3574.         DWORD dwKeyState, CPoint point);
  3575.     virtual void OnDragLeave();
  3576.     virtual BOOL OnDrop(COleDataObject* pDataObject,
  3577.         DROPEFFECT dropEffect, CPoint point);
  3578.     virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject,
  3579.         DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
  3580.     virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
  3581.  
  3582.     virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
  3583.  
  3584.     virtual void OnInitialUpdate(); // called first time after construct
  3585.  
  3586. protected:
  3587.     // Activation
  3588.     virtual void OnActivateView(BOOL bActivate, CView* pActivateView,
  3589.                     CView* pDeactiveView);
  3590.     virtual void OnActivateFrame(UINT nState, CFrameWnd* pFrameWnd);
  3591.  
  3592.     // General drawing/updating
  3593.     virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
  3594.     virtual void OnDraw(CDC* pDC) = 0;
  3595.  
  3596.     // Printing support
  3597.     virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  3598.         // must override to enable printing and print preview
  3599.  
  3600.     virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  3601.     virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
  3602.     virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  3603.  
  3604.     // Advanced: end print preview mode, move to point
  3605.     virtual void OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point,
  3606.         CPreviewView* pView);
  3607.  
  3608. // Implementation
  3609. public:
  3610.     virtual ~CView();
  3611. #ifdef _DEBUG
  3612.     virtual void Dump(CDumpContext&) const;
  3613.     virtual void AssertValid() const;
  3614. #endif //_DEBUG
  3615.  
  3616.     // Advanced: for implementing custom print preview
  3617.     BOOL DoPrintPreview(UINT nIDResource, CView* pPrintView,
  3618.             CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState);
  3619.  
  3620.     virtual void CalcWindowRect(LPRECT lpClientRect,
  3621.         UINT nAdjustType = adjustBorder);
  3622.     virtual CScrollBar* GetScrollBarCtrl(int nBar) const;
  3623.     static CSplitterWnd* PASCAL GetParentSplitter(
  3624.         const CWnd* pWnd, BOOL bAnyState);
  3625.  
  3626. protected:
  3627.     CDocument* m_pDocument;
  3628.  
  3629. public:
  3630.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  3631.         AFX_CMDHANDLERINFO* pHandlerInfo);
  3632. protected:
  3633.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3634.     virtual void PostNcDestroy();
  3635.  
  3636.     // friend classes that call protected CView overridables
  3637.     friend class CDocument;
  3638.     friend class CDocTemplate;
  3639.     friend class CPreviewView;
  3640.     friend class CFrameWnd;
  3641.     friend class CMDIFrameWnd;
  3642.     friend class CMDIChildWnd;
  3643.     friend class CSplitterWnd;
  3644.     friend class COleServerDoc;
  3645.     friend class CDocObjectServer;
  3646.  
  3647.     //{{AFX_MSG(CView)
  3648.     afx_msg int OnCreate(LPCREATESTRUCT lpcs);
  3649.     afx_msg void OnDestroy();
  3650.     afx_msg void OnPaint();
  3651.     afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
  3652.     // commands
  3653.     afx_msg void OnUpdateSplitCmd(CCmdUI* pCmdUI);
  3654.     afx_msg BOOL OnSplitCmd(UINT nID);
  3655.     afx_msg void OnUpdateNextPaneMenu(CCmdUI* pCmdUI);
  3656.     afx_msg BOOL OnNextPaneCmd(UINT nID);
  3657.  
  3658.     // not mapped commands - must be mapped in derived class
  3659.     afx_msg void OnFilePrint();
  3660.     afx_msg void OnFilePrintPreview();
  3661.     //}}AFX_MSG
  3662.     DECLARE_MESSAGE_MAP()
  3663. };
  3664.  
  3665. /////////////////////////////////////////////////////////////////////////////
  3666. // class CCtrlView allows almost any control to be a view
  3667.  
  3668. #ifdef _AFXDLL
  3669. class CCtrlView : public CView
  3670. #else
  3671. class AFX_NOVTABLE CCtrlView : public CView
  3672. #endif
  3673. {
  3674.     DECLARE_DYNCREATE(CCtrlView)
  3675.  
  3676. public:
  3677.     CCtrlView(LPCTSTR lpszClass, DWORD dwStyle);
  3678.  
  3679. // Attributes
  3680. protected:
  3681.     CString m_strClass;
  3682.     DWORD m_dwDefaultStyle;
  3683.  
  3684. // Overrides
  3685.     virtual void OnDraw(CDC*);
  3686.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  3687.  
  3688. // Implementation
  3689. public:
  3690. #ifdef _DEBUG
  3691.     virtual void Dump(CDumpContext&) const;
  3692.     virtual void AssertValid() const;
  3693. #endif //_DEBUG
  3694.  
  3695. protected:
  3696.     afx_msg void OnPaint();
  3697.     DECLARE_MESSAGE_MAP()
  3698. };
  3699.  
  3700. /////////////////////////////////////////////////////////////////////////////
  3701. // class CScrollView supports simple scrolling and scaling
  3702.  
  3703. class CScrollView : public CView
  3704. {
  3705.     DECLARE_DYNAMIC(CScrollView)
  3706.  
  3707. // Constructors
  3708. protected:
  3709.     CScrollView();
  3710.  
  3711. public:
  3712.     static AFX_DATA const SIZE sizeDefault;
  3713.         // used to specify default calculated page and line sizes
  3714.  
  3715.     // in logical units - call one of the following Set routines
  3716.     void SetScaleToFitSize(SIZE sizeTotal);
  3717.     void SetScrollSizes(int nMapMode, SIZE sizeTotal,
  3718.                 const SIZE& sizePage = sizeDefault,
  3719.                 const SIZE& sizeLine = sizeDefault);
  3720.  
  3721. // Attributes
  3722. public:
  3723.     CPoint GetScrollPosition() const;       // upper corner of scrolling
  3724.     CSize GetTotalSize() const;             // logical size
  3725.  
  3726.     // for device units
  3727.     CPoint GetDeviceScrollPosition() const;
  3728.     void GetDeviceScrollSizes(int& nMapMode, SIZE& sizeTotal,
  3729.             SIZE& sizePage, SIZE& sizeLine) const;
  3730.  
  3731. // Operations
  3732. public:
  3733.     void ScrollToPosition(POINT pt);    // set upper left position
  3734.     void FillOutsideRect(CDC* pDC, CBrush* pBrush);
  3735.     void ResizeParentToFit(BOOL bShrinkOnly = TRUE);
  3736.     BOOL DoMouseWheel(UINT fFlags, short zDelta, CPoint point);
  3737.  
  3738. // Implementation
  3739. protected:
  3740.     int m_nMapMode;
  3741.     CSize m_totalLog;           // total size in logical units (no rounding)
  3742.     CSize m_totalDev;           // total size in device units
  3743.     CSize m_pageDev;            // per page scroll size in device units
  3744.     CSize m_lineDev;            // per line scroll size in device units
  3745.  
  3746.     BOOL m_bCenter;             // Center output if larger than total size
  3747.     BOOL m_bInsideUpdate;       // internal state for OnSize callback
  3748.     void CenterOnPoint(CPoint ptCenter);
  3749.     void ScrollToDevicePosition(POINT ptDev); // explicit scrolling no checking
  3750.  
  3751. protected:
  3752.     virtual void OnDraw(CDC* pDC) = 0;      // pass on pure virtual
  3753.  
  3754.     void UpdateBars();          // adjust scrollbars etc
  3755.     BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
  3756.         // size with no bars
  3757.     void GetScrollBarSizes(CSize& sizeSb);
  3758.     void GetScrollBarState(CSize sizeClient, CSize& needSb,
  3759.         CSize& sizeRange, CPoint& ptMove, BOOL bInsideClient);
  3760.  
  3761. public:
  3762.     virtual ~CScrollView();
  3763. #ifdef _DEBUG
  3764.     virtual void Dump(CDumpContext&) const;
  3765.     virtual void AssertValid() const;
  3766. #endif //_DEBUG
  3767.     virtual void CalcWindowRect(LPRECT lpClientRect,
  3768.         UINT nAdjustType = adjustBorder);
  3769.     virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
  3770.  
  3771.     // scrolling implementation support for OLE
  3772.     virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);
  3773.     virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
  3774.  
  3775.     //{{AFX_MSG(CScrollView)
  3776.     afx_msg void OnSize(UINT nType, int cx, int cy);
  3777.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  3778.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  3779.     afx_msg BOOL OnMouseWheel(UINT fFlags, short zDelta, CPoint point);
  3780.     //}}AFX_MSG
  3781.     DECLARE_MESSAGE_MAP()
  3782. };
  3783.  
  3784. /////////////////////////////////////////////////////////////////////////////
  3785. // CWinThread
  3786.  
  3787. typedef UINT (AFX_CDECL *AFX_THREADPROC)(LPVOID);
  3788.  
  3789. class COleMessageFilter;        // forward reference (see afxole.h)
  3790.  
  3791. class CWinThread : public CCmdTarget
  3792. {
  3793.     DECLARE_DYNAMIC(CWinThread)
  3794.  
  3795. public:
  3796. // Constructors
  3797.     CWinThread();
  3798.     BOOL CreateThread(DWORD dwCreateFlags = 0, UINT nStackSize = 0,
  3799.         LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
  3800.  
  3801. // Attributes
  3802.     CWnd* m_pMainWnd;       // main window (usually same AfxGetApp()->m_pMainWnd)
  3803.     CWnd* m_pActiveWnd;     // active main window (may not be m_pMainWnd)
  3804.     BOOL m_bAutoDelete;     // enables 'delete this' after thread termination
  3805.  
  3806.     // only valid while running
  3807.     HANDLE m_hThread;       // this thread's HANDLE
  3808.     operator HANDLE() const;
  3809.     DWORD m_nThreadID;      // this thread's ID
  3810.  
  3811.     int GetThreadPriority();
  3812.     BOOL SetThreadPriority(int nPriority);
  3813.  
  3814. // Operations
  3815.     DWORD SuspendThread();
  3816.     DWORD ResumeThread();
  3817.     BOOL PostThreadMessage(UINT message, WPARAM wParam, LPARAM lParam);
  3818.  
  3819. // Overridables
  3820.     // thread initialization
  3821.     virtual BOOL InitInstance();
  3822.  
  3823.     // running and idle processing
  3824.     virtual int Run();
  3825.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  3826.     virtual BOOL PumpMessage();     // low level message pump
  3827.     virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
  3828.     virtual BOOL IsIdleMessage(MSG* pMsg);  // checks for special messages
  3829.  
  3830.     // thread termination
  3831.     virtual int ExitInstance(); // default will 'delete this'
  3832.  
  3833.     // Advanced: exception handling
  3834.     virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
  3835.  
  3836.     // Advanced: handling messages sent to message filter hook
  3837.     virtual BOOL ProcessMessageFilter(int code, LPMSG lpMsg);
  3838.  
  3839.     // Advanced: virtual access to m_pMainWnd
  3840.     virtual CWnd* GetMainWnd();
  3841.  
  3842. // Implementation
  3843. public:
  3844.     virtual ~CWinThread();
  3845. #ifdef _DEBUG
  3846.     virtual void AssertValid() const;
  3847.     virtual void Dump(CDumpContext& dc) const;
  3848.     int m_nDisablePumpCount; // Diagnostic trap to detect illegal re-entrancy
  3849. #endif
  3850.     void CommonConstruct();
  3851.     virtual void Delete();
  3852.         // 'delete this' only if m_bAutoDelete == TRUE
  3853.  
  3854.     // message pump for Run
  3855.     MSG m_msgCur;                   // current message
  3856.  
  3857. public:
  3858.     // constructor used by implementation of AfxBeginThread
  3859.     CWinThread(AFX_THREADPROC pfnThreadProc, LPVOID pParam);
  3860.  
  3861.     // valid after construction
  3862.     LPVOID m_pThreadParams; // generic parameters passed to starting function
  3863.     AFX_THREADPROC m_pfnThreadProc;
  3864.  
  3865.     // set after OLE is initialized
  3866.     void (AFXAPI* m_lpfnOleTermOrFreeLib)(BOOL, BOOL);
  3867.     COleMessageFilter* m_pMessageFilter;
  3868.  
  3869. protected:
  3870.     CPoint m_ptCursorLast;      // last mouse position
  3871.     UINT m_nMsgLast;            // last mouse message
  3872.     BOOL DispatchThreadMessageEx(MSG* msg);  // helper
  3873.     void DispatchThreadMessage(MSG* msg);  // obsolete
  3874. };
  3875.  
  3876. // global helpers for threads
  3877.  
  3878. CWinThread* AFXAPI AfxBeginThread(AFX_THREADPROC pfnThreadProc, LPVOID pParam,
  3879.     int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
  3880.     DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
  3881. CWinThread* AFXAPI AfxBeginThread(CRuntimeClass* pThreadClass,
  3882.     int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
  3883.     DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
  3884.  
  3885. CWinThread* AFXAPI AfxGetThread();
  3886. void AFXAPI AfxEndThread(UINT nExitCode, BOOL bDelete = TRUE);
  3887.  
  3888. void AFXAPI AfxInitThread();
  3889. void AFXAPI AfxTermThread(HINSTANCE hInstTerm = NULL);
  3890.  
  3891. /////////////////////////////////////////////////////////////////////////////
  3892. // Global functions for access to the one and only CWinApp
  3893.  
  3894. #define afxCurrentWinApp    AfxGetModuleState()->m_pCurrentWinApp
  3895. #define afxCurrentInstanceHandle    AfxGetModuleState()->m_hCurrentInstanceHandle
  3896. #define afxCurrentResourceHandle    AfxGetModuleState()->m_hCurrentResourceHandle
  3897. #define afxCurrentAppName   AfxGetModuleState()->m_lpszCurrentAppName
  3898. #define afxContextIsDLL     AfxGetModuleState()->m_bDLL
  3899. #define afxRegisteredClasses    AfxGetModuleState()->m_fRegisteredClasses
  3900.  
  3901. #ifndef _AFX_NO_OCC_SUPPORT
  3902. #define afxOccManager   AfxGetModuleState()->m_pOccManager
  3903. #endif
  3904.  
  3905. // Advanced initialization: for overriding default WinMain
  3906. BOOL AFXAPI AfxWinInit(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  3907.     LPTSTR lpCmdLine, int nCmdShow);
  3908. void AFXAPI AfxWinTerm();
  3909.  
  3910. // Global Windows state data helper functions (inlines)
  3911. CWinApp* AFXAPI AfxGetApp();
  3912. CWnd* AFXAPI AfxGetMainWnd();
  3913. HINSTANCE AFXAPI AfxGetInstanceHandle();
  3914. HINSTANCE AFXAPI AfxGetResourceHandle();
  3915. void AFXAPI AfxSetResourceHandle(HINSTANCE hInstResource);
  3916. LPCTSTR AFXAPI AfxGetAppName();
  3917.  
  3918. // Use instead of PostQuitMessage in OLE server applications
  3919. void AFXAPI AfxPostQuitMessage(int nExitCode);
  3920.  
  3921. // Use AfxFindResourceHandle to find resource in chain of extension DLLs
  3922. #ifndef _AFXDLL
  3923. #define AfxFindResourceHandle(lpszResource, lpszType) AfxGetResourceHandle()
  3924. #else
  3925. HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType);
  3926. #endif
  3927.  
  3928. LONG AFXAPI AfxDelRegTreeHelper(HKEY hParentKey, const CString& strKeyName);
  3929.  
  3930. class CRecentFileList;          // forward reference (see afxpriv.h)
  3931.  
  3932. // access to message filter in CWinApp
  3933. COleMessageFilter* AFXAPI AfxOleGetMessageFilter();
  3934.  
  3935. /////////////////////////////////////////////////////////////////////////////
  3936. // CCommandLineInfo
  3937.  
  3938. class CCommandLineInfo : public CObject
  3939. {
  3940. public:
  3941.     // Sets default values
  3942.     CCommandLineInfo();
  3943.  
  3944.     //plain char* version on UNICODE for source-code backwards compatibility
  3945.     virtual void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast);
  3946. #ifdef _UNICODE
  3947.     virtual void ParseParam(const char* pszParam, BOOL bFlag, BOOL bLast);
  3948. #endif
  3949.  
  3950.     BOOL m_bShowSplash;
  3951.     BOOL m_bRunEmbedded;
  3952.     BOOL m_bRunAutomated;
  3953.     enum { FileNew, FileOpen, FilePrint, FilePrintTo, FileDDE,
  3954.         AppUnregister, FileNothing = -1 } m_nShellCommand;
  3955.  
  3956.     // not valid for FileNew
  3957.     CString m_strFileName;
  3958.  
  3959.     // valid only for FilePrintTo
  3960.     CString m_strPrinterName;
  3961.     CString m_strDriverName;
  3962.     CString m_strPortName;
  3963.  
  3964.     ~CCommandLineInfo();
  3965. // Implementation
  3966. protected:
  3967.     void ParseParamFlag(const char* pszParam);
  3968.     void ParseParamNotFlag(const TCHAR* pszParam);
  3969. #ifdef _UNICODE
  3970.     void ParseParamNotFlag(const char* pszParam);
  3971. #endif
  3972.     void ParseLast(BOOL bLast);
  3973. };
  3974.  
  3975. /////////////////////////////////////////////////////////////////////////////
  3976. // CDocManager
  3977.  
  3978. class CDocManager : public CObject
  3979. {
  3980.     DECLARE_DYNAMIC(CDocManager)
  3981. public:
  3982.  
  3983. // Constructor
  3984.     CDocManager();
  3985.  
  3986.     //Document functions
  3987.     virtual void AddDocTemplate(CDocTemplate* pTemplate);
  3988.     virtual POSITION GetFirstDocTemplatePosition() const;
  3989.     virtual CDocTemplate* GetNextDocTemplate(POSITION& pos) const;
  3990.     virtual void RegisterShellFileTypes(BOOL bCompat);
  3991.     void UnregisterShellFileTypes();
  3992.     virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); // open named file
  3993.     virtual BOOL SaveAllModified(); // save before exit
  3994.     virtual void CloseAllDocuments(BOOL bEndSession); // close documents before exiting
  3995.     virtual int GetOpenDocumentCount();
  3996.  
  3997.     // helper for standard commdlg dialogs
  3998.     virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
  3999.             DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
  4000.  
  4001. //Commands
  4002.     // Advanced: process async DDE request
  4003.     virtual BOOL OnDDECommand(LPTSTR lpszCommand);
  4004.     virtual void OnFileNew();
  4005.     virtual void OnFileOpen();
  4006.  
  4007. // Implementation
  4008. protected:
  4009.     CPtrList m_templateList;
  4010.     int GetDocumentCount(); // helper to count number of total documents
  4011.  
  4012. public:
  4013.     static CPtrList* pStaticList;       // for static CDocTemplate objects
  4014.     static BOOL bStaticInit;            // TRUE during static initialization
  4015.     static CDocManager* pStaticDocManager;  // for static CDocTemplate objects
  4016.  
  4017. public:
  4018.     virtual ~CDocManager();
  4019. #ifdef _DEBUG
  4020.     virtual void AssertValid() const;
  4021.     virtual void Dump(CDumpContext& dc) const;
  4022. #endif
  4023. };
  4024.  
  4025. /////////////////////////////////////////////////////////////////////////////
  4026. // CWinApp - the root of all Windows applications
  4027.  
  4028. #define _AFX_MRU_COUNT   4      // default support for 4 entries in file MRU
  4029. #define _AFX_MRU_MAX_COUNT 16   // currently allocated id range supports 16
  4030.  
  4031. class CWinApp : public CWinThread
  4032. {
  4033.     DECLARE_DYNAMIC(CWinApp)
  4034. public:
  4035.  
  4036. // Constructor
  4037.     CWinApp(LPCTSTR lpszAppName = NULL);     // app name defaults to EXE name
  4038.  
  4039. // Attributes
  4040.     // Startup args (do not change)
  4041.     HINSTANCE m_hInstance;
  4042.     HINSTANCE m_hPrevInstance;
  4043.     LPTSTR m_lpCmdLine;
  4044.     int m_nCmdShow;
  4045.  
  4046.     // Running args (can be changed in InitInstance)
  4047.     LPCTSTR m_pszAppName;  // human readable name
  4048.                                 //  (from constructor or AFX_IDS_APP_TITLE)
  4049.     LPCTSTR m_pszRegistryKey;   // used for registry entries
  4050.     CDocManager* m_pDocManager;
  4051.  
  4052.     // Support for Shift+F1 help mode.
  4053.     BOOL m_bHelpMode;           // are we in Shift+F1 mode?
  4054.  
  4055. public:  // set in constructor to override default
  4056.     LPCTSTR m_pszExeName;       // executable name (no spaces)
  4057.     LPCTSTR m_pszHelpFilePath;  // default based on module path
  4058.     LPCTSTR m_pszProfileName;   // default based on app name
  4059.  
  4060. // Initialization Operations - should be done in InitInstance
  4061. protected:
  4062.     void LoadStdProfileSettings(UINT nMaxMRU = _AFX_MRU_COUNT); // load MRU file list and last preview state
  4063.     void EnableShellOpen();
  4064.  
  4065. #ifndef _AFX_NO_GRAYDLG_SUPPORT
  4066.     void SetDialogBkColor(COLORREF clrCtlBk = RGB(192, 192, 192),
  4067.                 COLORREF clrCtlText = RGB(0, 0, 0));
  4068.         // set dialog box and message box background color
  4069. #endif
  4070.  
  4071.     void SetRegistryKey(LPCTSTR lpszRegistryKey);
  4072.     void SetRegistryKey(UINT nIDRegistryKey);
  4073.         // enables app settings in registry instead of INI files
  4074.         //  (registry key is usually a "company name")
  4075.  
  4076. #ifndef _AFX_NO_CTL3D_SUPPORT
  4077.     BOOL Enable3dControls(); // use CTL3D32.DLL for 3D controls in dialogs
  4078. #ifndef _AFXDLL
  4079.     BOOL Enable3dControlsStatic();  // statically link CTL3D.LIB instead
  4080. #endif
  4081. #endif
  4082.  
  4083.     void RegisterShellFileTypes(BOOL bCompat=FALSE);
  4084.         // call after all doc templates are registered
  4085.     void RegisterShellFileTypesCompat();
  4086.         // for backwards compatibility
  4087.     void UnregisterShellFileTypes();
  4088.  
  4089. // Helper Operations - usually done in InitInstance
  4090. public:
  4091.     // Cursors
  4092.     HCURSOR LoadCursor(LPCTSTR lpszResourceName) const;
  4093.     HCURSOR LoadCursor(UINT nIDResource) const;
  4094.     HCURSOR LoadStandardCursor(LPCTSTR lpszCursorName) const; // for IDC_ values
  4095.     HCURSOR LoadOEMCursor(UINT nIDCursor) const;             // for OCR_ values
  4096.  
  4097.     // Icons
  4098.     HICON LoadIcon(LPCTSTR lpszResourceName) const;
  4099.     HICON LoadIcon(UINT nIDResource) const;
  4100.     HICON LoadStandardIcon(LPCTSTR lpszIconName) const;       // for IDI_ values
  4101.     HICON LoadOEMIcon(UINT nIDIcon) const;                   // for OIC_ values
  4102.  
  4103.     // Profile settings (to the app specific .INI file, or registry)
  4104.     UINT GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault);
  4105.     BOOL WriteProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue);
  4106.     CString GetProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  4107.                 LPCTSTR lpszDefault = NULL);
  4108.     BOOL WriteProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  4109.                 LPCTSTR lpszValue);
  4110.     BOOL GetProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  4111.                 LPBYTE* ppData, UINT* pBytes);
  4112.     BOOL WriteProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  4113.                 LPBYTE pData, UINT nBytes);
  4114.  
  4115.     BOOL Unregister();
  4116.     LONG DelRegTree(HKEY hParentKey, const CString& strKeyName);
  4117.  
  4118. // Running Operations - to be done on a running application
  4119.     // Dealing with document templates
  4120.     void AddDocTemplate(CDocTemplate* pTemplate);
  4121.     POSITION GetFirstDocTemplatePosition() const;
  4122.     CDocTemplate* GetNextDocTemplate(POSITION& pos) const;
  4123.  
  4124.     // Dealing with files
  4125.     virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); // open named file
  4126.     virtual void AddToRecentFileList(LPCTSTR lpszPathName);  // add to MRU
  4127.  
  4128.     // Printer DC Setup routine, 'struct tagPD' is a PRINTDLG structure
  4129.     void SelectPrinter(HANDLE hDevNames, HANDLE hDevMode,
  4130.         BOOL bFreeOld = TRUE);
  4131.     BOOL CreatePrinterDC(CDC& dc);
  4132. #ifndef _UNICODE
  4133.     BOOL GetPrinterDeviceDefaults(struct tagPDA* pPrintDlg);
  4134. #else
  4135.     BOOL GetPrinterDeviceDefaults(struct tagPDW* pPrintDlg);
  4136. #endif
  4137.  
  4138.     // Command line parsing
  4139.     BOOL RunEmbedded();
  4140.     BOOL RunAutomated();
  4141.     void ParseCommandLine(CCommandLineInfo& rCmdInfo);
  4142.     BOOL ProcessShellCommand(CCommandLineInfo& rCmdInfo);
  4143.  
  4144. // Overridables
  4145.     // hooks for your initialization code
  4146.     virtual BOOL InitApplication();
  4147.  
  4148.     // exiting
  4149.     virtual BOOL SaveAllModified(); // save before exit
  4150.     void HideApplication();
  4151.     void CloseAllDocuments(BOOL bEndSession); // close documents before exiting
  4152.  
  4153.     // Advanced: to override message boxes and other hooks
  4154.     virtual int DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt);
  4155.     virtual void DoWaitCursor(int nCode); // 0 => restore, 1=> begin, -1=> end
  4156.  
  4157.     // Advanced: process async DDE request
  4158.     virtual BOOL OnDDECommand(LPTSTR lpszCommand);
  4159.  
  4160.     // Advanced: Help support
  4161.     virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
  4162.  
  4163. // Command Handlers
  4164. protected:
  4165.     // map to the following for file new/open
  4166.     afx_msg void OnFileNew();
  4167.     afx_msg void OnFileOpen();
  4168.  
  4169.     // map to the following to enable print setup
  4170.     afx_msg void OnFilePrintSetup();
  4171.  
  4172.     // map to the following to enable help
  4173.     afx_msg void OnContextHelp();   // shift-F1
  4174.     afx_msg void OnHelp();          // F1 (uses current context)
  4175.     afx_msg void OnHelpIndex();     // ID_HELP_INDEX
  4176.     afx_msg void OnHelpFinder();    // ID_HELP_FINDER, ID_DEFAULT_HELP
  4177.     afx_msg void OnHelpUsing();     // ID_HELP_USING
  4178.  
  4179. // Implementation
  4180. protected:
  4181.     HGLOBAL m_hDevMode;             // printer Dev Mode
  4182.     HGLOBAL m_hDevNames;            // printer Device Names
  4183.     DWORD m_dwPromptContext;        // help context override for message box
  4184.  
  4185.     int m_nWaitCursorCount;         // for wait cursor (>0 => waiting)
  4186.     HCURSOR m_hcurWaitCursorRestore; // old cursor to restore after wait cursor
  4187.  
  4188.     CRecentFileList* m_pRecentFileList;
  4189.  
  4190.     void UpdatePrinterSelection(BOOL bForceDefaults);
  4191.     void SaveStdProfileSettings();  // save options to .INI file
  4192.  
  4193. public: // public for implementation access
  4194.     CCommandLineInfo* m_pCmdInfo;
  4195.  
  4196.     ATOM m_atomApp, m_atomSystemTopic;   // for DDE open
  4197.     UINT m_nNumPreviewPages;        // number of default printed pages
  4198.  
  4199.     size_t  m_nSafetyPoolSize;      // ideal size
  4200.  
  4201.     void (AFXAPI* m_lpfnDaoTerm)();
  4202.  
  4203.     void DevModeChange(LPTSTR lpDeviceName);
  4204.     void SetCurrentHandles();
  4205.     int GetOpenDocumentCount();
  4206.  
  4207.     // helpers for standard commdlg dialogs
  4208.     BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
  4209.             DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
  4210.     int DoPrintDialog(CPrintDialog* pPD);
  4211.  
  4212.     void EnableModeless(BOOL bEnable); // to disable OLE in-place dialogs
  4213.  
  4214.     // overrides for implementation
  4215.     virtual BOOL InitInstance();
  4216.     virtual int ExitInstance(); // return app exit code
  4217.     virtual int Run();
  4218.     virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
  4219.     virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
  4220.  
  4221. public:
  4222.     virtual ~CWinApp();
  4223. #ifdef _DEBUG
  4224.     virtual void AssertValid() const;
  4225.     virtual void Dump(CDumpContext& dc) const;
  4226. #endif
  4227.  
  4228.     // helpers for registration
  4229.     HKEY GetSectionKey(LPCTSTR lpszSection);
  4230.     HKEY GetAppRegistryKey();
  4231.  
  4232. protected:
  4233.     //{{AFX_MSG(CWinApp)
  4234.     afx_msg void OnAppExit();
  4235.     afx_msg void OnUpdateRecentFileMenu(CCmdUI* pCmdUI);
  4236.     afx_msg BOOL OnOpenRecentFile(UINT nID);
  4237.     //}}AFX_MSG
  4238.     DECLARE_MESSAGE_MAP()
  4239. };
  4240.  
  4241. /////////////////////////////////////////////////////////////////////////////
  4242. // class CWaitCursor
  4243.  
  4244. class CWaitCursor
  4245. {
  4246. // Construction/Destruction
  4247. public:
  4248.     CWaitCursor();
  4249.     ~CWaitCursor();
  4250.  
  4251. // Operations
  4252. public:
  4253.     void Restore();
  4254. };
  4255.  
  4256. /////////////////////////////////////////////////////////////////////////////
  4257. // class CDocTemplate creates documents
  4258.  
  4259. #ifdef _AFXDLL
  4260. class CDocTemplate : public CCmdTarget
  4261. #else
  4262. class AFX_NOVTABLE CDocTemplate : public CCmdTarget
  4263. #endif
  4264. {
  4265.     DECLARE_DYNAMIC(CDocTemplate)
  4266.  
  4267. // Constructors
  4268. protected:
  4269.     CDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
  4270.         CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
  4271.  
  4272. public:
  4273.     virtual void LoadTemplate();
  4274.  
  4275. // Attributes
  4276. public:
  4277.     // setup for OLE containers
  4278.     void SetContainerInfo(UINT nIDOleInPlaceContainer);
  4279.  
  4280.     // setup for OLE servers
  4281.     void SetServerInfo(UINT nIDOleEmbedding, UINT nIDOleInPlaceServer = 0,
  4282.         CRuntimeClass* pOleFrameClass = NULL, CRuntimeClass* pOleViewClass = NULL);
  4283.  
  4284.     // iterating over open documents
  4285.     virtual POSITION GetFirstDocPosition() const = 0;
  4286.     virtual CDocument* GetNextDoc(POSITION& rPos) const = 0;
  4287.  
  4288. // Operations
  4289. public:
  4290.     virtual void AddDocument(CDocument* pDoc);      // must override
  4291.     virtual void RemoveDocument(CDocument* pDoc);   // must override
  4292.  
  4293.     enum DocStringIndex
  4294.     {
  4295.         windowTitle,        // default window title
  4296.         docName,            // user visible name for default document
  4297.         fileNewName,        // user visible name for FileNew
  4298.         // for file based documents:
  4299.         filterName,         // user visible name for FileOpen
  4300.         filterExt,          // user visible extension for FileOpen
  4301.         // for file based documents with Shell open support:
  4302.         regFileTypeId,      // REGEDIT visible registered file type identifier
  4303.         regFileTypeName,    // Shell visible registered file type name
  4304.     };
  4305.     virtual BOOL GetDocString(CString& rString,
  4306.         enum DocStringIndex index) const; // get one of the info strings
  4307.     CFrameWnd* CreateOleFrame(CWnd* pParentWnd, CDocument* pDoc,
  4308.         BOOL bCreateView);
  4309.  
  4310. // Overridables
  4311. public:
  4312.     enum Confidence
  4313.     {
  4314.         noAttempt,
  4315.         maybeAttemptForeign,
  4316.         maybeAttemptNative,
  4317.         yesAttemptForeign,
  4318.         yesAttemptNative,
  4319.         yesAlreadyOpen
  4320.     };
  4321.     virtual Confidence MatchDocType(LPCTSTR lpszPathName,
  4322.                     CDocument*& rpDocMatch);
  4323.     virtual CDocument* CreateNewDocument();
  4324.     virtual CFrameWnd* CreateNewFrame(CDocument* pDoc, CFrameWnd* pOther);
  4325.     virtual void InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,
  4326.         BOOL bMakeVisible = TRUE);
  4327.     virtual BOOL SaveAllModified();     // for all documents
  4328.     virtual void CloseAllDocuments(BOOL bEndSession);
  4329.     virtual CDocument* OpenDocumentFile(
  4330.         LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE) = 0;
  4331.                     // open named file
  4332.                     // if lpszPathName == NULL => create new file with this type
  4333.     virtual void SetDefaultTitle(CDocument* pDocument) = 0;
  4334.  
  4335. // Implementation
  4336. public:
  4337.     BOOL m_bAutoDelete;
  4338.     virtual ~CDocTemplate();
  4339.  
  4340.     // back pointer to OLE or other server (NULL if none or disabled)
  4341.     CObject* m_pAttachedFactory;
  4342.  
  4343.     // menu & accelerator resources for in-place container
  4344.     HMENU m_hMenuInPlace;
  4345.     HACCEL m_hAccelInPlace;
  4346.  
  4347.     // menu & accelerator resource for server editing embedding
  4348.     HMENU m_hMenuEmbedding;
  4349.     HACCEL m_hAccelEmbedding;
  4350.  
  4351.     // menu & accelerator resource for server editing in-place
  4352.     HMENU m_hMenuInPlaceServer;
  4353.     HACCEL m_hAccelInPlaceServer;
  4354.  
  4355. #ifdef _DEBUG
  4356.     virtual void Dump(CDumpContext&) const;
  4357.     virtual void AssertValid() const;
  4358. #endif
  4359.     virtual void OnIdle();             // for all documents
  4360.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  4361.         AFX_CMDHANDLERINFO* pHandlerInfo);
  4362.  
  4363. protected:
  4364.     UINT m_nIDResource;                 // IDR_ for frame/menu/accel as well
  4365.     UINT m_nIDServerResource;           // IDR_ for OLE inplace frame/menu/accel
  4366.     UINT m_nIDEmbeddingResource;        // IDR_ for OLE open frame/menu/accel
  4367.     UINT m_nIDContainerResource;        // IDR_ for container frame/menu/accel
  4368.  
  4369.     CRuntimeClass* m_pDocClass;         // class for creating new documents
  4370.     CRuntimeClass* m_pFrameClass;       // class for creating new frames
  4371.     CRuntimeClass* m_pViewClass;        // class for creating new views
  4372.     CRuntimeClass* m_pOleFrameClass;    // class for creating in-place frame
  4373.     CRuntimeClass* m_pOleViewClass;     // class for creating in-place view
  4374.  
  4375.     CString m_strDocStrings;    // '\n' separated names
  4376.         // The document names sub-strings are represented as _one_ string:
  4377.         // windowTitle\ndocName\n ... (see DocStringIndex enum)
  4378. };
  4379.  
  4380. // SDI support (1 document only)
  4381. class CSingleDocTemplate : public CDocTemplate
  4382. {
  4383.     DECLARE_DYNAMIC(CSingleDocTemplate)
  4384.  
  4385. // Constructors
  4386. public:
  4387.     CSingleDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
  4388.         CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
  4389.  
  4390. // Implementation
  4391. public:
  4392.     virtual ~CSingleDocTemplate();
  4393.     virtual void AddDocument(CDocument* pDoc);
  4394.     virtual void RemoveDocument(CDocument* pDoc);
  4395.     virtual POSITION GetFirstDocPosition() const;
  4396.     virtual CDocument* GetNextDoc(POSITION& rPos) const;
  4397.     virtual CDocument* OpenDocumentFile(
  4398.         LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE);
  4399.     virtual void SetDefaultTitle(CDocument* pDocument);
  4400.  
  4401. #ifdef _DEBUG
  4402.     virtual void Dump(CDumpContext&) const;
  4403.     virtual void AssertValid() const;
  4404. #endif //_DEBUG
  4405.  
  4406. protected:  // standard implementation
  4407.     CDocument* m_pOnlyDoc;
  4408. };
  4409.  
  4410. // MDI support (zero or more documents)
  4411. class CMultiDocTemplate : public CDocTemplate
  4412. {
  4413.     DECLARE_DYNAMIC(CMultiDocTemplate)
  4414.  
  4415. // Constructors
  4416. public:
  4417.     CMultiDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
  4418.         CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
  4419.  
  4420. // Implementation
  4421. public:
  4422.     // Menu and accel table for MDI Child windows of this type
  4423.     HMENU m_hMenuShared;
  4424.     HACCEL m_hAccelTable;
  4425.  
  4426.     virtual ~CMultiDocTemplate();
  4427.     virtual void LoadTemplate();
  4428.     virtual void AddDocument(CDocument* pDoc);
  4429.     virtual void RemoveDocument(CDocument* pDoc);
  4430.     virtual POSITION GetFirstDocPosition() const;
  4431.     virtual CDocument* GetNextDoc(POSITION& rPos) const;
  4432.     virtual CDocument* OpenDocumentFile(
  4433.         LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE);
  4434.     virtual void SetDefaultTitle(CDocument* pDocument);
  4435.  
  4436. #ifdef _DEBUG
  4437.     virtual void Dump(CDumpContext&) const;
  4438.     virtual void AssertValid() const;
  4439. #endif //_DEBUG
  4440.  
  4441. protected:  // standard implementation
  4442.     CPtrList m_docList;          // open documents of this type
  4443.     UINT m_nUntitledCount;   // start at 0, for "Document1" title
  4444. };
  4445.  
  4446. /////////////////////////////////////////////////////////////////////////////
  4447. // class CDocument is the main document data abstraction
  4448.  
  4449. #ifdef _AFXDLL
  4450. class CDocument : public CCmdTarget
  4451. #else
  4452. class AFX_NOVTABLE CDocument : public CCmdTarget
  4453. #endif
  4454. {
  4455.     DECLARE_DYNAMIC(CDocument)
  4456.  
  4457. public:
  4458. // Constructors
  4459.     CDocument();
  4460.  
  4461. // Attributes
  4462. public:
  4463.     const CString& GetTitle() const;
  4464.     virtual void SetTitle(LPCTSTR lpszTitle);
  4465.     const CString& GetPathName() const;
  4466.     virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE);
  4467.  
  4468.     CDocTemplate* GetDocTemplate() const;
  4469.     virtual BOOL IsModified();
  4470.     virtual void SetModifiedFlag(BOOL bModified = TRUE);
  4471.  
  4472. // Operations
  4473.     void AddView(CView* pView);
  4474.     void RemoveView(CView* pView);
  4475.     virtual POSITION GetFirstViewPosition() const;
  4476.     virtual CView* GetNextView(POSITION& rPosition) const;
  4477.  
  4478.     // Update Views (simple update - DAG only)
  4479.     void UpdateAllViews(CView* pSender, LPARAM lHint = 0L,
  4480.         CObject* pHint = NULL);
  4481.  
  4482. // Overridables
  4483.     // Special notifications
  4484.     virtual void OnChangedViewList(); // after Add or Remove view
  4485.     virtual void DeleteContents(); // delete doc items etc
  4486.  
  4487.     // File helpers
  4488.     virtual BOOL OnNewDocument();
  4489.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  4490.     virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
  4491.     virtual void OnCloseDocument();
  4492.     virtual void ReportSaveLoadException(LPCTSTR lpszPathName,
  4493.                 CException* e, BOOL bSaving, UINT nIDPDefault);
  4494.     virtual CFile* GetFile(LPCTSTR lpszFileName, UINT nOpenFlags,
  4495.         CFileException* pError);
  4496.     virtual void ReleaseFile(CFile* pFile, BOOL bAbort);
  4497.  
  4498.     // advanced overridables, closing down frame/doc, etc.
  4499.     virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
  4500.     virtual BOOL SaveModified(); // return TRUE if ok to continue
  4501.     virtual void PreCloseFrame(CFrameWnd* pFrame);
  4502.  
  4503. // Implementation
  4504. protected:
  4505.     // default implementation
  4506.     CString m_strTitle;
  4507.     CString m_strPathName;
  4508.     CDocTemplate* m_pDocTemplate;
  4509.     CPtrList m_viewList;                // list of views
  4510.     BOOL m_bModified;                   // changed since last saved
  4511.  
  4512. public:
  4513.     BOOL m_bAutoDelete;     // TRUE => delete document when no more views
  4514.     BOOL m_bEmbedded;       // TRUE => document is being created by OLE
  4515.  
  4516. #ifdef _DEBUG
  4517.     virtual void Dump(CDumpContext&) const;
  4518.     virtual void AssertValid() const;
  4519. #endif //_DEBUG
  4520.     virtual ~CDocument();
  4521.  
  4522.     // implementation helpers
  4523.     virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace = TRUE);
  4524.     virtual BOOL DoFileSave();
  4525.     virtual void UpdateFrameCounts();
  4526.     void DisconnectViews();
  4527.     void SendInitialUpdate();
  4528.  
  4529.     // overridables for implementation
  4530.     virtual HMENU GetDefaultMenu(); // get menu depending on state
  4531.     virtual HACCEL GetDefaultAccelerator();
  4532.     virtual void OnIdle();
  4533.     virtual void OnFinalRelease();
  4534.  
  4535.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  4536.         AFX_CMDHANDLERINFO* pHandlerInfo);
  4537.     friend class CDocTemplate;
  4538.  
  4539. protected:
  4540.     // file menu commands
  4541.     //{{AFX_MSG(CDocument)
  4542.     afx_msg void OnFileClose();
  4543.     afx_msg void OnFileSave();
  4544.     afx_msg void OnFileSaveAs();
  4545.     //}}AFX_MSG
  4546.     // mail enabling
  4547.     afx_msg void OnFileSendMail();
  4548.     afx_msg void OnUpdateFileSendMail(CCmdUI* pCmdUI);
  4549.     DECLARE_MESSAGE_MAP()
  4550. };
  4551.  
  4552. /////////////////////////////////////////////////////////////////////////////
  4553. // Extra diagnostic tracing options
  4554.  
  4555. #ifdef _DEBUG
  4556.  
  4557. extern AFX_DATA UINT afxTraceFlags;
  4558. enum AfxTraceFlags
  4559. {
  4560.     traceMultiApp = 1,      // multi-app debugging
  4561.     traceAppMsg = 2,        // main message pump trace (includes DDE)
  4562.     traceWinMsg = 4,        // Windows message tracing
  4563.     traceCmdRouting = 8,    // Windows command routing trace (set 4+8 for control notifications)
  4564.     traceOle = 16,          // special OLE callback trace
  4565.     traceDatabase = 32,     // special database trace
  4566.     traceInternet = 64      // special Internet client trace
  4567. };
  4568.  
  4569. #endif // _DEBUG
  4570.  
  4571. //////////////////////////////////////////////////////////////////////////////
  4572. // MessageBox helpers
  4573.  
  4574. void AFXAPI AfxFormatString1(CString& rString, UINT nIDS, LPCTSTR lpsz1);
  4575. void AFXAPI AfxFormatString2(CString& rString, UINT nIDS,
  4576.                 LPCTSTR lpsz1, LPCTSTR lpsz2);
  4577. int AFXAPI AfxMessageBox(LPCTSTR lpszText, UINT nType = MB_OK,
  4578.                 UINT nIDHelp = 0);
  4579. int AFXAPI AfxMessageBox(UINT nIDPrompt, UINT nType = MB_OK,
  4580.                 UINT nIDHelp = (UINT)-1);
  4581.  
  4582. // Implementation string helpers
  4583. void AFXAPI AfxFormatStrings(CString& rString, UINT nIDS,
  4584.                 LPCTSTR const* rglpsz, int nString);
  4585. void AFXAPI AfxFormatStrings(CString& rString, LPCTSTR lpszFormat,
  4586.                 LPCTSTR const* rglpsz, int nString);
  4587. BOOL AFXAPI AfxExtractSubString(CString& rString, LPCTSTR lpszFullString,
  4588.                 int iSubString, TCHAR chSep = '\n');
  4589.  
  4590. /////////////////////////////////////////////////////////////////////////////
  4591. // Special target variant APIs
  4592.  
  4593. #ifdef _AFXDLL
  4594.     #include <afxdll_.h>
  4595. #endif
  4596.  
  4597. // Windows Version compatibility (obsolete)
  4598. #define AfxEnableWin30Compatibility()
  4599. #define AfxEnableWin31Compatibility()
  4600. #define AfxEnableWin40Compatibility()
  4601.  
  4602. // Temporary map management (locks temp map on current thread)
  4603. void AFXAPI AfxLockTempMaps();
  4604. BOOL AFXAPI AfxUnlockTempMaps(BOOL bDeleteTemps = TRUE);
  4605.  
  4606. /////////////////////////////////////////////////////////////////////////////
  4607. // Special OLE related functions (see OLELOCK.CPP)
  4608.  
  4609. void AFXAPI AfxOleOnReleaseAllObjects();
  4610. BOOL AFXAPI AfxOleCanExitApp();
  4611. void AFXAPI AfxOleLockApp();
  4612. void AFXAPI AfxOleUnlockApp();
  4613.  
  4614. void AFXAPI AfxOleSetUserCtrl(BOOL bUserCtrl);
  4615. BOOL AFXAPI AfxOleGetUserCtrl();
  4616.  
  4617. #ifndef _AFX_NO_OCC_SUPPORT
  4618. BOOL AFXAPI AfxOleLockControl(REFCLSID clsid);
  4619. BOOL AFXAPI AfxOleUnlockControl(REFCLSID clsid);
  4620. BOOL AFXAPI AfxOleLockControl(LPCTSTR lpszProgID);
  4621. BOOL AFXAPI AfxOleUnlockControl(LPCTSTR lpszProgID);
  4622. void AFXAPI AfxOleUnlockAllControls();
  4623. #endif
  4624.  
  4625. /////////////////////////////////////////////////////////////////////////////
  4626. // Use version 1.0 of the RichEdit control
  4627.  
  4628. #define _RICHEDIT_VER 0x0100
  4629.  
  4630. /////////////////////////////////////////////////////////////////////////////
  4631. // Inline function declarations
  4632.  
  4633. #ifdef _AFX_PACKING
  4634. #pragma pack(pop)
  4635. #endif
  4636.  
  4637. #ifdef _AFX_ENABLE_INLINES
  4638. #define _AFXWIN_INLINE AFX_INLINE
  4639. #include <afxwin1.inl>
  4640. #include <afxwin2.inl>
  4641. #endif
  4642.  
  4643. #undef AFX_DATA
  4644. #define AFX_DATA
  4645.  
  4646. #ifdef _AFX_MINREBUILD
  4647. #pragma component(minrebuild, on)
  4648. #endif
  4649. #ifndef _AFX_FULLTYPEINFO
  4650. #pragma component(mintypeinfo, off)
  4651. #endif
  4652.  
  4653. /////////////////////////////////////////////////////////////////////////////
  4654.  
  4655. #else //RC_INVOKED
  4656. #include <afxres.h>     // standard resource IDs
  4657. #endif //RC_INVOKED
  4658.  
  4659. #endif //__AFXWIN_H__
  4660.  
  4661. /////////////////////////////////////////////////////////////////////////////
  4662.