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.

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