afxpriv.h 25 KB

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