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

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. // Note: This header file contains useful classes that are documented only
  12. //  in the MFC Technical Notes.  These classes may change from version to
  13. //  version, so be prepared to change your code accordingly if you utilize
  14. //  this header.  In the future, commonly used portions of this header
  15. //  may be moved and officially documented.
  16.  
  17. #ifndef __AFXPRIV_H__
  18. #define __AFXPRIV_H__
  19.  
  20. #ifndef __AFXADV_H__
  21.     #include <afxadv.h>
  22. #endif
  23.  
  24. #ifndef _INC_MALLOC
  25.     #include <malloc.h>
  26. #endif
  27.  
  28. #ifndef __AFXEXT_H__
  29.     #include <afxext.h>
  30. #endif
  31.  
  32. #ifdef _AFX_MINREBUILD
  33. #pragma component(minrebuild, off)
  34. #endif
  35. #ifndef _AFX_FULLTYPEINFO
  36. #pragma component(mintypeinfo, on)
  37. #endif
  38.  
  39. #ifdef _AFX_PACKING
  40. #pragma pack(push, _AFX_PACKING)
  41. #endif
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // AFXPRIV - MFC Private Classes
  45.  
  46. // Implementation structures
  47. struct AFX_SIZEPARENTPARAMS;    // Control bar implementation
  48. struct AFX_CMDHANDLERINFO;      // Command routing implementation
  49.  
  50. // Classes declared in this file
  51.  
  52.     //CDC
  53.         class CPreviewDC;               // Virtual DC for print preview
  54.  
  55.     //CCmdTarget
  56.         //CWnd
  57.             //CView
  58.                 class CPreviewView;     // Print preview view
  59.         //CFrameWnd
  60.             class COleCntrFrameWnd;
  61.             //CMiniFrameWnd
  62.                 class CMiniDockFrameWnd;
  63.  
  64. class CDockContext;                     // for dragging control bars
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67.  
  68. #undef AFX_DATA
  69. #define AFX_DATA AFX_CORE_DATA
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Global ID ranges (see Technical note TN020 for more details)
  73.  
  74. // 8000 -> FFFF command IDs (used for menu items, accelerators and controls)
  75. #define IS_COMMAND_ID(nID)  ((nID) & 0x8000)
  76.  
  77. // 8000 -> DFFF : user commands
  78. // E000 -> EFFF : AFX commands and other things
  79. // F000 -> FFFF : standard windows commands and other things etc
  80.     // E000 -> E7FF standard commands
  81.     // E800 -> E8FF control bars (first 32 are special)
  82.     // E900 -> EEFF standard window controls/components
  83.     // EF00 -> EFFF SC_ menu help
  84.     // F000 -> FFFF standard strings
  85. #define ID_COMMAND_FROM_SC(sc)  (((sc - 0xF000) >> 4) + AFX_IDS_SCFIRST)
  86.  
  87. // 0000 -> 7FFF IDR range
  88. // 0000 -> 6FFF : user resources
  89. // 7000 -> 7FFF : AFX (and standard windows) resources
  90. // IDR ranges (NOTE: IDR_ values must be <32768)
  91. #define ASSERT_VALID_IDR(nIDR) ASSERT((nIDR) != 0 && (nIDR) < 0x8000)
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // Context sensitive help support (see Technical note TN028 for more details)
  95.  
  96. // Help ID bases
  97. #define HID_BASE_COMMAND    0x00010000UL        // ID and IDM
  98. #define HID_BASE_RESOURCE   0x00020000UL        // IDR and IDD
  99. #define HID_BASE_PROMPT     0x00030000UL        // IDP
  100. #define HID_BASE_NCAREAS    0x00040000UL
  101. #define HID_BASE_CONTROL    0x00050000UL        // IDC
  102. #define HID_BASE_DISPATCH   0x00060000UL        // IDispatch help codes
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105. // Internal AFX Windows messages (see Technical note TN024 for more details)
  106. // (0x0360 - 0x037F are reserved for MFC)
  107.  
  108. #define WM_QUERYAFXWNDPROC  0x0360  // lResult = 1 if processed by AfxWndProc
  109. #define WM_SIZEPARENT       0x0361  // lParam = &AFX_SIZEPARENTPARAMS
  110. #define WM_SETMESSAGESTRING 0x0362  // wParam = nIDS (or 0),
  111.                                     // lParam = lpszOther (or NULL)
  112. #define WM_IDLEUPDATECMDUI  0x0363  // wParam == bDisableIfNoHandler
  113. #define WM_INITIALUPDATE    0x0364  // (params unused) - sent to children
  114. #define WM_COMMANDHELP      0x0365  // lResult = TRUE/FALSE,
  115.                                     // lParam = dwContext
  116. #define WM_HELPHITTEST      0x0366  // lResult = dwContext,
  117.                                     // lParam = MAKELONG(x,y)
  118. #define WM_EXITHELPMODE     0x0367  // (params unused)
  119. #define WM_RECALCPARENT     0x0368  // force RecalcLayout on frame window
  120.                                     //  (only for inplace frame windows)
  121. #define WM_SIZECHILD        0x0369  // special notify from COleResizeBar
  122.                                     // wParam = ID of child window
  123.                                     // lParam = lpRectNew (new position/size)
  124. #define WM_KICKIDLE         0x036A  // (params unused) causes idles to kick in
  125. #define WM_QUERYCENTERWND   0x036B  // lParam = HWND to use as centering parent
  126. #define WM_DISABLEMODAL     0x036C  // lResult = 0, disable during modal state
  127.                                     // lResult = 1, don't disable
  128. #define WM_FLOATSTATUS      0x036D  // wParam combination of FS_* flags below
  129.  
  130. // WM_ACTIVATETOPLEVEL is like WM_ACTIVATEAPP but works with hierarchies
  131. //   of mixed processes (as is the case with OLE in-place activation)
  132. #define WM_ACTIVATETOPLEVEL 0x036E  // wParam = nState (like WM_ACTIVATE)
  133.                                     // lParam = pointer to HWND[2]
  134.                                     //  lParam[0] = hWnd getting WM_ACTIVATE
  135.                                     //  lParam[1] = hWndOther
  136.  
  137. #define WM_QUERY3DCONTROLS  0x036F  // lResult != 0 if 3D controls wanted
  138.  
  139. // Note: Messages 0x0370, 0x0371, and 0x372 were incorrectly used by
  140. //  some versions of Windows.  To remain compatible, MFC does not
  141. //  use messages in that range.
  142. #define WM_RESERVED_0370    0x0370
  143. #define WM_RESERVED_0371    0x0371
  144. #define WM_RESERVED_0372    0x0372
  145.  
  146. // WM_SOCKET_NOTIFY and WM_SOCKET_DEAD are used internally by MFC's
  147. // Windows sockets implementation.  For more information, see sockcore.cpp
  148. #define WM_SOCKET_NOTIFY    0x0373
  149. #define WM_SOCKET_DEAD      0x0374
  150.  
  151. // same as WM_SETMESSAGESTRING except not popped if IsTracking()
  152. #define WM_POPMESSAGESTRING 0x0375
  153.  
  154. // WM_HELPPROMPTADDR is used internally to get the address of
  155. //  m_dwPromptContext from the associated frame window. This is used
  156. //  during message boxes to setup for F1 help while that msg box is
  157. //  displayed. lResult is the address of m_dwPromptContext.
  158. #define WM_HELPPROMPTADDR   0x0376
  159.  
  160. // Constants used in DLGINIT resources for OLE control containers
  161. // NOTE: These are NOT real Windows messages they are simply tags
  162. // used in the control resource and are never used as 'messages'
  163. #define WM_OCC_LOADFROMSTREAM           0x0376
  164. #define WM_OCC_LOADFROMSTORAGE          0x0377
  165. #define WM_OCC_INITNEW                  0x0378
  166. #define WM_OCC_LOADFROMSTREAM_EX        0x037A
  167. #define WM_OCC_LOADFROMSTORAGE_EX       0x037B
  168.  
  169. // Marker used while rearranging the message queue
  170. #define WM_QUEUE_SENTINEL   0x0379
  171.  
  172. // Note: Messages 0x037C - 0x37E reserved for future MFC use.
  173. #define WM_RESERVED_037C    0x037C
  174. #define WM_RESERVED_037D    0x037D
  175. #define WM_RESERVED_037E    0x037E
  176.  
  177. // WM_FORWARDMSG - used by ATL to forward a message to another window for processing
  178. //  WPARAM - DWORD dwUserData - defined by user
  179. //  LPARAM - LPMSG pMsg - a pointer to the MSG structure
  180. //  return value - 0 if the message was not processed, nonzero if it was
  181. #define WM_FORWARDMSG       0x037F
  182.  
  183. // like ON_MESSAGE but no return value
  184. #define ON_MESSAGE_VOID(message, memberFxn) \
  185.     { message, 0, 0, 0, AfxSig_vv, \
  186.         (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(void))&memberFxn },
  187.  
  188. // special struct for WM_SIZEPARENT
  189. struct AFX_SIZEPARENTPARAMS
  190. {
  191.     HDWP hDWP;       // handle for DeferWindowPos
  192.     RECT rect;       // parent client rectangle (trim as appropriate)
  193.     SIZE sizeTotal;  // total size on each side as layout proceeds
  194.     BOOL bStretch;   // should stretch to fill all space
  195. };
  196.  
  197. // flags for wParam in the WM_FLOATSTATUS message
  198. enum {  FS_SHOW = 0x01, FS_HIDE = 0x02,
  199.         FS_ACTIVATE = 0x04, FS_DEACTIVATE = 0x08,
  200.         FS_ENABLE = 0x10, FS_DISABLE = 0x20,
  201.         FS_SYNCACTIVE = 0x40 };
  202.  
  203. void AFXAPI AfxRepositionWindow(AFX_SIZEPARENTPARAMS* lpLayout,
  204.     HWND hWnd, LPCRECT lpRect);
  205.  
  206. /////////////////////////////////////////////////////////////////////////////
  207. // Implementation of command routing
  208.  
  209. struct AFX_CMDHANDLERINFO
  210. {
  211.     CCmdTarget* pTarget;
  212.     void (AFX_MSG_CALL CCmdTarget::*pmf)(void);
  213. };
  214.  
  215. /////////////////////////////////////////////////////////////////////////////
  216. // Robust file save support
  217. // opens a temp file if modeCreate specified and enough free space
  218. // renaming, etc occurs automatically if everything succeeds
  219.  
  220. class CMirrorFile : public CFile
  221. {
  222. // Implementation
  223. public:
  224.     virtual void Abort();
  225.     virtual void Close();
  226.     virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags,
  227.         CFileException* pError = NULL);
  228.     static CString GetTempName(LPCTSTR pstrOriginalFile, BOOL bCreate);
  229.  
  230. protected:
  231.     CString m_strMirrorName;
  232. };
  233.  
  234. /////////////////////////////////////////////////////////////////////////////
  235. // Implementation of PrintPreview
  236.  
  237. class CPreviewDC : public CDC
  238. {
  239.     DECLARE_DYNAMIC(CPreviewDC)
  240.  
  241. public:
  242.     virtual void SetAttribDC(HDC hDC);  // Set the Attribute DC
  243.     virtual void SetOutputDC(HDC hDC);
  244.  
  245.     virtual void ReleaseOutputDC();
  246.  
  247. // Constructors
  248.     CPreviewDC();
  249.  
  250. // Implementation
  251. public:
  252.     virtual ~CPreviewDC();
  253. #ifdef _DEBUG
  254.     virtual void AssertValid() const;
  255.     virtual void Dump(CDumpContext& dc) const;
  256. #endif
  257.  
  258.     void SetScaleRatio(int nNumerator, int nDenominator);
  259.     void SetTopLeftOffset(CSize TopLeft);
  260.     void ClipToPage();
  261.  
  262.     // These conversion functions can be used without an output DC
  263.  
  264.     void PrinterDPtoScreenDP(LPPOINT lpPoint) const;
  265.  
  266. // Device-Context Functions
  267.     virtual int SaveDC();
  268.     virtual BOOL RestoreDC(int nSavedDC);
  269.  
  270. public:
  271.     virtual CGdiObject* SelectStockObject(int nIndex);
  272.     virtual CFont* SelectObject(CFont* pFont);
  273.  
  274. // Drawing-Attribute Functions
  275.     virtual COLORREF SetBkColor(COLORREF crColor);
  276.     virtual COLORREF SetTextColor(COLORREF crColor);
  277.  
  278. // Mapping Functions
  279.     virtual int SetMapMode(int nMapMode);
  280.     virtual CPoint SetViewportOrg(int x, int y);
  281.     virtual CPoint OffsetViewportOrg(int nWidth, int nHeight);
  282.     virtual CSize SetViewportExt(int x, int y);
  283.     virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
  284.     virtual CSize SetWindowExt(int x, int y);
  285.     virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
  286.  
  287. // Text Functions
  288.     virtual BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount);
  289.     virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
  290.                 LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths);
  291.     virtual CSize TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount,
  292.                 int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
  293.     virtual int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect,
  294.                 UINT nFormat);
  295.     virtual BOOL GrayString(CBrush* pBrush,
  296.                 BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int),
  297.                     LPARAM lpData, int nCount,
  298.                     int x, int y, int nWidth, int nHeight);
  299.  
  300. // Printer Escape Functions
  301.     virtual int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData);
  302.  
  303. // Implementation
  304. protected:
  305.     void MirrorMappingMode(BOOL bCompute);
  306.     void MirrorViewportOrg();
  307.     void MirrorFont();
  308.     void MirrorAttributes();
  309.  
  310.     CSize ComputeDeltas(int& x, LPCTSTR lpszString, UINT& nCount, BOOL bTabbed,
  311.                     UINT nTabStops, LPINT lpnTabStops, int nTabOrigin,
  312.                     LPTSTR lpszOutputString, int* pnDxWidths, int& nRightFixup);
  313.  
  314. protected:
  315.     int m_nScaleNum;    // Scale ratio Numerator
  316.     int m_nScaleDen;    // Scale ratio Denominator
  317.     int m_nSaveDCIndex; // DC Save index when Screen DC Attached
  318.     int m_nSaveDCDelta; // delta between Attrib and output restore indices
  319.     CSize m_sizeTopLeft;// Offset for top left corner of page
  320.     HFONT m_hFont;      // Font selected into the screen DC (NULL if none)
  321.     HFONT m_hPrinterFont; // Font selected into the print DC
  322.  
  323.     CSize m_sizeWinExt; // cached window extents computed for screen
  324.     CSize m_sizeVpExt;  // cached viewport extents computed for screen
  325. };
  326.  
  327. /////////////////////////////////////////////////////////////////////////////
  328. // CPreviewView
  329.  
  330. class CDialogBar;
  331.  
  332. class CPreviewView : public CScrollView
  333. {
  334.     DECLARE_DYNCREATE(CPreviewView)
  335.  
  336. // Constructors
  337. public:
  338.     CPreviewView();
  339.     BOOL SetPrintView(CView* pPrintView);
  340.  
  341. // Attributes
  342. protected:
  343.     CView* m_pOrigView;
  344.     CView* m_pPrintView;
  345.     CPreviewDC* m_pPreviewDC;  // Output and attrib DCs Set, not created
  346.     CDC m_dcPrint;             // Actual printer DC
  347.  
  348. // Operations
  349.     void SetZoomState(UINT nNewState, UINT nPage, CPoint point);
  350.     void SetCurrentPage(UINT nPage, BOOL bClearRatios);
  351.  
  352.     // Returns TRUE if in a page rect. Returns the page index
  353.     // in nPage and the point converted to 1:1 screen device coordinates
  354.     BOOL FindPageRect(CPoint& point, UINT& nPage);
  355.  
  356.  
  357. // Overridables
  358.     virtual void OnActivateView(BOOL bActivate,
  359.             CView* pActivateView, CView* pDeactiveView);
  360.  
  361.     // Returns .cx/.cy as the numerator/denominator pair for the ratio
  362.     // using CSize for convenience
  363.     virtual CSize CalcScaleRatio(CSize windowSize, CSize actualSize);
  364.  
  365.     virtual void PositionPage(UINT nPage);
  366.     virtual void OnDisplayPageNumber(UINT nPage, UINT nPagesDisplayed);
  367.  
  368. // Implementation
  369. public:
  370.     virtual ~CPreviewView();
  371.     virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
  372. #ifdef _DEBUG
  373.     void AssertValid() const;
  374.     void Dump(CDumpContext& dc) const;
  375. #endif
  376.  
  377. protected:
  378.     //{{AFX_MSG(CPreviewView)
  379.     afx_msg void OnPreviewClose();
  380.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  381.     afx_msg void OnSize(UINT nType, int cx, int cy);
  382.     afx_msg void OnDraw(CDC* pDC);
  383.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  384.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  385.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  386.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  387.     afx_msg void OnNumPageChange();
  388.     afx_msg void OnNextPage();
  389.     afx_msg void OnPrevPage();
  390.     afx_msg void OnPreviewPrint();
  391.     afx_msg void OnZoomIn();
  392.     afx_msg void OnZoomOut();
  393.     afx_msg void OnUpdateNumPageChange(CCmdUI* pCmdUI);
  394.     afx_msg void OnUpdateNextPage(CCmdUI* pCmdUI);
  395.     afx_msg void OnUpdatePrevPage(CCmdUI* pCmdUI);
  396.     afx_msg void OnUpdateZoomIn(CCmdUI* pCmdUI);
  397.     afx_msg void OnUpdateZoomOut(CCmdUI* pCmdUI);
  398.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  399.     //}}AFX_MSG
  400.  
  401.     void DoZoom(UINT nPage, CPoint point);
  402.     void SetScaledSize(UINT nPage);
  403.     CSize CalcPageDisplaySize();
  404.  
  405.     CPrintPreviewState* m_pPreviewState; // State to restore
  406.     CDialogBar* m_pToolBar; // Toolbar for preview
  407.  
  408.     struct PAGE_INFO
  409.     {
  410.         PAGE_INFO();
  411.         CRect rectScreen; // screen rect (screen device units)
  412.         CSize sizeUnscaled; // unscaled screen rect (screen device units)
  413.         CSize sizeScaleRatio; // scale ratio (cx/cy)
  414.         CSize sizeZoomOutRatio; // scale ratio when zoomed out (cx/cy)
  415.     };
  416.  
  417.     PAGE_INFO* m_pPageInfo; // Array of page info structures
  418.     PAGE_INFO m_pageInfoArray[2]; // Embedded array for the default implementation
  419.  
  420.     BOOL m_bPageNumDisplayed;// Flags whether or not page number has yet
  421.                                 // been displayed on status line
  422.     UINT m_nZoomOutPages; // number of pages when zoomed out
  423.     UINT m_nZoomState;
  424.     UINT m_nMaxPages; // for sanity checks
  425.     UINT m_nCurrentPage;
  426.     UINT m_nPages;
  427.     int m_nSecondPageOffset; // used to shift second page position
  428.  
  429.     HCURSOR m_hMagnifyCursor;
  430.  
  431.     CSize m_sizePrinterPPI; // printer pixels per inch
  432.     CPoint m_ptCenterPoint;
  433.     CPrintInfo* m_pPreviewInfo;
  434.  
  435.     DECLARE_MESSAGE_MAP()
  436.  
  437.     friend class CView;
  438.     friend BOOL CALLBACK _AfxPreviewCloseProc(CFrameWnd* pFrameWnd);
  439. };
  440.  
  441. // Zoom States
  442. #define ZOOM_OUT    0
  443. #define ZOOM_MIDDLE 1
  444. #define ZOOM_IN     2
  445.  
  446. /////////////////////////////////////////////////////////////////////////////
  447. // mirroring support
  448.  
  449. //WINBUG: some mirroring stuff will be in wingdi.h someday
  450. #ifndef LAYOUT_RTL
  451. #define LAYOUT_LTR                               0x00000000
  452. #define LAYOUT_RTL                         0x00000001
  453. #define NOMIRRORBITMAP                     0x80000000
  454. #endif
  455.  
  456. //WINBUG: some mirroring stuff will be in winuser.h someday
  457. #ifndef WS_EX_LAYOUTRTL
  458. #define WS_EX_LAYOUTRTL                    0x00400000L
  459. #endif
  460.  
  461.  
  462. /////////////////////////////////////////////////////////////////////////////
  463. // toolbar docking support
  464.  
  465. class CDockContext
  466. {
  467. public:
  468. // Construction
  469.     CDockContext(CControlBar* pBar);
  470.  
  471. // Attributes
  472.     CPoint m_ptLast;            // last mouse position during drag
  473.     CRect m_rectLast;
  474.     CSize m_sizeLast;
  475.     BOOL m_bDitherLast;
  476.  
  477.     // Rectangles used during dragging or resizing
  478.     CRect m_rectDragHorz;
  479.     CRect m_rectDragVert;
  480.     CRect m_rectFrameDragHorz;
  481.     CRect m_rectFrameDragVert;
  482.  
  483.     CControlBar* m_pBar;        // the toolbar that created this context
  484.     CFrameWnd* m_pDockSite;     // the controlling frame of the CControlBar
  485.     DWORD m_dwDockStyle;        // allowable dock styles for bar
  486.     DWORD m_dwOverDockStyle;    // style of dock that rect is over
  487.     DWORD m_dwStyle;            // style of control bar
  488.     BOOL m_bFlip;               // if shift key is down
  489.     BOOL m_bForceFrame;         // if ctrl key is down
  490.  
  491.     CDC* m_pDC;                 // where to draw during drag
  492.     BOOL m_bDragging;
  493.     int m_nHitTest;
  494.  
  495.     UINT m_uMRUDockID;
  496.     CRect m_rectMRUDockPos;
  497.  
  498.     DWORD m_dwMRUFloatStyle;
  499.     CPoint m_ptMRUFloatPos;
  500.  
  501. // Drag Operations
  502.     virtual void StartDrag(CPoint pt);
  503.     void Move(CPoint pt);       // called when mouse has moved
  504.     void EndDrag();             // drop
  505.     void OnKey(int nChar, BOOL bDown);
  506.  
  507. // Resize Operations
  508.     virtual void StartResize(int nHitTest, CPoint pt);
  509.     void Stretch(CPoint pt);
  510.     void EndResize();
  511.  
  512. // Double Click Operations
  513.     virtual void ToggleDocking();
  514.  
  515. // Operations
  516.     void InitLoop();
  517.     void CancelLoop();
  518.  
  519. // Implementation
  520. public:
  521.     ~CDockContext();
  522.     BOOL Track();
  523.     void DrawFocusRect(BOOL bRemoveRect = FALSE);
  524.         // draws the correct outline
  525.     void UpdateState(BOOL* pFlag, BOOL bNewValue);
  526.     DWORD CanDock();
  527.     CDockBar* GetDockBar(DWORD dwOverDockStyle);
  528. };
  529.  
  530. /////////////////////////////////////////////////////////////////////////////
  531. // CControlBarInfo - used for docking serialization
  532.  
  533. class CControlBarInfo
  534. {
  535. public:
  536. // Implementation
  537.     CControlBarInfo();
  538.  
  539. // Attributes
  540.     UINT m_nBarID;      // ID of this bar
  541.     BOOL m_bVisible;    // visibility of this bar
  542.     BOOL m_bFloating;   // whether floating or not
  543.     BOOL m_bHorz;       // orientation of floating dockbar
  544.     BOOL m_bDockBar;    // TRUE if a dockbar
  545.     CPoint m_pointPos;  // topleft point of window
  546.  
  547.     UINT m_nMRUWidth;   // MRUWidth for Dynamic Toolbars
  548.     BOOL m_bDocking;    // TRUE if this bar has a DockContext
  549.     UINT m_uMRUDockID;  // most recent docked dockbar
  550.     CRect m_rectMRUDockPos; // most recent docked position
  551.     DWORD m_dwMRUFloatStyle; // most recent floating orientation
  552.     CPoint m_ptMRUFloatPos; // most recent floating position
  553.  
  554.     CPtrArray m_arrBarID;   // bar IDs for bars contained within this one
  555.     CControlBar* m_pBar;    // bar which this refers to (transient)
  556.  
  557.     void Serialize(CArchive& ar, CDockState* pDockState);
  558.     BOOL LoadState(LPCTSTR lpszProfileName, int nIndex, CDockState* pDockState);
  559.     BOOL SaveState(LPCTSTR lpszProfileName, int nIndex);
  560. };
  561.  
  562. /////////////////////////////////////////////////////////////////////////////
  563. // CDockBar - used for docking
  564.  
  565. class CDockBar : public CControlBar
  566. {
  567.     DECLARE_DYNAMIC(CDockBar)
  568.  
  569. // Construction
  570. public:
  571.     CDockBar(BOOL bFloating = FALSE);   // TRUE if attached to CMiniDockFrameWnd
  572.     BOOL Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID);
  573.  
  574. // Attributes
  575.     BOOL m_bFloating;
  576.  
  577.     virtual BOOL IsDockBar() const;
  578.     int GetDockedCount() const;
  579.     virtual int GetDockedVisibleCount() const;
  580.  
  581. // Operations
  582.     void DockControlBar(CControlBar* pBar, LPCRECT lpRect = NULL);
  583.     void ReDockControlBar(CControlBar* pBar, LPCRECT lpRect = NULL);
  584.     BOOL RemoveControlBar(CControlBar*, int nPosExclude = -1, int nAddPlaceHolder = 0);
  585.     void RemovePlaceHolder(CControlBar* pBar);
  586.  
  587. // Implementation
  588. public:
  589.     virtual ~CDockBar();
  590. #ifdef _DEBUG
  591.     virtual void AssertValid() const;
  592.     virtual void Dump(CDumpContext& dc) const;
  593. #endif
  594.     virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  595.     virtual void DoPaint(CDC* pDC);
  596.  
  597.     // public implementation helpers
  598.     void GetBarInfo(CControlBarInfo* pInfo);
  599.     void SetBarInfo(CControlBarInfo* pInfo, CFrameWnd* pFrameWnd);
  600.     int FindBar(CControlBar* pBar, int nPosExclude = -1);
  601.     void ShowAll(BOOL bShow);
  602.  
  603.     CPtrArray m_arrBars;    // each element is a CControlBar
  604. protected:
  605.     BOOL m_bLayoutQuery;
  606.     CRect m_rectLayout;
  607.  
  608.     CControlBar* GetDockedControlBar(int nPos) const;
  609.  
  610.     // implementation helpers
  611.     int Insert(CControlBar* pBar, CRect rect, CPoint ptMid);
  612.     virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  613.  
  614.     //{{AFX_MSG(CDockBar)
  615.     afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  616.     afx_msg void OnNcPaint();
  617.     afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
  618.     afx_msg void OnPaint();
  619.     afx_msg LRESULT OnSizeParent(WPARAM, LPARAM);
  620.     //}}AFX_MSG
  621.     DECLARE_MESSAGE_MAP()
  622.  
  623.     friend class CMiniDockFrameWnd;
  624. };
  625.  
  626. class CMiniDockFrameWnd : public CMiniFrameWnd
  627. {
  628.     DECLARE_DYNCREATE(CMiniDockFrameWnd)
  629.  
  630. public:
  631. // Construction
  632.     CMiniDockFrameWnd();
  633.     virtual BOOL Create(CWnd* pParent, DWORD dwBarStyle);
  634.  
  635. // Operations
  636.     virtual void RecalcLayout(BOOL bNotify = TRUE);
  637.  
  638. // Implementation
  639. public:
  640.     CDockBar m_wndDockBar;
  641.  
  642.     //{{AFX_MSG(CMiniFrameWnd)
  643.     afx_msg void OnClose();
  644.     afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  645.     afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  646.     //}}AFX_MSG
  647.     afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
  648.     DECLARE_MESSAGE_MAP()
  649. };
  650.  
  651. /////////////////////////////////////////////////////////////////////////////
  652. // COleCntrFrameWnd
  653.  
  654. class COleIPFrameWnd;
  655.  
  656. class COleCntrFrameWnd : public CFrameWnd
  657. {
  658. // Constructor
  659. public:
  660.     COleCntrFrameWnd(COleIPFrameWnd* pInPlaceFrame);
  661.  
  662. // Implementation
  663. protected:
  664.     COleIPFrameWnd* m_pInPlaceFrame;
  665.     virtual void PostNcDestroy();
  666.  
  667. public:
  668.     virtual ~COleCntrFrameWnd();
  669.     virtual void RecalcLayout(BOOL bNotify = TRUE);
  670.     void OnIdleUpdateCmdUI();
  671.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  672.         AFX_CMDHANDLERINFO* pHandlerInfo);
  673. #ifdef _DEBUG
  674.     void AssertValid() const;
  675. #endif
  676. };
  677.  
  678. /////////////////////////////////////////////////////////////////////////////
  679. // CDialogTemplate
  680.  
  681. class CDialogTemplate
  682. {
  683. // Constructors
  684. public:
  685.     CDialogTemplate(const DLGTEMPLATE* pTemplate = NULL);
  686.     CDialogTemplate(HGLOBAL hGlobal);
  687.  
  688. // Attributes
  689.     BOOL HasFont() const;
  690.     BOOL SetFont(LPCTSTR lpFaceName, WORD nFontSize);
  691.     BOOL SetSystemFont(WORD nFontSize = 0);
  692.     BOOL GetFont(CString& strFaceName, WORD& nFontSize) const;
  693.     void GetSizeInDialogUnits(SIZE* pSize) const;
  694.     void GetSizeInPixels(SIZE* pSize) const;
  695.  
  696.     static BOOL AFX_CDECL GetFont(const DLGTEMPLATE* pTemplate,
  697.         CString& strFaceName, WORD& nFontSize);
  698.  
  699. // Operations
  700.     BOOL Load(LPCTSTR lpDialogTemplateID);
  701.     HGLOBAL Detach();
  702.  
  703. // Implementation
  704. public:
  705.     ~CDialogTemplate();
  706.  
  707.     HGLOBAL m_hTemplate;
  708.     DWORD m_dwTemplateSize;
  709.     BOOL m_bSystemFont;
  710.  
  711. protected:
  712.     static BYTE* AFX_CDECL GetFontSizeField(const DLGTEMPLATE* pTemplate);
  713.     static UINT AFX_CDECL GetTemplateSize(const DLGTEMPLATE* pTemplate);
  714.     BOOL SetTemplate(const DLGTEMPLATE* pTemplate, UINT cb);
  715. };
  716.  
  717. /////////////////////////////////////////////////////////////////////////////
  718. // WM_NOTIFY support
  719.  
  720. struct AFX_NOTIFY
  721. {
  722.     LRESULT* pResult;
  723.     NMHDR* pNMHDR;
  724. };
  725.  
  726. /////////////////////////////////////////////////////////////////////////////
  727. // Global implementation helpers
  728.  
  729. // window creation hooking
  730. void AFXAPI AfxHookWindowCreate(CWnd* pWnd);
  731. BOOL AFXAPI AfxUnhookWindowCreate();
  732. void AFXAPI AfxResetMsgCache();
  733.  
  734. // for backward compatibility to previous versions
  735. #define _AfxHookWindowCreate    AfxHookWindowCreate
  736. #define _AfxUnhookWindowCreate  AfxUnhookWindowCreate
  737.  
  738. // string helpers
  739. void AFXAPI AfxSetWindowText(HWND hWndCtrl, LPCTSTR lpszNew);
  740. int AFXAPI AfxLoadString(UINT nIDS, LPTSTR lpszBuf, UINT nMaxBuf = 256);
  741.  
  742. HDC AFXAPI AfxCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode);
  743.  
  744. void AFXAPI AfxGetModuleShortFileName(HINSTANCE hInst, CString& strShortName);
  745.  
  746. // Failure dialog helpers
  747. void AFXAPI AfxFailMaxChars(CDataExchange* pDX, int nChars);
  748. void AFXAPI AfxFailRadio(CDataExchange* pDX);
  749.  
  750. // DLL load helpers
  751. HINSTANCE AFXAPI AfxLoadDll(HINSTANCE* volatile hInst, LPCSTR lpszDLL);
  752. HINSTANCE AFXAPI AfxLoadDll(HINSTANCE* volatile hInst, LPCSTR lpszDLL,
  753.     FARPROC* pProcPtrs, LPCSTR lpszProcName);
  754.  
  755. #ifndef __AFXCONV_H__
  756. #include <afxconv.h>
  757. #endif
  758.  
  759. /////////////////////////////////////////////////////////////////////////////
  760.  
  761. #ifdef _AFX_PACKING
  762. #pragma pack(pop)
  763. #endif
  764.  
  765. #undef AFX_DATA
  766. #define AFX_DATA
  767.  
  768. #ifdef _AFX_MINREBUILD
  769. #pragma component(minrebuild, on)
  770. #endif
  771. #ifndef _AFX_FULLTYPEINFO
  772. #pragma component(mintypeinfo, off)
  773. #endif
  774.  
  775. #endif // __AFXPRIV_H__
  776.  
  777. /////////////////////////////////////////////////////////////////////////////
  778.  
  779. #ifndef __AFXPRIV2_H__
  780. #include <afxpriv2.h>
  781. #endif
  782.