home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / MFCINC.PAK / AFXWIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  143.6 KB  |  4,499 lines

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