Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4661 lines
151 KiB

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