home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK10 / MFC / INCLUDE / AFXWIN.H$ / afxwin
Encoding:
Text File  |  1992-03-16  |  58.2 KB  |  2,011 lines

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 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 Microsoft
  7. // QuickHelp 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. #define __AFXWIN_H__
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Classes declared in this file
  16.  
  17. class CSize;
  18. class CPoint;
  19. class CRect;
  20.  
  21. //CObject
  22.     // CException
  23.         class CResourceException; // Win resource failure exception
  24.  
  25.     class CGdiObject;             // CDC drawing tool
  26.         class CPen;               // a pen / HPEN wrapper
  27.         class CBrush;             // a brush / HBRUSH wrapper
  28.         class CFont;              // a font / HFONT wrapper
  29.         class CBitmap;            // a bitmap / HBITMAP wrapper
  30.         class CPalette;           // a palette / HPALLETE wrapper
  31.         class CRgn;               // a region / HRGN wrapper
  32.  
  33.     class CDC;                    // a Display Context / HDC wrapper
  34.         class CClientDC;          // CDC for client of window
  35.         class CWindowDC;          // CDC for entire window
  36.         class CPaintDC;           // embeddable BeginPaint struct helper
  37.  
  38.     class CMenu;                  // a menu / HMENU wrapper
  39.  
  40.     class CWnd;                   // a window / HWND wrapper
  41.         class CDialog;            // a dialog
  42.  
  43.         // controls
  44.         class CStatic;            // Static control
  45.         class CButton;            // Button control
  46.             class CBitmapButton;  // Bitmap button (self-draw)
  47.         class CListBox;           // ListBox control
  48.         class CComboBox;          // ComboBox control
  49.         class CEdit;              // Edit control
  50.         class CScrollBar;         // ScrollBar control
  51.  
  52.         // frame windows
  53.         class CFrameWnd;          // standard SDI frame
  54.             class CMDIFrameWnd;   // standard MDI frame
  55.             class CMDIChildWnd;   // standard MDI child
  56.  
  57.     class CWinApp;                // simple application base class
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Make sure 'afx.h' is included first
  61.  
  62. #ifndef __AFX_H__
  63. #ifndef _WINDOWS
  64. #define _WINDOWS
  65. #endif
  66. #include "afx.h"
  67. #else
  68. #ifndef _WINDOWS
  69.     #error Please #define _WINDOWS before including afx.h
  70. #endif
  71. #endif
  72.  
  73. // we must include certain parts of Windows.h
  74. #undef NOKERNEL
  75. #undef NOGDI
  76. #undef NOUSER
  77. #undef NOSOUND
  78. #undef NOCOMM
  79. #undef NODRIVERS
  80. #undef NOLOGERROR
  81. #undef NOPROFILER
  82. #undef NOMEMMGR
  83. #undef NOLFILEIO
  84. #undef NOOPENFILE
  85. #undef NORESOURCE
  86. #undef NOATOM
  87. #undef NOLANGUAGE
  88. #undef NOLSTRING
  89. #undef NODBCS
  90. #undef NOKEYBOARDINFO
  91. #undef NOGDICAPMASKS
  92. #undef NOCOLOR
  93. #undef NOGDIOBJ
  94. #undef NODRAWTEXT
  95. #undef NOTEXTMETRIC
  96. #undef NOSCALABLEFONT
  97. #undef NOBITMAP
  98. #undef NORASTEROPS
  99. #undef NOMETAFILE
  100. #undef NOSYSMETRICS
  101. #undef NOSYSTEMPARAMSINFO
  102. #undef NOMSG
  103. #undef NOWINSTYLES
  104. #undef NOWINOFFSETS
  105. #undef NOSHOWWINDOW
  106. #undef NODEFERWINDOWPOS
  107. #undef NOVIRTUALKEYCODES
  108. #undef NOKEYSTATES
  109. #undef NOWH
  110. #undef NOMENUS
  111. #undef NOSCROLL
  112. #undef NOCLIPBOARD
  113. #undef NOICONS
  114. #undef NOMB
  115. #undef NOSYSCOMMANDS
  116. #undef NOMDI
  117. #undef NOCTLMGR
  118. #undef NOWINMESSAGES
  119.  
  120. // The MFC library MUST be built with WINVER >= 0x030A (the default)
  121. // even when Windows 3.0 is the target.  There are no compatability
  122. // issues, rather this is done for source code maintainability.
  123.  
  124. // MFC applications may be built with WINVER == 0x300 (Win 3.0 only)
  125. // or WINVER == 0x030A (Win 3.1/3.0)
  126.  
  127. #ifdef STRICT
  128. // The default for MFC is not STRICT, since C++ and MFC
  129. // provide all of the same benefits (see TN012.TXT).  If
  130. // you wish to use STRICT typechecking, then you must rebuild
  131. // the library after removing the following #undef.
  132. #undef STRICT
  133. #endif
  134.  
  135. #include "windows.h"
  136.  
  137. #ifndef WINVER
  138.     #error Please include the correct WINDOWS.H (from \C700\INCLUDE)
  139. #endif
  140.  
  141. // Windows 3.1 Common Dialogs
  142. #include "commdlg.h"
  143.  
  144. #ifndef __AFXRES_H__
  145. #include "afxres.h"     // standard resource IDs
  146. #endif
  147.  
  148. #ifndef EXPORT
  149. #define EXPORT __export
  150. #endif
  151. #ifdef _WINDLL
  152. #define AFX_EXPORT  __loadds
  153. #else
  154. #define AFX_EXPORT  EXPORT
  155. #endif
  156.  
  157. // Type modifier for message handlers
  158. #define afx_msg         /* intentional placeholder */
  159.  
  160. /////////////////////////////////////////////////////////////////////////////
  161. // CSize - An extent, similar to Windows SIZE structure.
  162.  
  163. #if (WINVER < 0x030a)
  164. typedef struct tagSIZE
  165. {
  166.     int cx;
  167.     int cy;
  168. } SIZE;
  169. typedef SIZE*       PSIZE;
  170. typedef SIZE NEAR* NPSIZE;
  171. typedef SIZE FAR*  LPSIZE;
  172. #endif  /* WINVER < 0x030a */
  173.  
  174. class CSize : public tagSIZE
  175. {
  176. public:
  177.  
  178. // Constructors
  179.     CSize();
  180.     CSize(int initCX, int initCY);
  181.     CSize(SIZE initSize);
  182.     CSize(POINT initPt);
  183.     CSize(DWORD dwSize);
  184.  
  185. // Operations
  186.     BOOL operator==(SIZE size) const;
  187.     BOOL operator!=(SIZE size) const;
  188.     void operator+=(SIZE size);
  189.     void operator-=(SIZE size);
  190.  
  191. // Operators returning CSize values
  192.     CSize operator+(SIZE size) const;
  193.     CSize operator-(SIZE size) const;
  194. };
  195.  
  196. /////////////////////////////////////////////////////////////////////////////
  197. // CPoint - A 2-D point, similar to Windows POINT structure.
  198.  
  199. class CPoint : public tagPOINT
  200. {
  201. public:
  202.  
  203. // Constructors
  204.     CPoint();
  205.     CPoint(int initX, int initY);
  206.     CPoint(POINT initPt);
  207.     CPoint(SIZE initSize);
  208.     CPoint(DWORD dwPoint);
  209.  
  210. // Operations
  211.     void Offset(int xOffset, int yOffset);
  212.     void Offset(POINT point);
  213.     void Offset(SIZE size);
  214.     BOOL operator==(POINT point) const;
  215.     BOOL operator!=(POINT point) const;
  216.     void operator+=(SIZE size);
  217.     void operator-=(SIZE size);
  218.  
  219. // Operators returning CPoint values
  220.     CPoint operator+(SIZE size) const;
  221.     CPoint operator-(SIZE size) const;
  222.  
  223. // Operators returning CSize values
  224.     CSize operator-(POINT point) const;
  225. };
  226.  
  227. /////////////////////////////////////////////////////////////////////////////
  228. // CRect - A 2-D rectangle, similar to Windows RECT structure.
  229.  
  230. class CRect : public tagRECT
  231. {
  232. public:
  233.  
  234. // Constructors
  235.     CRect();
  236.     CRect(int l, int t, int r, int b);
  237.     CRect(const RECT& srcRect);
  238.     CRect(LPRECT lpSrcRect);
  239.     CRect(POINT point, SIZE size);
  240.  
  241. // Attributes (in addition to RECT members)
  242.     int Width() const;
  243.     int Height() const;
  244.     CSize Size() const;
  245.     CPoint& TopLeft();
  246.     CPoint& BottomRight();
  247.  
  248.     // convert between CRect and LPRECT (no need for &)
  249.     operator LPRECT();
  250.  
  251.     BOOL IsRectEmpty() const;
  252.     BOOL IsRectNull() const;
  253.     BOOL PtInRect(POINT point) const;
  254.  
  255. // Operations (from standard Windows)
  256.     void SetRect(int x1, int y1, int x2, int y2);
  257.     void SetRectEmpty();
  258.     void CopyRect(LPRECT lpSrcRect);
  259.     BOOL EqualRect(LPRECT lpRect) const;
  260.  
  261.     void InflateRect(int x, int y);
  262.     void InflateRect(SIZE size);
  263.     void OffsetRect(int x, int y);
  264.     void OffsetRect(SIZE size);
  265.     void OffsetRect(POINT point);
  266.  
  267.     // operations that fill '*this' with result
  268.     int IntersectRect(LPRECT lpRect1, LPRECT lpRect2);
  269.     int UnionRect(LPRECT lpRect1, LPRECT lpRect2);
  270. #if (WINVER >= 0x030a)
  271.     BOOL SubtractRect(LPRECT lpRectSrc1, LPRECT lpRectSrc2);
  272. #endif /* WINVER >= 0x030a */
  273.  
  274. // Additional Operations
  275.     void operator=(const RECT& srcRect);
  276.     BOOL operator==(const RECT& rect) const;
  277.     BOOL operator!=(const RECT& rect) const;
  278.     void operator+=(POINT point);
  279.     void operator-=(POINT point);
  280.     void operator&=(const RECT& rect);
  281.     void operator|=(const RECT& rect);
  282.  
  283. // Operators returning CRect values
  284.     CRect operator+(POINT point) const;
  285.     CRect operator-(POINT point) const;
  286.     CRect operator&(const RECT& rect2) const;
  287.     CRect operator|(const RECT& rect2) const;
  288. };
  289.  
  290. #ifdef _DEBUG
  291. // Diagnostic Output
  292. CDumpContext& operator<<(CDumpContext& dc, SIZE size);
  293. CDumpContext& operator<<(CDumpContext& dc, POINT point);
  294. CDumpContext& operator<<(CDumpContext& dc, const RECT& rect);
  295. #endif //_DEBUG
  296.  
  297. // Serialization
  298. CArchive& operator<<(CArchive& ar, SIZE size);
  299. CArchive& operator<<(CArchive& ar, POINT point);
  300. CArchive& operator<<(CArchive& ar, const RECT& rect);
  301. CArchive& operator>>(CArchive& ar, SIZE& size);
  302. CArchive& operator>>(CArchive& ar, POINT& point);
  303. CArchive& operator>>(CArchive& ar, RECT& rect);
  304.  
  305. /////////////////////////////////////////////////////////////////////////////
  306. // Standard exception for resource failures
  307.  
  308. class CResourceException : public CException
  309. {
  310.     DECLARE_DYNAMIC(CResourceException)
  311. public:
  312.     CResourceException();
  313. };
  314.  
  315. void AfxThrowResourceException();
  316.  
  317. /////////////////////////////////////////////////////////////////////////////
  318. // CGdiObject abstract class for CDC SelectObject
  319.  
  320. class CGdiObject : public CObject
  321. {
  322.     DECLARE_DYNAMIC(CGdiObject)
  323. public:
  324.  
  325. // Attributes
  326.     HANDLE m_hObject;
  327.     HANDLE GetSafeHandle() const;
  328.  
  329.     static CGdiObject* FromHandle(HANDLE hObject);
  330.     static void DeleteTempMap();
  331.     BOOL Attach(HANDLE hObject);
  332.     HANDLE Detach();
  333.  
  334. // Constructors
  335.     CGdiObject(); // must Create a derived class object
  336.     virtual ~CGdiObject();
  337.     BOOL DeleteObject();
  338.  
  339. // Operations
  340.     int GetObject(int nCount, void FAR* lpObject) const;
  341.     BOOL CreateStockObject(int nIndex);
  342.     BOOL UnrealizeObject();
  343.  
  344. // Implementation
  345. #ifdef _DEBUG
  346.     virtual void Dump(CDumpContext& dc) const;
  347. #endif
  348. };
  349.  
  350. /////////////////////////////////////////////////////////////////////////////
  351. // CGdiObject subclasses (drawing tools)
  352.  
  353. class CPen : public CGdiObject
  354. {
  355.     DECLARE_DYNAMIC(CPen)
  356.  
  357. public:
  358.     static CPen* FromHandle(HPEN hPen);
  359.  
  360. // Constructors
  361.     CPen();
  362.     CPen(int nPenStyle, int nWidth, DWORD crColor);
  363.     BOOL CreatePen(int nPenStyle, int nWidth, DWORD crColor);
  364.     BOOL CreatePenIndirect(LPLOGPEN lpLogPen);
  365. };
  366.  
  367. class CBrush : public CGdiObject
  368. {
  369.     DECLARE_DYNAMIC(CBrush)
  370.  
  371. public:
  372.     static CBrush* FromHandle(HBRUSH hBrush);
  373.  
  374. // Constructors
  375.     CBrush();
  376.     CBrush(DWORD crColor);             // CreateSolidBrush
  377.     CBrush(int nIndex, DWORD crColor); // CreateHatchBrush
  378.     CBrush(CBitmap* pBitmap);          // CreatePatternBrush
  379.  
  380.     BOOL CreateSolidBrush(DWORD crColor);
  381.     BOOL CreateHatchBrush(int nIndex, DWORD crColor);
  382.     BOOL CreateBrushIndirect(LPLOGBRUSH lpLogBrush);
  383.     BOOL CreatePatternBrush(CBitmap* pBitmap);
  384.     BOOL CreateDIBPatternBrush(GLOBALHANDLE hPackedDIB, UINT nUsage);
  385. };
  386.  
  387. class CFont : public CGdiObject
  388. {
  389.     DECLARE_DYNAMIC(CFont)
  390.  
  391. public:
  392.     static CFont* FromHandle(HFONT hFont);
  393.  
  394. // Constructors
  395.     CFont();
  396.     BOOL CreateFontIndirect(LPLOGFONT lpLogFont);
  397.     BOOL CreateFont(int nHeight, int nWidth, int nEscapement,
  398.               int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline,
  399.               BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
  400.               BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
  401.               LPCSTR lpFacename);
  402. };
  403.  
  404.  
  405. class CBitmap : public CGdiObject
  406. {
  407.     DECLARE_DYNAMIC(CBitmap)
  408.  
  409. public:
  410.     static CBitmap* FromHandle(HBITMAP hBitmap);
  411.  
  412. // Constructors
  413.     CBitmap();
  414.  
  415.     BOOL LoadBitmap(LPCSTR lpBitmapName);
  416.     BOOL LoadBitmap(UINT nIDBitmap);
  417.     BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_
  418.     BOOL CreateBitmap(int nWidth, int nHeight, BYTE nPlanes, BYTE nBitcount,
  419.             const void FAR* lpBits);
  420.     BOOL CreateBitmapIndirect(LPBITMAP lpBitmap);
  421.     BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight);
  422.     BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight);
  423.  
  424. // Operations
  425.     DWORD SetBitmapBits(DWORD dwCount, const void FAR* lpBits);
  426.     DWORD GetBitmapBits(DWORD dwCount, void FAR* lpBits) const;
  427.     CSize SetBitmapDimension(int nWidth, int nHeight);
  428.     CSize GetBitmapDimension() const;
  429. };
  430.  
  431. class CPalette : public CGdiObject
  432. {
  433.     DECLARE_DYNAMIC(CPalette)
  434.  
  435. public:
  436.     static CPalette* FromHandle(HPALETTE hPalette);
  437.  
  438. // Constructors
  439.     CPalette();
  440.     BOOL CreatePalette(LPLOGPALETTE lpLogPalette);
  441.  
  442. // Operations
  443.     UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  444.               LPPALETTEENTRY lpPaletteColors) const;
  445.     UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  446.               LPPALETTEENTRY lpPaletteColors);
  447.     void AnimatePalette(UINT nStartIndex, UINT nNumEntries,
  448.               LPPALETTEENTRY lpPaletteColors);
  449.     UINT GetNearestPaletteIndex(DWORD crColor) const;
  450.     BOOL ResizePalette(UINT nNumEntries);
  451. };
  452.  
  453. class CRgn : public CGdiObject
  454. {
  455.     DECLARE_DYNAMIC(CRgn)
  456.  
  457. public:
  458.     static CRgn* FromHandle(HRGN hRgn);
  459.  
  460. // Constructors
  461.     CRgn();
  462.     BOOL CreateRectRgn(int x1, int y1, int x2, int y2);
  463.     BOOL CreateRectRgnIndirect(LPRECT lpRect);
  464.     BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2);
  465.     BOOL CreateEllipticRgnIndirect(LPRECT lpRect);
  466.     BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode);
  467.     BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
  468.             int nCount, int nPolyFillMode);
  469.     BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2,
  470.             int x3, int y3);
  471.  
  472. // Operations
  473.     void SetRectRgn(int x1, int y1, int x2, int y2);
  474.     void SetRectRgn(LPRECT lpRect);
  475.     int  CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode);
  476.     int  CopyRgn(CRgn* pRgnSrc);
  477.     BOOL EqualRgn(CRgn* pRgn) const;
  478.     int  OffsetRgn(int x, int y);
  479.     int  OffsetRgn(POINT point);
  480.     int  GetRgnBox(LPRECT lpRect) const;
  481.     BOOL PtInRegion(int x, int y) const;
  482.     BOOL PtInRegion(POINT point) const;
  483.     BOOL RectInRegion(LPRECT lpRect) const;
  484. };
  485.  
  486. /////////////////////////////////////////////////////////////////////////////
  487. // The device context
  488.  
  489. class CDC : public CObject
  490. {
  491.     DECLARE_DYNAMIC(CDC)
  492. public:
  493.  
  494. // Attributes
  495.     HDC m_hDC;
  496.     HDC GetSafeHdc() const;
  497.  
  498.     static CDC* FromHandle(HDC hDC);
  499.     static void DeleteTempMap();
  500.     BOOL Attach(HDC hDC);
  501.     HDC  Detach();
  502.  
  503. // Constructors
  504.     CDC();
  505.  
  506.     BOOL CreateDC(LPCSTR lpDriverName, LPCSTR lpDeviceName,
  507.             LPCSTR lpOutput, const void FAR* lpInitData);
  508.     BOOL CreateIC(LPCSTR lpDriverName, LPCSTR lpDeviceName,
  509.             LPCSTR lpOutput, const void FAR* lpInitData);
  510.     BOOL CreateCompatibleDC(CDC* pDC);
  511.  
  512.     BOOL DeleteDC();
  513.     virtual ~CDC();
  514.  
  515. // Implementation support
  516. #ifdef _DEBUG
  517.     virtual void AssertValid() const;
  518.     virtual void Dump(CDumpContext& dc) const;
  519. #endif
  520.  
  521. protected:
  522.     static CGdiObject* SelectGdiObject(HDC hDC, HANDLE h);
  523. public:
  524.  
  525. // Device-Context Functions
  526.     CPoint GetDCOrg() const;
  527.     int SaveDC() const;
  528.     BOOL RestoreDC(int nSavedDC);
  529.     int GetDeviceCaps(int nIndex) const;
  530.  
  531. // Drawing-Tool Functions
  532.     CPoint GetBrushOrg() const;
  533.     CPoint SetBrushOrg(int x, int y);
  534.     CPoint SetBrushOrg(POINT point);
  535.     int EnumObjects(int nObjectType,
  536.                     int (FAR PASCAL EXPORT* lpfn)(LPSTR, LPSTR),
  537.                     LPSTR lpData);
  538.  
  539. // type-safe selection helpers
  540.     CGdiObject* SelectObject(CGdiObject* pObject);  // do not use for regions
  541.     CGdiObject* SelectStockObject(int nIndex);
  542.     CPen* SelectObject(CPen* pPen);
  543.     CBrush* SelectObject(CBrush* pBrush);
  544.     CFont* SelectObject(CFont* pFont);
  545.     CBitmap* SelectObject(CBitmap* pBitmap);
  546.     int SelectObject(CRgn* pRgn);       // special return for regions
  547.  
  548. // Color and Color Palette Functions
  549.     DWORD GetNearestColor(DWORD crColor) const;
  550.     CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground);
  551.     UINT RealizePalette();
  552.     void UpdateColors();
  553.  
  554. // Drawing-Attribute Functions
  555.     DWORD GetBkColor() const;
  556.     DWORD SetBkColor(DWORD crColor);
  557.     int GetBkMode() const;
  558.     int SetBkMode(int nBkMode);
  559.     int GetPolyFillMode() const;
  560.     int SetPolyFillMode(int nPolyFillMode);
  561.     int GetROP2() const;
  562.     int SetROP2(int nDrawMode);
  563.     int GetStretchBltMode() const;
  564.     int SetStretchBltMode(int nStretchMode);
  565.     DWORD GetTextColor() const;
  566.     DWORD SetTextColor(DWORD crColor);
  567.  
  568. // Mapping Functions
  569.     int GetMapMode() const;
  570.     int SetMapMode(int nMapMode);
  571.     // Viewport Origin
  572.     CPoint GetViewportOrg() const;
  573.     CPoint SetViewportOrg(int x, int y);
  574.     CPoint SetViewportOrg(POINT point);
  575.     CPoint OffsetViewportOrg(int nWidth, int nHeight);
  576.  
  577.     // Viewport Extent
  578.     CSize GetViewportExt() const;
  579.     CSize SetViewportExt(int x, int y);
  580.     CSize SetViewportExt(SIZE size);
  581.     CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
  582.  
  583.     // Window Origin
  584.     CPoint GetWindowOrg() const;
  585.     CPoint SetWindowOrg(int x, int y);
  586.     CPoint SetWindowOrg(POINT point);
  587.     CPoint OffsetWindowOrg(int nWidth, int nHeight);
  588.  
  589.     // Window extent
  590.     CSize GetWindowExt() const;
  591.     CSize SetWindowExt(int x, int y);
  592.     CSize SetWindowExt(SIZE size);
  593.     CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
  594.  
  595. // Coordinate Functions
  596.     void DPtoLP(LPPOINT lpPoints, int nCount = 1) const;
  597.     void DPtoLP(LPRECT lpRect) const;
  598.     void LPtoDP(LPPOINT lpPoints, int nCount = 1) const;
  599.     void LPtoDP(LPRECT lpRect) const;
  600.  
  601. // Region Functions
  602.     BOOL FillRgn(CRgn* pRgn, CBrush* pBrush);
  603.     BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight);
  604.     BOOL InvertRgn(CRgn* pRgn);
  605.     BOOL PaintRgn(CRgn* pRgn);
  606.  
  607. // Clipping Functions
  608.     int GetClipBox(LPRECT lpRect) const;
  609.     int SelectClipRgn(CRgn* pRgn);
  610.     int ExcludeClipRect(int x1, int y1, int x2, int y2);
  611.     int ExcludeClipRect(LPRECT lpRect);
  612.     int ExcludeUpdateRgn(CWnd* pWnd);
  613.     int IntersectClipRect(int x1, int y1, int x2, int y2);
  614.     int IntersectClipRect(LPRECT lpRect);
  615.     int OffsetClipRgn(int x, int y);
  616.     int OffsetClipRgn(SIZE size);
  617.     BOOL PtVisible(int x, int y) const;
  618.     BOOL PtVisible(POINT point) const;
  619.     BOOL RectVisible(LPRECT lpRect) const;
  620.  
  621. // Line-Output Functions
  622.     CPoint GetCurrentPosition() const;
  623.     CPoint MoveTo(int x, int y);
  624.     CPoint MoveTo(POINT point);
  625.     BOOL LineTo(int x, int y);
  626.     BOOL LineTo(POINT point);
  627.     BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  628.     BOOL Arc(LPRECT lpRect, POINT ptStart, POINT ptEnd);
  629.     BOOL Polyline(LPPOINT lpPoints, int nCount);
  630.  
  631. // Simple Drawing Functions
  632.     void FillRect(LPRECT lpRect, CBrush* pBrush);
  633.     void FrameRect(LPRECT lpRect, CBrush* pBrush);
  634.     void InvertRect(LPRECT lpRect);
  635.     BOOL DrawIcon(int x, int y, HICON hIcon);
  636.     BOOL DrawIcon(POINT point, HICON hIcon);
  637.  
  638. // Ellipse and Polygon Functions
  639.     BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3,
  640.                int x4, int y4);
  641.     BOOL Chord(LPRECT lpRect, POINT ptStart, POINT ptEnd);
  642.     void DrawFocusRect(LPRECT lpRect);
  643.     BOOL Ellipse(int x1, int y1, int x2, int y2);
  644.     BOOL Ellipse(LPRECT lpRect);
  645.     BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  646.     BOOL Pie(LPRECT lpRect, POINT ptStart, POINT ptEnd);
  647.     BOOL Polygon(LPPOINT lpPoints, int nCount);
  648.     BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount);
  649.     BOOL Rectangle(int x1, int y1, int x2, int y2);
  650.     BOOL Rectangle(LPRECT lpRect);
  651.     BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
  652.     BOOL RoundRect(LPRECT lpRect, POINT point);
  653.  
  654. // Bitmap Function
  655.     BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop);
  656.     BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  657.                 int xSrc, int ySrc, DWORD dwRop);
  658.     BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  659.             int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop);
  660.     DWORD GetPixel(int x, int y) const;
  661.     DWORD GetPixel(POINT point) const;
  662.     DWORD SetPixel(int x, int y, DWORD crColor);
  663.     DWORD SetPixel(POINT point, DWORD crColor);
  664.     BOOL FloodFill(int x, int y, DWORD crColor);
  665.     BOOL ExtFloodFill(int x, int y, DWORD crColor, UINT nFillType);
  666.  
  667. // Text Functions
  668.     BOOL TextOut(int x, int y, const CString& str);
  669.     BOOL TextOut(int x, int y, LPCSTR lpString, int nCount);
  670.     BOOL ExtTextOut(int x, int y, UINT nOptions, LPRECT lpRect,
  671.             LPCSTR lpString, UINT nCount, LPINT lpDxWidths);
  672.     CSize TabbedTextOut(int x, int y, LPCSTR lpString, int nCount,
  673.             int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
  674.     int DrawText(LPCSTR lpString, int nCount, LPRECT lpRect,
  675.                     UINT nFormat);
  676.     CSize GetTextExtent(LPCSTR lpString, int nCount) const;
  677.     CSize GetTabbedTextExtent(LPCSTR lpString, int nCount,
  678.             int nTabPositions, LPINT lpnTabStopPositions) const;
  679.     BOOL GrayString(CBrush* pBrush,
  680.                 BOOL (FAR PASCAL EXPORT* lpfnOutput)(HDC, DWORD, int),
  681.                     DWORD lpData, int nCount,
  682.                     int x, int y, int nWidth, int nHeight);
  683.     UINT GetTextAlign() const;
  684.     UINT SetTextAlign(UINT nFlags);
  685.     int GetTextFace(int nCount, LPSTR lpFacename) const;
  686.     BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const;
  687.     int SetTextJustification(int nBreakExtra, int nBreakCount);
  688.     int GetTextCharacterExtra() const;
  689.     int SetTextCharacterExtra(int nCharExtra);
  690.  
  691. // Font Functions
  692.     BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
  693.     DWORD SetMapperFlags(DWORD dwFlag);
  694.     CSize GetAspectRatioFilter() const;
  695.  
  696. // Printer Escape Functions
  697.     int Escape(int nEscape, int nCount, LPCSTR lpInData, void FAR* lpOutData);
  698.  
  699.     // Escape helpers
  700.     int StartDoc(LPCSTR pDocName); 
  701.                 // Windows 3.1 use StartDoc(LPDOCINFO lpDocInfo)
  702.     int StartPage();
  703.     int EndPage();
  704.     int SetAbortProc(BOOL (FAR PASCAL EXPORT* lpfn)(HDC, int));
  705.     int AbortDoc();
  706.     int EndDoc();
  707.  
  708. // Scrolling Functions
  709.     BOOL ScrollDC(int dx, int dy, LPRECT lpRectScroll, LPRECT lpRectClip,
  710.                     CRgn* pRgnUpdate, LPRECT lpRectUpdate);
  711.  
  712. // MetaFile Functions
  713.     BOOL PlayMetaFile(HANDLE hMF);
  714.  
  715. // Windows 3.1 Specific GDI functions
  716. #if (WINVER >= 0x030a)
  717.     BOOL QueryAbort() const;
  718.     UINT SetBoundsRect(const RECT FAR* lpRectBounds, UINT flags);
  719.     UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags);
  720.     int StartDoc(LPDOCINFO lpDocInfo);
  721.     BOOL GetCharABCWidths(UINT nFirst, UINT nLast, LPABC lpabc) const;
  722.     DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const;
  723.     int GetKerningPairs(int nPairs, KERNINGPAIR FAR* lpkrnpair) const;
  724.     UINT GetOutlineTextMetrics(UINT cbData, OUTLINETEXTMETRIC FAR* lpotm) const;
  725.     DWORD GetGlyphOutline(UINT nChar, UINT nFormat, GLYPHMETRICS FAR* lpgm, 
  726.         DWORD cbBuffer, void FAR* lpBuffer, const MAT2 FAR* lpmat2) const;
  727. #endif
  728.  
  729. };
  730.  
  731. /////////////////////////////////////////////////////////////////////////////
  732. // CDC Helpers
  733.  
  734. class CClientDC : public CDC
  735. {
  736.     DECLARE_DYNAMIC(CClientDC)
  737.  
  738. // Constructors
  739. public:
  740.     CClientDC(CWnd* pWnd);
  741.  
  742. // Attributes
  743. protected:
  744.     HWND m_hWnd;
  745.  
  746. // Implementation
  747. public:
  748.     virtual ~CClientDC();
  749. #ifdef _DEBUG
  750.     virtual void AssertValid() const;
  751.     virtual void Dump(CDumpContext& dc) const;
  752. #endif
  753. };
  754.  
  755. class CWindowDC : public CDC
  756. {
  757.     DECLARE_DYNAMIC(CWindowDC)
  758.  
  759. // Constructors
  760. public:
  761.  
  762.     CWindowDC(CWnd* pWnd);
  763.  
  764. // Attributes
  765. protected:
  766.     HWND m_hWnd;
  767.  
  768. // Implementation
  769. public:
  770.     virtual ~CWindowDC();
  771. #ifdef _DEBUG
  772.     virtual void AssertValid() const;
  773.     virtual void Dump(CDumpContext& dc) const;
  774. #endif
  775. };
  776.  
  777. class CPaintDC : public CDC
  778. {
  779.     DECLARE_DYNAMIC(CPaintDC)
  780.  
  781. // Constructors
  782. public:
  783.     CPaintDC(CWnd* pWnd);   // BeginPaint
  784.  
  785. // Attributes
  786. protected:
  787.     HWND m_hWnd;
  788. public:
  789.     PAINTSTRUCT m_ps;       // actual paint struct !
  790.  
  791. // Implementation
  792.     virtual ~CPaintDC();
  793. #ifdef _DEBUG
  794.     virtual void AssertValid() const;
  795.     virtual void Dump(CDumpContext& dc) const;
  796. #endif
  797. };
  798.  
  799. class CMetaFileDC : public CDC
  800. {
  801.     DECLARE_DYNAMIC(CMetaFileDC)
  802.  
  803. // Constructors
  804. public:
  805.     CMetaFileDC();
  806.     BOOL Create(LPCSTR lpFilename = NULL);
  807.  
  808.     // Special close
  809.     HANDLE  Close();
  810.  
  811. // Operations : selecting in a MetaFile DC returns a BOOL, not old object
  812.     BOOL SelectObject(CGdiObject* pObject);
  813.     BOOL SelectStockObject(int nIndex);
  814. };
  815.  
  816.  
  817. /////////////////////////////////////////////////////////////////////////////
  818. // CMenu
  819.  
  820. class CMenu : public CObject
  821. {
  822.     DECLARE_DYNAMIC(CMenu)
  823. public:
  824.  
  825. // Constructors
  826.     CMenu();
  827.  
  828.     BOOL CreateMenu();
  829.     BOOL CreatePopupMenu();
  830.     BOOL LoadMenu(LPCSTR lpMenuName);
  831.     BOOL LoadMenu(UINT nIDMenu);
  832.     BOOL LoadMenuIndirect(const void FAR* lpMenuTemplate);
  833.     BOOL DestroyMenu();
  834.  
  835. // Attributes
  836.     HMENU m_hMenu;
  837.     HMENU GetSafeHmenu() const;
  838.  
  839.     static CMenu* FromHandle(HMENU hMenu);
  840.     static void DeleteTempMap();
  841.     BOOL Attach(HMENU hMenu);
  842.     HMENU Detach();
  843.  
  844. // CMenu Operations
  845.     BOOL DeleteMenu(UINT nPosition, UINT nFlags);
  846.     BOOL TrackPopupMenu(UINT nFlags, int x, int y,
  847.                         const CWnd* pWnd, const RECT FAR* lpRect = 0);
  848.  
  849. // CMenuItem Operations
  850.     BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0,
  851.                     LPCSTR lpNewItem = NULL);
  852.     BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp);
  853.     UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck);
  854.     UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable);
  855.     UINT GetMenuItemCount() const;
  856.     UINT GetMenuItemID(int nPos) const;
  857.     UINT GetMenuState(UINT nID, UINT nFlags) const;
  858.     int GetMenuString(UINT nIDItem, LPSTR lpString, int nMaxCount,
  859.                     UINT nFlags) const;
  860.     CMenu* GetSubMenu(int nPos) const;
  861.     BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
  862.                     LPCSTR lpNewItem = NULL);
  863.     BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
  864.                     const CBitmap* pBmp);
  865.     BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
  866.                     LPCSTR lpNewItem = NULL);
  867.     BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
  868.                     const CBitmap* pBmp);
  869.     BOOL RemoveMenu(UINT nPosition, UINT nFlags);
  870.     BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags,
  871.                     const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked);
  872.  
  873. // Overridables (must override draw and measure for owner-draw menu items)
  874.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  875.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  876.  
  877. // Implementation
  878. #ifdef _DEBUG
  879.     virtual void AssertValid() const;
  880.     virtual void Dump(CDumpContext& dc) const;
  881. #endif
  882.  
  883.     virtual ~CMenu();
  884. };
  885.  
  886. /////////////////////////////////////////////////////////////////////////////
  887. // Window wrapping message map
  888.  
  889. struct CMessageEntry;       // declared below after CWnd
  890. struct NEAR CMessageMap
  891. {
  892.     CMessageMap*        pBaseMessageMap;
  893.     CMessageEntry FAR*  lpEntries;
  894. };
  895.  
  896. #define DECLARE_MESSAGE_MAP() \
  897. private: \
  898.     static CMessageEntry BASED_CODE _messageEntries[]; \
  899. protected: \
  900.     static CMessageMap messageMap; \
  901.     virtual CMessageMap* GetMessageMap() const;
  902.  
  903. #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
  904.     CMessageMap* theClass::GetMessageMap() const \
  905.         { return &theClass::messageMap; } \
  906.     CMessageMap theClass::messageMap = \
  907.     { &(baseClass::messageMap), \
  908.         (CMessageEntry FAR*) &(theClass::_messageEntries) }; \
  909.     CMessageEntry BASED_CODE theClass::_messageEntries[] = \
  910.     {
  911.  
  912. #define END_MESSAGE_MAP() \
  913.     { 0, 0, AfxSig_end, (AFX_PMSG)0 } \
  914.     };
  915.  
  916. // Message map signature values and macros in separate header
  917. #include "afxmsg.h"
  918.  
  919. /////////////////////////////////////////////////////////////////////////////
  920.  
  921.  
  922. /////////////////////////////////////////////////////////////////////////////
  923. // CWnd - a Microsoft Windows application window
  924.  
  925. class CWnd : public CObject
  926. {
  927.     DECLARE_DYNAMIC(CWnd)
  928. protected:
  929.     static const MSG* GetCurrentMessage();
  930.  
  931. // Attributes
  932. public:
  933.     HWND m_hWnd;
  934.  
  935.     HWND GetSafeHwnd() const;
  936.     DWORD GetStyle() const;
  937.     DWORD GetExStyle() const;
  938.  
  939. // Constructors and other creation
  940.     CWnd();
  941.  
  942.     static CWnd* FromHandle(HWND hWnd);
  943.     static CWnd* FromHandlePermanent(HWND hWnd);    // INTERNAL USE
  944.     static void DeleteTempMap();
  945.     BOOL Attach(HWND hWndNew);
  946.     HWND Detach();
  947.     BOOL SubclassWindow(HWND hWnd);
  948.     BOOL SubclassDlgItem(UINT nID, CWnd* pParent);
  949.             // for dynamic subclassing of windows control
  950.  
  951. protected: // This CreateEx() wraps CreateWindowEx
  952.     BOOL CreateEx(DWORD dwExStyle, LPCSTR lpClassName,
  953.         LPCSTR lpWindowName, DWORD dwStyle,
  954.         int x, int y, int nWidth, int nHeight,
  955.         HWND hwndParent, HMENU nIDorHMenu);
  956.  
  957. private:
  958.     CWnd(HWND hWnd);    // just for special initialization
  959.  
  960. public:
  961.     // for child windows...
  962.     BOOL Create(LPCSTR lpClassName,
  963.         LPCSTR lpWindowName, DWORD dwStyle,
  964.         const RECT& rect,
  965.         const CWnd* pParentWnd, UINT nID);
  966.  
  967.     virtual BOOL DestroyWindow();
  968.  
  969.  
  970. // Message Functions
  971.     LONG SendMessage(UINT message, UINT wParam = 0, LONG lParam = 0);
  972.     BOOL PostMessage(UINT message, UINT wParam = 0, LONG lParam = 0);
  973.  
  974. // Window Text Functions
  975.     void SetWindowText(LPCSTR lpString);
  976.     int GetWindowText(LPSTR lpString, int nMaxCount) const;
  977.     int GetWindowTextLength() const;
  978.     void GetWindowText(CString& rString) const;
  979.     void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
  980.     CFont* GetFont();
  981.  
  982. // CMenu Functions - non-Child windows only
  983.     CMenu* GetMenu() const;
  984.     BOOL SetMenu(CMenu* pMenu);
  985.     void DrawMenuBar();
  986.     CMenu* GetSystemMenu(BOOL bRevert) const;
  987.     BOOL HiliteMenuItem(CMenu* pMenu, UINT nIDHiliteItem, UINT nHilite);
  988.  
  989. // Special attributes for Child windows only
  990.     int GetDlgCtrlID() const;
  991.  
  992. // Window Size and Position Functions
  993.     void CloseWindow();
  994.     BOOL OpenIcon();
  995.     BOOL IsIconic() const;
  996.     BOOL IsZoomed() const;
  997.     void MoveWindow(int x, int y, int nWidth, int nHeight,
  998.                 BOOL bRepaint = TRUE);
  999.     void MoveWindow(LPRECT lpRect, BOOL bRepaint = TRUE);
  1000.  
  1001.     static const CWnd NEAR wndTop; // SetWindowPos's pWndInsertAfter
  1002.     static const CWnd NEAR wndBottom; // SetWindowPos's pWndInsertAfter
  1003. #if (WINVER >= 0x030a)
  1004.     static const CWnd NEAR wndTopMost; // SetWindowPos's pWndInsertAfter (3.1)
  1005.     static const CWnd NEAR wndNoTopMost; // SetWindowPos's pWndInsertAfter (3.1)
  1006. #endif /* WINVER >= 0x030a */ 
  1007.  
  1008.     BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
  1009.                 int cx, int cy, UINT nFlags);
  1010.     UINT ArrangeIconicWindows();
  1011.     void BringWindowToTop();
  1012.     void GetWindowRect(LPRECT lpRect) const;
  1013.     void GetClientRect(LPRECT lpRect) const;
  1014.  
  1015. #if (WINVER >= 0x030a)
  1016.     BOOL GetWindowPlacement(WINDOWPLACEMENT FAR* lpwndpl) const;
  1017.     BOOL SetWindowPlacement(const WINDOWPLACEMENT FAR* lpwndpl);
  1018. #endif  /* WINVER >= 0x030a */
  1019.  
  1020. // Coordinate Mapping Functions
  1021.     void ClientToScreen(LPPOINT lpPoint) const;
  1022.     void ClientToScreen(LPRECT lpRect) const;
  1023.     void ScreenToClient(LPPOINT lpPoint) const;
  1024.     void ScreenToClient(LPRECT lpRect) const;
  1025. #if (WINVER >= 0x030a)
  1026.     void MapWindowPoints(CWnd* pwndTo, LPPOINT lpPoint, UINT nCount) const;
  1027.     void MapWindowPoints(CWnd* pwndTo, LPRECT lpRect) const;
  1028. #endif  /* WINVER >= 0x030a */
  1029.  
  1030. // Update/Painting Functions
  1031.     CDC* BeginPaint(LPPAINTSTRUCT lpPaint);
  1032.     void EndPaint(LPPAINTSTRUCT lpPaint);
  1033.     CDC* GetDC();
  1034.     CDC* GetWindowDC();
  1035.     int ReleaseDC(CDC* pDC);
  1036.  
  1037.     void UpdateWindow();
  1038.     void SetRedraw(BOOL bRedraw = TRUE);
  1039.     BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE);
  1040.     int GetUpdateRgn(CRgn* pRgn, BOOL bErase = FALSE);
  1041.     void Invalidate(BOOL bErase = TRUE);
  1042.     void InvalidateRect(LPRECT lpRect, BOOL bErase = TRUE);
  1043.     void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
  1044.     void ValidateRect(LPRECT lpRect);
  1045.     void ValidateRgn(CRgn* pRgn);
  1046.     BOOL ShowWindow(int nCmdShow);
  1047.     BOOL IsWindowVisible() const;
  1048.     void ShowOwnedPopups(BOOL bShow = TRUE);
  1049.  
  1050. #if (WINVER >= 0x030a)
  1051.     CDC* GetDCEx(CRgn* prgnClip, DWORD flags);
  1052.     BOOL LockWindowUpdate();
  1053.     BOOL RedrawWindow(const RECT FAR* lpRectUpdate = NULL, 
  1054.         CRgn* prgnUpdate = NULL, 
  1055.         UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
  1056.     BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH);
  1057. #endif  /* WINVER >= 0x030a */
  1058.  
  1059. // Timer Functions
  1060.     UINT SetTimer(int nIDEvent, UINT nElapse,
  1061.                     UINT (FAR PASCAL EXPORT* lpfnTimer)(HWND, UINT, int, DWORD));
  1062.     BOOL KillTimer(int nIDEvent);
  1063.  
  1064. // Window State Functions
  1065.     BOOL IsWindowEnabled() const;
  1066.     BOOL EnableWindow(BOOL bEnable = TRUE);
  1067.  
  1068.     static CWnd* GetActiveWindow();
  1069.     CWnd* SetActiveWindow();
  1070.  
  1071.     static CWnd* GetCapture();
  1072.     CWnd* SetCapture();
  1073.     static CWnd* GetFocus();
  1074.     CWnd* SetFocus();
  1075.  
  1076.     CWnd* SetSysModalWindow();
  1077.     static CWnd* GetSysModalWindow();
  1078.  
  1079.     static CWnd* GetDesktopWindow();
  1080.  
  1081. // Dialog-Box Item Functions
  1082. // (NOTE: Dialog-Box Items are not necessarily in dialog boxes!)
  1083.     void CheckDlgButton(int nIDButton, UINT nCheck);
  1084.     void CheckRadioButton(int nIDFirstButton, int nIDLastButton,
  1085.                     int nIDCheckButton);
  1086.     int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton);
  1087.     int DlgDirList(LPSTR lpPathSpec, int nIDListBox,
  1088.                     int nIDStaticPath, UINT nFileType);
  1089.     int DlgDirListComboBox(LPSTR lpPathSpec, int nIDComboBox,
  1090.                     int nIDStaticPath, UINT nFileType);
  1091.     BOOL DlgDirSelect(LPSTR lpString, int nIDListBox);
  1092.     BOOL DlgDirSelectComboBox(LPSTR lpString, int nIDComboBox);
  1093.  
  1094.     CWnd* GetDlgItem(int nID) const;
  1095.     UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL,
  1096.                     BOOL bSigned = TRUE) const;
  1097.     int GetDlgItemText(int nID, LPSTR lpStr, int nMaxCount) const;
  1098.  
  1099.     CWnd* GetNextDlgGroupItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
  1100.  
  1101.     CWnd* GetNextDlgTabItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
  1102.     UINT IsDlgButtonChecked(int nIDButton) const;
  1103.     LONG SendDlgItemMessage(int nID, UINT message,
  1104.                     UINT wParam = 0, LONG lParam = 0);
  1105.     void SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE);
  1106.     void SetDlgItemText(int nID, LPCSTR lpString);
  1107.  
  1108. // Scrolling Functions
  1109.     int GetScrollPos(int nBar) const;
  1110.     void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const;
  1111.     void ScrollWindow(int xAmount, int yAmount,
  1112.                     const RECT FAR* lpRect = NULL,
  1113.                     const RECT FAR* lpClipRect = NULL);
  1114.     int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
  1115.     void SetScrollRange(int nBar, int nMinPos, int nMaxPos,
  1116.               BOOL bRedraw = TRUE);
  1117.     void ShowScrollBar(UINT nBar, BOOL bShow = TRUE);
  1118. #if (WINVER >= 0x030a)
  1119.     int ScrollWindowEx(int dx, int dy,
  1120.                 const RECT FAR* lpRectScroll, const RECT FAR* lpRectClip,
  1121.                 CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags);
  1122. #endif  /* WINVER >= 0x030a */
  1123.  
  1124. // Window Access Functions
  1125.     CWnd* ChildWindowFromPoint(POINT point) const;
  1126.     static CWnd* FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName);
  1127.     CWnd* GetNextWindow(UINT nFlag = GW_HWNDNEXT) const;
  1128.     CWnd* GetTopWindow() const;
  1129.  
  1130.     CWnd* GetWindow(UINT nCmd) const;
  1131.     CWnd* GetLastActivePopup() const;
  1132.  
  1133.     BOOL IsChild(CWnd* pWnd) const;
  1134.     CWnd* GetParent() const;
  1135.     CWnd* SetParent(CWnd* pWndNewParent);
  1136.     static CWnd* WindowFromPoint(POINT point);
  1137.  
  1138. // Alert Functions
  1139.     BOOL FlashWindow(BOOL bInvert);
  1140.     int MessageBox(LPCSTR lpText, LPCSTR lpCaption = NULL,
  1141.               UINT nType = MB_OK);
  1142.  
  1143. // Clipboard Functions
  1144.     BOOL ChangeClipboardChain(HWND hWndNext);
  1145.     HWND SetClipboardViewer();
  1146.     BOOL OpenClipboard();
  1147.     static CWnd* GetClipboardOwner();
  1148.     static CWnd* GetClipboardViewer();
  1149. #if (WINVER >= 0x030a)
  1150.     static CWnd* GetOpenClipboardWindow();
  1151. #endif /* WINVER >= 0x030a */
  1152.  
  1153. // Caret Functions
  1154.     void CreateCaret(CBitmap* pBitmap);
  1155.     void CreateSolidCaret(int nWidth, int nHeight);
  1156.     void CreateGrayCaret(int nWidth, int nHeight);
  1157.     static CPoint GetCaretPos();
  1158.     static void SetCaretPos(POINT point);
  1159.     void HideCaret();
  1160.     void ShowCaret();
  1161.  
  1162. // Window-Management message handler member functions
  1163. protected:
  1164.     virtual BOOL OnCommand(UINT wParam, LONG lParam);
  1165.  
  1166.     afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
  1167.     afx_msg void OnActivateApp(BOOL bActive, HANDLE hTask);
  1168.     afx_msg void OnCancelMode();
  1169.     afx_msg void OnChildActivate();
  1170.     afx_msg void OnClose();
  1171.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  1172.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  1173.     afx_msg void OnDestroy();
  1174.     afx_msg void OnEnable(BOOL bEnable);
  1175.     afx_msg void OnEndSession(BOOL bEnding);
  1176.     afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
  1177.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  1178.     afx_msg void OnGetMinMaxInfo(LPPOINT lpPoints);
  1179.     afx_msg void OnIconEraseBkgnd(CDC* pDC);
  1180.     afx_msg void OnKillFocus(CWnd* pNewWnd);
  1181.     afx_msg LONG OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
  1182.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  1183.     afx_msg void OnMove(int x, int y);
  1184.     afx_msg void OnPaint();
  1185.     afx_msg void OnParentNotify(UINT message, LONG lParam);
  1186.     afx_msg HCURSOR OnQueryDragIcon();
  1187.     afx_msg BOOL OnQueryEndSession();
  1188.     afx_msg BOOL OnQueryNewPalette();
  1189.     afx_msg BOOL OnQueryOpen();
  1190.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  1191.     afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  1192.     afx_msg void OnSize(UINT nType, int cx, int cy);
  1193. #if (WINVER >= 0x030a)
  1194.     afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
  1195.     afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
  1196. #endif /* WINVER >= 0x030a */
  1197.  
  1198. // Nonclient-Area message handler member functions
  1199.     afx_msg BOOL OnNcActivate(BOOL bActive);
  1200.     afx_msg void OnNcCalcSize(NCCALCSIZE_PARAMS FAR* lpncsp);
  1201.     afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
  1202.     afx_msg void OnNcDestroy();
  1203.     afx_msg UINT OnNcHitTest(CPoint point);
  1204.     afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  1205.     afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  1206.     afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  1207.     afx_msg void OnNcMButtonDblClk(UINT nHitTest, CPoint point);
  1208.     afx_msg void OnNcMButtonDown(UINT nHitTest, CPoint point);
  1209.     afx_msg void OnNcMButtonUp(UINT nHitTest, CPoint point);
  1210.     afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
  1211.     afx_msg void OnNcPaint();
  1212.     afx_msg void OnNcRButtonDblClk(UINT nHitTest, CPoint point);
  1213.     afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
  1214.     afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
  1215.  
  1216. // System message handler member functions
  1217. #if (WINVER >= 0x030a)
  1218.     afx_msg void OnDropFiles(HANDLE hDropInfo);
  1219.     afx_msg void OnPaletteIsChanging(CWnd* pRealizeWnd);
  1220. #endif /* WINVER >= 0x030a */
  1221.     afx_msg void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  1222.     afx_msg void OnSysCommand(UINT nID, LONG lParam);
  1223.     afx_msg void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  1224.     afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  1225.     afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  1226.     afx_msg void OnCompacting(UINT nCpuTime);
  1227.     afx_msg void OnDevModeChange(LPSTR lpDeviceName);
  1228.     afx_msg void OnFontChange();
  1229.     afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  1230.     afx_msg void OnSpoolerStatus(UINT nStatus, UINT nJobs);
  1231.     afx_msg void OnSysColorChange();
  1232.     afx_msg void OnTimeChange();
  1233.     afx_msg void OnWinIniChange(LPSTR lpSection);
  1234.  
  1235. // Input message handler member functions
  1236.     afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  1237.     afx_msg void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  1238.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  1239.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  1240.     afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  1241.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  1242.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  1243.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  1244.     afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
  1245.     afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  1246.     afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  1247.     afx_msg int OnMouseActivate(CWnd* pFrameWnd, UINT nHitTest, UINT message);
  1248.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  1249.     afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  1250.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  1251.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  1252.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  1253.     afx_msg void OnTimer(UINT nIDEvent);
  1254.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  1255.  
  1256. // Initialization message handler member functions
  1257.     afx_msg void OnInitMenu(CMenu* pMenu);
  1258.     afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
  1259.  
  1260. // Clipboard message handler member functions
  1261.     afx_msg void OnAskCbFormatName(UINT nMaxCount, LPSTR lpString);
  1262.     afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
  1263.     afx_msg void OnDestroyClipboard();
  1264.     afx_msg void OnDrawClipboard();
  1265.     afx_msg void OnHScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
  1266.     afx_msg void OnPaintClipboard(CWnd* pClipAppWnd, HANDLE hPaintStruct);
  1267.     afx_msg void OnRenderAllFormats();
  1268.     afx_msg void OnRenderFormat(UINT nFormat);
  1269.     afx_msg void OnSizeClipboard(CWnd* pClipAppWnd, HANDLE hRect);
  1270.     afx_msg void OnVScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
  1271.  
  1272. // Control message handler member functions
  1273.     afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex);
  1274.     afx_msg int OnCompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  1275.     afx_msg void OnDeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  1276.     afx_msg void OnDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1277.     afx_msg UINT OnGetDlgCode();
  1278.     afx_msg void OnMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  1279.     afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
  1280.  
  1281. // MDI message handler member functions
  1282.     afx_msg void OnMDIActivate(BOOL bActivate, 
  1283.             CWnd* pActivateWnd, CWnd* pDeactivateWnd);
  1284.  
  1285. // Overridables and other helpers (for implementation of derived classes)
  1286. protected:
  1287.     // for deriving from a standard control
  1288.     virtual WNDPROC* GetSuperWndProcAddr();
  1289.  
  1290.     // for translating Windows messages in main message pump
  1291.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1292.  
  1293.     // for processing Windows messages
  1294.     virtual LONG WindowProc(UINT message, UINT wParam, LONG lParam);
  1295.  
  1296.     // for handling default processing
  1297.     LONG Default();
  1298.     virtual LONG DefWindowProc(UINT message, UINT wParam, LONG lParam);
  1299.  
  1300.     // for custom cleanup after WM_NCDESTROY
  1301.     virtual void PostNcDestroy();
  1302.  
  1303. // Implementation
  1304. public:
  1305.     virtual ~CWnd();
  1306. #ifdef _DEBUG
  1307.     virtual void AssertValid() const;
  1308.     virtual void Dump(CDumpContext& dc) const;
  1309. #endif
  1310.  
  1311. protected:
  1312.     friend void FAR PASCAL AFX_EXPORT _AfxSendMsgHook(int, UINT, LONG);
  1313.     friend LONG _AfxCallWndProc(CWnd*, HWND, UINT, UINT, LONG);
  1314.  
  1315.     friend class CWinApp;   // for PreTranslate access
  1316.  
  1317.     DECLARE_MESSAGE_MAP()
  1318. };
  1319.  
  1320. // helpers for registering your own WNDCLASSes
  1321. const char* AfxRegisterWndClass(UINT nClassStyle,
  1322.     HCURSOR hCursor = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0);
  1323.  
  1324. LONG FAR PASCAL AFX_EXPORT AfxWndProc(HWND, UINT, UINT, LONG);
  1325.  
  1326. /////////////////////////////////////////////////////////////////////////////
  1327. // pointer to afx_msg member function
  1328.  
  1329. #define AFX_MSG_CALL PASCAL
  1330.  
  1331. typedef void (AFX_MSG_CALL CWnd::*AFX_PMSG)(void);
  1332. struct CMessageEntry
  1333. {
  1334.     UINT        nMessage;   // windows message or control notification code
  1335.     UINT        nID;        // control ID (or 0 for windows messages)
  1336.     UINT        nSig;       // signature type (action) or near pointer to extra
  1337.     AFX_PMSG    pfn;        // routine to call (or special value)
  1338. };
  1339.  
  1340. /////////////////////////////////////////////////////////////////////////////
  1341. // CDialog, CModalDialog
  1342.  
  1343.  
  1344. class CDialog : public CWnd
  1345. {
  1346.     DECLARE_DYNAMIC(CDialog)
  1347. public:
  1348.  
  1349. // Constructors (protected since you must subclass to implement a Dialog)
  1350. protected:
  1351.     // Modeless construct
  1352.     CDialog();
  1353.     ~CDialog();
  1354.  
  1355.     BOOL Create(LPCSTR lpTemplateName, CWnd* pParentWnd = NULL);
  1356.     BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
  1357.  
  1358.     // Generic construct (for modal too)
  1359.     BOOL CreateIndirect(const void FAR* lpDialogTemplate,
  1360.         CWnd* pParentWnd = NULL);
  1361.  
  1362. // Attributes
  1363. public:
  1364.     void MapDialogRect(LPRECT lpRect) const;
  1365.  
  1366. protected:
  1367.     HBRUSH m_hBrushCtlBk;
  1368.  
  1369. // Operations
  1370. public:
  1371.     // message processing for modeless
  1372.     BOOL IsDialogMessage(LPMSG lpMsg);
  1373.  
  1374.     // support for passing on tab control - use 'PostMessage' if needed
  1375.     void NextDlgCtrl() const;
  1376.     void PrevDlgCtrl() const;
  1377.     void GotoDlgCtrl(CWnd* pWndCtrl);
  1378.  
  1379.     // default button access
  1380.     void SetDefID(UINT nID);
  1381.     DWORD GetDefID();
  1382.  
  1383.     // support for "new look" dialog boxes, set background color with this
  1384.     BOOL SetCtlBkColor(COLORREF clrCtlBk);
  1385.  
  1386.     // termination
  1387.     void EndDialog(int nResult);
  1388.  
  1389. // Overridables (special message map entries)
  1390.     virtual BOOL OnInitDialog();
  1391.     virtual void OnSetFont(CFont* pFont);
  1392.  
  1393.     // Default implementation sets colors to the "new look"
  1394.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  1395.  
  1396. // Implementation
  1397. #ifdef _DEBUG
  1398.     virtual void AssertValid() const;
  1399. #endif
  1400.  
  1401. protected:
  1402.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1403.     virtual WNDPROC* GetSuperWndProcAddr();
  1404.  
  1405.     DECLARE_MESSAGE_MAP()
  1406. };
  1407.  
  1408. class CModalDialog : public CDialog
  1409. {
  1410.     DECLARE_DYNAMIC(CModalDialog)
  1411.  
  1412. // Constructors
  1413. public:
  1414.     CModalDialog(LPCSTR lpTemplateName, CWnd* pParentWnd = NULL);
  1415.     CModalDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);
  1416.  
  1417.     // advanced usage - create indirect
  1418.     BOOL CreateIndirect(HANDLE hDialogTemplate);
  1419.  
  1420. // Operations
  1421.     virtual int DoModal();
  1422.  
  1423. // Overridables (automatic message map entries)
  1424. protected:
  1425.     virtual void OnOK();
  1426.     virtual void OnCancel();
  1427.  
  1428. // Implementation
  1429. #ifdef _DEBUG
  1430. public:
  1431.     virtual void AssertValid() const;
  1432.     virtual void Dump(CDumpContext& dc) const;
  1433. #endif
  1434.  
  1435. protected:
  1436.  
  1437.     // parameters for 'DoModal'
  1438.     LPCSTR m_lpDialogTemplate;      // name or MAKEINTRESOURCE
  1439.     HANDLE m_hDialogTemplate;       // Indirect if (lpDialogTemplate == NULL)
  1440.     CWnd* m_pParentWnd;
  1441.  
  1442.     DECLARE_MESSAGE_MAP()
  1443. };
  1444.  
  1445. /////////////////////////////////////////////////////////////////////////////
  1446. // Standard Windows controls
  1447.  
  1448. class CStatic : public CWnd
  1449. {
  1450.     DECLARE_DYNAMIC(CStatic)
  1451.  
  1452. // Constructors
  1453. public:
  1454.     CStatic();
  1455.     BOOL Create(LPCSTR lpText, DWORD dwStyle,
  1456.                 const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff);
  1457.  
  1458. #if (WINVER >= 0x030a)
  1459.     HICON SetIcon(HICON hIcon);
  1460.     HICON GetIcon() const;
  1461. #endif /* WINVER >= 0x030a */
  1462.     
  1463.  
  1464. // Implementation
  1465. protected:
  1466.     virtual WNDPROC* GetSuperWndProcAddr();
  1467. };
  1468.  
  1469. class CButton : public CWnd
  1470. {
  1471.     DECLARE_DYNAMIC(CButton)
  1472.  
  1473. // Constructors
  1474. public:
  1475.     CButton();
  1476.     BOOL Create(LPCSTR lpCaption, DWORD dwStyle,
  1477.                 const RECT& rect, CWnd* pParentWnd, UINT nID);
  1478.  
  1479. // Attributes
  1480.     UINT GetState() const;
  1481.     void SetState(BOOL bHighlight);
  1482.     int GetCheck() const;
  1483.     void SetCheck(int nCheck);
  1484.     UINT GetButtonStyle() const;
  1485.     void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);
  1486.  
  1487. // Overridables (for owner draw only)
  1488.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1489.  
  1490. // Implementation
  1491. protected:
  1492.     virtual WNDPROC* GetSuperWndProcAddr();
  1493. };
  1494.  
  1495.  
  1496. class CListBox : public CWnd
  1497. {
  1498.     DECLARE_DYNAMIC(CListBox)
  1499.  
  1500. // Constructors
  1501. public:
  1502.     CListBox();
  1503.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  1504.  
  1505. // Attributes
  1506.  
  1507.     // for entire listbox
  1508.     int GetCount() const;
  1509.     int GetHorizontalExtent() const;
  1510.     void SetHorizontalExtent(int cxExtent);
  1511.     int GetTopIndex() const;
  1512.     int SetTopIndex(int nIndex);
  1513.  
  1514.     // for single-selection listboxes
  1515.     int GetCurSel() const;
  1516.     int SetCurSel(int nSelect);
  1517.  
  1518.     // for multiple-selection listboxes
  1519.     int GetSel(int nIndex) const;           // also works for single-selection
  1520.     int SetSel(int nIndex, BOOL bSelect = TRUE);
  1521.     int GetSelCount() const;
  1522.     int GetSelItems(int nMaxItems, LPINT rgIndex) const;
  1523.  
  1524.     // for listbox items
  1525.     DWORD GetItemData(int nIndex) const;
  1526.     int SetItemData(int nIndex, DWORD dwItemData);
  1527.     int GetItemRect(int nIndex, LPRECT lpRect) const;
  1528.     int GetText(int nIndex, LPSTR lpBuffer) const;
  1529.     int GetTextLen(int nIndex) const;
  1530.     void GetText(int nIndex, CString& rString) const;
  1531.  
  1532.     // Settable only attributes
  1533.     void SetColumnWidth(int cxWidth);
  1534.     BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
  1535.     void SetTabStops();
  1536.     BOOL SetTabStops(int cxEachStop);
  1537.  
  1538. #if (WINVER >= 0x030a)
  1539.     int SetItemHeight(int nIndex, UINT cyItemHeight);
  1540.     int GetItemHeight(int nIndex) const;
  1541.     int FindStringExact(int nIndexStart, LPCSTR lpszFind) const;
  1542.     int GetCaretIndex() const;
  1543.     int SetCaretIndex(int nIndex, BOOL bScroll = TRUE);
  1544.     
  1545. #endif  /* WINVER >= 0x030a */
  1546.  
  1547. // Operations
  1548.     // manipulating listbox items
  1549.     int AddString(LPCSTR lpItem);
  1550.     int DeleteString(UINT nIndex);
  1551.     int InsertString(int nIndex, LPCSTR lpItem);
  1552.     void ResetContent();
  1553.     int Dir(UINT attr, LPCSTR lpWildCard);
  1554.  
  1555.     // selection helpers
  1556.     int FindString(int nStartAfter, LPCSTR lpItem) const;
  1557.     int SelectString(int nStartAfter, LPCSTR lpItem);
  1558.     int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem);
  1559.  
  1560. // Overridables (must override draw, measure and compare for owner draw)
  1561.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1562.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  1563.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  1564.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  1565.  
  1566. // Implementation
  1567. protected:
  1568.     virtual WNDPROC* GetSuperWndProcAddr();
  1569. };
  1570.  
  1571. class CComboBox : public CWnd
  1572. {
  1573.     DECLARE_DYNAMIC(CComboBox)
  1574.  
  1575. // Constructors
  1576. public:
  1577.     CComboBox();
  1578.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  1579.  
  1580. // Attributes
  1581.     // for entire combo box
  1582.     int GetCount() const;
  1583.     int GetCurSel() const;
  1584.     int SetCurSel(int nSelect);
  1585.  
  1586.     // for edit control
  1587.     DWORD GetEditSel() const;
  1588.     BOOL LimitText(int nMaxChars);
  1589.     BOOL SetEditSel(int nStartChar, int nEndChar);
  1590.  
  1591.     // for combobox item
  1592.     DWORD GetItemData(int nIndex) const;
  1593.     int SetItemData(int nIndex, DWORD dwItemData);
  1594.     int GetLBText(int nIndex, LPSTR lpText) const;
  1595.     int GetLBTextLen(int nIndex) const;
  1596.     void GetLBText(int nIndex, CString& rString) const;
  1597.  
  1598. #if (WINVER >= 0x030a)
  1599.     int SetItemHeight(int nIndex, UINT cyItemHeight);
  1600.     int GetItemHeight(int nIndex) const;
  1601.     int FindStringExact(int nIndexStart, LPCSTR lpszFind) const;
  1602.     int SetExtendedUI(BOOL bExtended = TRUE);
  1603.     BOOL GetExtendedUI() const;
  1604.     void GetDroppedControlRect(LPRECT lprect) const;
  1605.     BOOL GetDroppedState() const;
  1606. #endif  /* WINVER >= 0x030a */
  1607.  
  1608. // Operations
  1609.     // for drop-down combo boxes
  1610.     void ShowDropDown(BOOL bShowIt = TRUE);
  1611.  
  1612.     // manipulating listbox items
  1613.     int AddString(LPCSTR lpString);
  1614.     int DeleteString(UINT nIndex);
  1615.     int InsertString(int nIndex, LPCSTR lpString);
  1616.     void ResetContent();
  1617.     int Dir(UINT attr, LPCSTR lpWildCard);
  1618.  
  1619.     // selection helpers
  1620.     int FindString(int nStartAfter, LPCSTR lpString) const;
  1621.     int SelectString(int nStartAfter, LPCSTR lpString);
  1622.  
  1623.     // Clipboard operations
  1624.     void Clear();
  1625.     void Copy();
  1626.     void Cut();
  1627.     void Paste();
  1628.  
  1629. // Overridables (must override draw, measure and compare for owner draw)
  1630.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1631.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  1632.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  1633.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
  1634.  
  1635. // Implementation
  1636. protected:
  1637.     virtual WNDPROC* GetSuperWndProcAddr();
  1638. };
  1639.  
  1640.  
  1641. class CEdit : public CWnd
  1642. {
  1643.     DECLARE_DYNAMIC(CEdit)
  1644.  
  1645. // Constructors
  1646. public:
  1647.     CEdit();
  1648.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  1649.  
  1650. // Attributes
  1651.     BOOL CanUndo() const;
  1652.     int GetLineCount() const;
  1653.     BOOL GetModify() const;
  1654.     void SetModify(BOOL bModified = TRUE);
  1655.     void GetRect(LPRECT lpRect) const;
  1656.     DWORD GetSel() const;
  1657.     HANDLE  GetHandle() const;
  1658.     void SetHandle(HANDLE hBuffer);
  1659.  
  1660.     // NOTE: first word in lpBuffer must contain the size of the buffer!
  1661.     int GetLine(int nIndex, LPSTR lpBuffer) const;
  1662.     int GetLine(int nIndex, LPSTR lpBuffer, int nMaxLength) const;
  1663.  
  1664. // Operations
  1665.     void EmptyUndoBuffer();
  1666.     BOOL FmtLines(BOOL bAddEOL);
  1667.  
  1668.     void LimitText(int nChars = 0);
  1669.     int LineFromChar(int nIndex = -1) const;
  1670.     int LineIndex(int nLine = -1) const;
  1671.     int LineLength(int nLine = -1) const;
  1672.     void LineScroll(int nLines, int nChars = 0);
  1673.     void ReplaceSel(LPCSTR lpNewText);
  1674.     void SetPasswordChar(char ch);
  1675.     void SetRect(LPRECT lpRect);
  1676.     void SetRectNP(LPRECT lpRect);
  1677.     void SetSel(DWORD dwSelection);
  1678.     void SetSel(int nStartChar, int nEndChar);
  1679.     BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
  1680.     void SetTabStops();
  1681.     BOOL SetTabStops(int cxEachStop);
  1682.  
  1683.     // Clipboard operations
  1684.     BOOL Undo();
  1685.     void Clear();
  1686.     void Copy();
  1687.     void Cut();
  1688.     void Paste();
  1689.  
  1690. #if (WINVER >= 0x030a)
  1691.     BOOL SetReadOnly(BOOL bReadOnly = TRUE);
  1692.     int GetFirstVisibleLine() const;
  1693.     char GetPasswordChar() const;
  1694. #endif  /* WINVER >= 0x030a */
  1695.  
  1696. // Implementation
  1697. protected:
  1698.     virtual WNDPROC* GetSuperWndProcAddr();
  1699. };
  1700.  
  1701.  
  1702. class CScrollBar : public CWnd
  1703. {
  1704.     DECLARE_DYNAMIC(CScrollBar)
  1705.  
  1706. // Constructors
  1707. public:
  1708.     CScrollBar();
  1709.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  1710.  
  1711. // Attributes
  1712.     int GetScrollPos() const;
  1713.     int SetScrollPos(int nPos, BOOL bRedraw = TRUE);
  1714.     void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const;
  1715.     void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE);
  1716.     void ShowScrollBar(BOOL bShow = TRUE);
  1717.  
  1718. #if (WINVER >= 0x030a)
  1719.     BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH);
  1720. #endif  /* WINVER >= 0x030a */
  1721.  
  1722. // Implementation
  1723. protected:
  1724.     virtual WNDPROC* GetSuperWndProcAddr();
  1725. };
  1726.  
  1727. /////////////////////////////////////////////////////////////////////////////
  1728. // Extra Custom Controls
  1729.  
  1730. // CBitmapButton - push-button with 2 or 3 bitmap images
  1731. class CBitmapButton : public CButton
  1732. {
  1733.     DECLARE_DYNAMIC(CBitmapButton)
  1734.  
  1735. protected:
  1736.     // all bitmaps must be the same size
  1737.     CBitmap m_bitmap;           // normal image (REQUIRED)
  1738.     CBitmap m_bitmapSel;        // selected image (OPTIONAL)
  1739.     CBitmap m_bitmapFocus;      // focused but not selected (OPTIONAL)
  1740.  
  1741. public:
  1742. // Construction
  1743.     CBitmapButton();
  1744.     CBitmapButton(LPCSTR lpBitmapResource, LPCSTR lpBitmapResourceSel = NULL,
  1745.             LPCSTR lpBitmapResourceFocus = NULL);
  1746.  
  1747.     BOOL LoadBitmaps(LPCSTR lpBitmapResource, LPCSTR lpBitmapResourceSel = NULL,
  1748.             LPCSTR lpBitmapResourceFocus = NULL);
  1749.     BOOL AutoLoad(UINT nID, CWnd* pParent);
  1750.  
  1751. // Operations
  1752.     void SizeToContent();
  1753.  
  1754. // Implementation:
  1755. protected:
  1756.     virtual void    DrawItem(LPDRAWITEMSTRUCT lpDIS);
  1757. };
  1758.  
  1759. /////////////////////////////////////////////////////////////////////////////
  1760. // CFrameWnd
  1761.  
  1762. class CFrameWnd : public CWnd
  1763. {
  1764.     DECLARE_DYNAMIC(CFrameWnd)
  1765.  
  1766. protected:
  1767. // Protected attributes
  1768.     HACCEL m_hAccelTable;
  1769.  
  1770. public:
  1771.     static const CRect NEAR rectDefault;
  1772.  
  1773. // Constructors
  1774.     CFrameWnd();
  1775.  
  1776.     BOOL LoadAccelTable(LPCSTR lpAccelTableName);
  1777.     BOOL Create(LPCSTR lpClassName,
  1778.                 LPCSTR lpWindowName,
  1779.                 DWORD dwStyle = WS_OVERLAPPEDWINDOW,
  1780.                 const RECT& rect = rectDefault,
  1781.                 const CWnd* pParentWnd = NULL,      // != NULL for popups
  1782.                 LPCSTR lpMenuName = NULL);
  1783.  
  1784. // Implementation
  1785. public:
  1786. #ifdef _DEBUG
  1787.     virtual void AssertValid() const;
  1788.     virtual void Dump(CDumpContext& dc) const;
  1789. #endif
  1790.  
  1791.     virtual ~CFrameWnd();
  1792.  
  1793.     virtual CFrameWnd* GetParentFrame();
  1794.     virtual CFrameWnd* GetChildFrame();
  1795.  
  1796. protected:
  1797.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1798.     virtual void PostNcDestroy();   // default to delete this.
  1799. };
  1800.  
  1801. /////////////////////////////////////////////////////////////////////////////
  1802. // MDI Support
  1803.  
  1804. class CMDIFrameWnd : public CFrameWnd
  1805. {
  1806.     DECLARE_DYNAMIC(CMDIFrameWnd)
  1807. public:
  1808.  
  1809. // Constructors
  1810.     CMDIFrameWnd();
  1811.  
  1812.     BOOL Create(LPCSTR lpClassName,
  1813.                 LPCSTR lpWindowName,
  1814.                 DWORD dwStyle,
  1815.                 const RECT& rect,
  1816.                 const CWnd* pParentWnd,
  1817.                 LPCSTR lpMenuName);
  1818.  
  1819. // Overridables (automatic message map entries)
  1820. protected:
  1821.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  1822.  
  1823. // Attributes
  1824. public:
  1825.     HWND m_hWndMDIClient;
  1826.  
  1827.     virtual BOOL CreateClient(LPCREATESTRUCT lpCreateStruct,
  1828.                               CMenu* pWindowMenu);
  1829.  
  1830.     void MDIActivate(CWnd* pWndActivate);
  1831.     CMDIChildWnd* MDIGetActive(BOOL* pbMaximized = NULL) const;
  1832.     void MDIIconArrange();
  1833.     void MDIMaximize(CWnd* pWnd);
  1834.     void MDINext();
  1835.     void MDIRestore(CWnd* pWnd);
  1836.     CMenu* MDISetMenu(CMenu* pFrameMenu, CMenu* pWindowMenu);
  1837.  
  1838.     void MDICascade();
  1839.     void MDITile();
  1840.  
  1841. #if (WINVER >= 0x030a)
  1842.     void MDITile(int nType);
  1843.     void MDICascade(int nType);
  1844. #endif /* WINVER >= 0x030a */
  1845.  
  1846. // Implementation
  1847. public:
  1848. #ifdef _DEBUG
  1849.     virtual void AssertValid() const;
  1850. #endif
  1851.     virtual CFrameWnd* GetChildFrame();
  1852. protected:
  1853.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1854.     virtual LONG DefWindowProc(UINT nMsg, UINT wParam, LONG lParam);
  1855.     virtual BOOL OnCommand(UINT wParam, LONG lParam);
  1856. protected:
  1857.     DECLARE_MESSAGE_MAP()
  1858.  
  1859.     friend class CMDIChildWnd;
  1860. };
  1861.  
  1862.  
  1863. class CMDIChildWnd : public CFrameWnd
  1864. {
  1865.     DECLARE_DYNAMIC(CMDIChildWnd)
  1866. protected:
  1867.     CMDIFrameWnd* m_pMDIFrameWnd;           // our MDIFrame parent
  1868.  
  1869. // Constructors
  1870. public:
  1871.     CMDIChildWnd();
  1872.  
  1873.     BOOL Create(LPCSTR lpClassName,
  1874.                 LPCSTR lpWindowName,
  1875.                 DWORD dwStyle = 0,
  1876.                 const RECT& rect = rectDefault,
  1877.                 CMDIFrameWnd* pParentWnd = NULL);
  1878.  
  1879. // Operations
  1880.     void MDIDestroy();
  1881.     void MDIActivate();
  1882.     void MDIMaximize();
  1883.     void MDIRestore();
  1884.  
  1885. // Implementation
  1886. public:
  1887. #ifdef _DEBUG
  1888.     virtual void AssertValid() const;
  1889.     virtual void Dump(CDumpContext& dc) const;
  1890. #endif
  1891.  
  1892.     virtual BOOL DestroyWindow();
  1893.     virtual CFrameWnd* GetParentFrame();
  1894. protected:
  1895.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1896.     virtual LONG DefWindowProc(UINT nMsg, UINT wParam, LONG lParam);
  1897.  
  1898.     friend class CMDIFrameWnd;
  1899. };
  1900.  
  1901. /////////////////////////////////////////////////////////////////////////////
  1902. // Global functions for access to the one and only CWinApp
  1903.  
  1904. extern "C"
  1905. {
  1906. // standard C variables if you wish to access them from C programs,
  1907. // use inline functions for C++ programs
  1908. extern CWinApp* afxCurrentWinApp;
  1909. extern HANDLE afxCurrentInstanceHandle;
  1910. extern HANDLE afxCurrentResourceHandle;
  1911. extern const char* afxCurrentAppName;
  1912. extern BOOL AfxWinInit(HINSTANCE, HINSTANCE, LPSTR, int);
  1913. extern void AfxWinTerm();
  1914. }
  1915.  
  1916. // Global Windows state data helper functions (inlines)
  1917. CWinApp* AfxGetApp();
  1918. HINSTANCE AfxGetInstanceHandle();
  1919. HINSTANCE AfxGetResourceHandle();
  1920. const char* AfxGetAppName();
  1921.  
  1922. /////////////////////////////////////////////////////////////////////////////
  1923. // CWinApp - the world's simplest Windows application
  1924.  
  1925. class CWinApp : public CObject
  1926. {
  1927.     DECLARE_DYNAMIC(CWinApp)
  1928. public:
  1929.  
  1930. // Constructor
  1931.     CWinApp(const char* pszAppName = NULL);
  1932.     void SetCurrentHandles();
  1933.  
  1934. // Attributes
  1935.     // Startup args (do not change)
  1936.     const char* m_pszAppName;       // from constructor
  1937.     HINSTANCE m_hInstance;
  1938.     HINSTANCE m_hPrevInstance;
  1939.     LPSTR m_lpCmdLine;
  1940.     int m_nCmdShow;
  1941.  
  1942.     // Running args
  1943.     CWnd* m_pMainWnd;       // main window (optional)
  1944.  
  1945. // Operations
  1946.     // Cursors
  1947.     HCURSOR LoadCursor(LPCSTR lpCursorName);
  1948.     HCURSOR LoadCursor(UINT nIDCursor);
  1949.     HCURSOR LoadStandardCursor(LPCSTR lpCursorName); // for IDC_ values
  1950.     HCURSOR LoadOEMCursor(UINT nIDCursor);          // for OCR_ values
  1951.  
  1952.     // Icons
  1953.     HICON LoadIcon(LPCSTR lpIconName);
  1954.     HICON LoadIcon(UINT nIDIcon);
  1955.     HICON LoadStandardIcon(LPCSTR lpIconName);    // for IDI_ values
  1956.     HICON LoadOEMIcon(UINT nIDIcon);             // for OIC_ values
  1957.  
  1958.     BOOL PumpMessage();
  1959.  
  1960. // Overridables
  1961.     // hooks for your initialization code
  1962.     virtual BOOL InitApplication();
  1963.     virtual BOOL InitInstance();
  1964.  
  1965.     virtual int Run();
  1966.  
  1967.     // called by standard 'Run' implementation
  1968.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  1969.     virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
  1970.     virtual int ExitInstance(); // return app exit code
  1971.  
  1972.  
  1973. // Implementation
  1974. #ifdef _DEBUG
  1975.     virtual void AssertValid() const;
  1976.     virtual void Dump(CDumpContext& dc) const;
  1977. #endif
  1978.  
  1979. protected:
  1980.     MSG  m_msgCur;
  1981.  
  1982. #ifdef _DEBUG
  1983. // Diagnostic trap for when going back to message pump is not permitted.
  1984. protected:
  1985.     int m_nDisablePumpCount;
  1986. public:
  1987.     void EnablePump(BOOL bEnable);
  1988. #endif
  1989.  
  1990. };
  1991.  
  1992. /////////////////////////////////////////////////////////////////////////////
  1993. // Extra diagnostic tracing options
  1994.  
  1995. #ifdef _WINDOWS
  1996. extern "C" extern int afxTraceFlags;
  1997.     // 1 => multi-app debugging
  1998.     // 2 => main message pump trace (includes DDE)
  1999.     // 4 => Windows message tracing
  2000.     // 8 => Windows command routing trace (set 4+8 for control notifications)
  2001.     // 16 (0x10) => special OLE callback trace
  2002. #endif // _WINDOWS
  2003.  
  2004. /////////////////////////////////////////////////////////////////////////////
  2005. // Inline function declarations
  2006.  
  2007. #include "afxwin.inl"
  2008.  
  2009.  
  2010. #endif //__AFXWIN_H__
  2011.