home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / include / afxodlgs.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  14KB  |  511 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. #ifndef __AFXODLGS_H__
  12. #define __AFXODLGS_H__
  13.  
  14. #ifdef _AFX_NO_OLE_SUPPORT
  15.     #error OLE classes not supported in this library variant.
  16. #endif
  17.  
  18. #ifndef __AFXOLE_H__
  19.     #include <afxole.h>
  20. #endif
  21.  
  22. #ifndef __AFXDLGS_H__
  23.     #include <afxdlgs.h>
  24. #endif
  25.  
  26. // include OLE dialog/helper APIs
  27. #ifndef _OLEDLG_H_
  28.     #include <oledlg.h>
  29. #endif
  30.  
  31. #ifdef _AFX_MINREBUILD
  32. #pragma component(minrebuild, off)
  33. #endif
  34. #ifndef _AFX_FULLTYPEINFO
  35. #pragma component(mintypeinfo, on)
  36. #endif
  37.  
  38. #ifdef _AFX_PACKING
  39. #pragma pack(push, _AFX_PACKING)
  40. #endif
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // AFXODLGS.H - MFC OLE dialogs
  44.  
  45. // Classes declared in this file
  46.  
  47. //CCommonDialog
  48.     class COleDialog;                   // base class for OLE dialog wrappers
  49.         class COleInsertDialog;         // insert object dialog
  50.         class COleConvertDialog;        // convert dialog
  51.         class COleChangeIconDialog;     // change icon dialog
  52.         class COlePasteSpecialDialog;   // paste special dialog
  53.         class COleLinksDialog;          // edit links dialog
  54.             class COleUpdateDialog;     // update links/embeddings dialog
  55.         class COleBusyDialog;           // used for
  56.         class COlePropertiesDialog;
  57.         class COleChangeSourceDialog;
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60.  
  61. // AFXDLL support
  62. #undef AFX_DATA
  63. #define AFX_DATA AFX_OLE_DATA
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // COleUILinkInfo -- used internally to implement
  67. // IOleUILinkInfo and IOleUILinkContainer
  68. // used by COleLinksDialog and COleChangeSourceDialog
  69.  
  70. class COleUILinkInfo : public IOleUILinkInfo
  71. {
  72. public:
  73.     COleUILinkInfo(COleDocument* pDocument);
  74.  
  75. // Implementation
  76.     COleDocument* m_pDocument;          // document being manipulated
  77.     COleClientItem* m_pSelectedItem;    // primary selected item in m_pDocument
  78.     POSITION m_pos;                     // used during link enumeration
  79.     BOOL m_bUpdateLinks;                // update links?
  80.     BOOL m_bUpdateEmbeddings;           // update embeddings?
  81.  
  82.     STDMETHOD_(ULONG, AddRef)();
  83.     STDMETHOD_(ULONG, Release)();
  84.     STDMETHOD(QueryInterface)(REFIID, LPVOID*);
  85.  
  86.     // IOleUILinkContainer
  87.     STDMETHOD_(DWORD,GetNextLink)(DWORD);
  88.     STDMETHOD(SetLinkUpdateOptions)(DWORD, DWORD);
  89.     STDMETHOD(GetLinkUpdateOptions)(DWORD, LPDWORD);
  90.     STDMETHOD(SetLinkSource)(DWORD, LPTSTR, ULONG, ULONG*, BOOL);
  91.     STDMETHOD(GetLinkSource)(DWORD, LPTSTR*, ULONG*, LPTSTR*, LPTSTR*, BOOL*,
  92.         BOOL*);
  93.     STDMETHOD(OpenLinkSource)(DWORD);
  94.     STDMETHOD(UpdateLink)(DWORD, BOOL, BOOL);
  95.     STDMETHOD(CancelLink)(DWORD);
  96.     // IOleUILinkInfo
  97.     STDMETHOD(GetLastUpdate)(DWORD dwLink, FILETIME* lpLastUpdate);
  98. };
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // Wrappers for OLE UI dialogs
  102.  
  103. #ifdef _AFXDLL
  104. class COleDialog : public CCommonDialog
  105. #else
  106. class AFX_NOVTABLE COleDialog : public CCommonDialog
  107. #endif
  108. {
  109.     DECLARE_DYNAMIC(COleDialog)
  110.  
  111. // Attributes
  112. public:
  113.     UINT GetLastError() const;
  114.  
  115. // Implementation
  116. public:
  117.     int MapResult(UINT nResult);
  118.     COleDialog(CWnd* pParentWnd);
  119. #ifdef _DEBUG
  120.     virtual void Dump(CDumpContext& dc) const;
  121. #endif
  122.  
  123. protected:
  124.     UINT m_nLastError;
  125.  
  126. protected:
  127.     friend UINT CALLBACK _AfxOleHookProc(HWND, UINT, WPARAM, LPARAM);
  128. };
  129.  
  130. /////////////////////////////////////////////////////////////////////////////
  131. // COleInsertDialog
  132.  
  133. class COleInsertDialog : public COleDialog
  134. {
  135.     DECLARE_DYNAMIC(COleInsertDialog)
  136.  
  137. // Attributes
  138. public:
  139.     OLEUIINSERTOBJECT m_io; // structure for OleUIInsertObject
  140.  
  141. // Constructors
  142.     COleInsertDialog(DWORD dwFlags = IOF_SELECTCREATENEW,
  143.         CWnd* pParentWnd = NULL);
  144.  
  145. // Operations
  146.     virtual int DoModal();
  147.     int DoModal(DWORD dwFlags);
  148.     BOOL CreateItem(COleClientItem* pItem);
  149.         // call after DoModal to create item based on dialog data
  150.  
  151. // Attributes (after DoModal returns IDOK)
  152.     enum Selection { createNewItem, insertFromFile, linkToFile };
  153.     UINT GetSelectionType() const;
  154.         // return type of selection made
  155.  
  156.     CString GetPathName() const;  // return full path name
  157.     REFCLSID GetClassID() const;    // get class ID of new item
  158.  
  159.     DVASPECT GetDrawAspect() const;
  160.         // DVASPECT_CONTENT or DVASPECT_ICON
  161.     HGLOBAL GetIconicMetafile() const;
  162.         // returns HGLOBAL to METAFILEPICT struct with iconic data
  163.  
  164. // Implementation
  165. public:
  166.     virtual ~COleInsertDialog();
  167. #ifdef _DEBUG
  168.     virtual void Dump(CDumpContext& dc) const;
  169. #endif
  170.  
  171.     enum FilterFlags {
  172.         DocObjectsOnly = 1,
  173.         ControlsOnly = 2,
  174.     };
  175.  
  176. protected:
  177.     TCHAR m_szFileName[_MAX_PATH];
  178.         // contains full path name after return
  179.  
  180.     void AddClassIDToList(LPCLSID& lpList, int& nListCount,
  181.         int& nBufferLen, LPCLSID pNewID);
  182. };
  183.  
  184. /////////////////////////////////////////////////////////////////////////////
  185. // COleConvertDialog
  186.  
  187. class COleConvertDialog : public COleDialog
  188. {
  189.     DECLARE_DYNAMIC(COleConvertDialog)
  190.  
  191. // Attributes
  192. public:
  193.     OLEUICONVERT m_cv;  // structure for OleUIConvert
  194.  
  195. // Constructors
  196.     COleConvertDialog(COleClientItem* pItem,
  197.         DWORD dwFlags = CF_SELECTCONVERTTO, CLSID* pClassID = NULL,
  198.         CWnd* pParentWnd = NULL);
  199.  
  200. // Operations
  201.     virtual int DoModal();
  202.         // just display the dialog and collect convert info
  203.     BOOL DoConvert(COleClientItem* pItem);
  204.         // do the conversion on pItem (after DoModal == IDOK)
  205.  
  206. // Attributes (after DoModal returns IDOK)
  207.     enum Selection { noConversion, convertItem, activateAs };
  208.     UINT GetSelectionType() const;
  209.  
  210.     HGLOBAL GetIconicMetafile() const;  // will return NULL if same as before
  211.     REFCLSID GetClassID() const;    // get class ID to convert or activate as
  212.     DVASPECT GetDrawAspect() const; // get new draw aspect
  213.  
  214. // Implementation
  215. public:
  216.     virtual ~COleConvertDialog();
  217. #ifdef _DEBUG
  218.     virtual void Dump(CDumpContext& dc) const;
  219. #endif
  220. };
  221.  
  222. /////////////////////////////////////////////////////////////////////////////
  223. // COleChangeIconDialog
  224.  
  225. class COleChangeIconDialog : public COleDialog
  226. {
  227.     DECLARE_DYNAMIC(COleChangeIconDialog)
  228.  
  229. // Attributes
  230. public:
  231.     OLEUICHANGEICON m_ci;   // structure for OleUIChangeIcon
  232.  
  233. // Constructors
  234.     COleChangeIconDialog(COleClientItem* pItem,
  235.         DWORD dwFlags = CIF_SELECTCURRENT,
  236.         CWnd* pParentWnd = NULL);
  237.  
  238. // Operations
  239.     virtual int DoModal();
  240.     BOOL DoChangeIcon(COleClientItem* pItem);
  241.  
  242. // Attributes
  243.     HGLOBAL GetIconicMetafile() const;
  244.  
  245. // Implementation
  246. public:
  247.     virtual ~COleChangeIconDialog();
  248. #ifdef _DEBUG
  249.     virtual void Dump(CDumpContext& dc) const;
  250. #endif
  251. };
  252.  
  253. /////////////////////////////////////////////////////////////////////////////
  254. // COlePasteSpecialDialog
  255.  
  256. class COlePasteSpecialDialog : public COleDialog
  257. {
  258.     DECLARE_DYNAMIC(COlePasteSpecialDialog)
  259.  
  260. // Attributes
  261. public:
  262.     OLEUIPASTESPECIAL m_ps; // structure for OleUIPasteSpecial
  263.  
  264. // Constructors
  265.     COlePasteSpecialDialog(DWORD dwFlags = PSF_SELECTPASTE,
  266.         COleDataObject* pDataObject = NULL, CWnd *pParentWnd = NULL);
  267.  
  268. // Operations
  269.     OLEUIPASTEFLAG AddLinkEntry(UINT cf);
  270.     void AddFormat(const FORMATETC& formatEtc, LPTSTR lpszFormat,
  271.         LPTSTR lpszResult, DWORD flags);
  272.     void AddFormat(UINT cf, DWORD tymed, UINT nFormatID, BOOL bEnableIcon,
  273.         BOOL bLink);
  274.     void AddStandardFormats(BOOL bEnableLink = TRUE);
  275.  
  276.     virtual int DoModal();
  277.     BOOL CreateItem(COleClientItem *pNewItem);
  278.         // creates a standard OLE item from selection data
  279.  
  280. // Attributes (after DoModal returns IDOK)
  281.     int GetPasteIndex() const;      // resulting index to use for paste
  282.  
  283.     enum Selection { pasteLink = 1, pasteNormal = 2, pasteStatic = 3, pasteOther = 4};
  284.     UINT GetSelectionType() const;
  285.         // get selection type (pasteLink, pasteNormal, pasteStatic)
  286.  
  287.     DVASPECT GetDrawAspect() const;
  288.         // DVASPECT_CONTENT or DVASPECT_ICON
  289.     HGLOBAL GetIconicMetafile() const;
  290.         // returns HGLOBAL to METAFILEPICT struct with iconic data
  291.  
  292. // Implementation
  293. public:
  294.     virtual ~COlePasteSpecialDialog();
  295. #ifdef _DEBUG
  296.     virtual void Dump(CDumpContext& dc) const;
  297.     virtual void AssertValid() const;
  298. #endif
  299.     unsigned int m_arrLinkTypes[8];
  300.         // size limit imposed by MFCUIx32.DLL library
  301. };
  302.  
  303. /////////////////////////////////////////////////////////////////////////////
  304. // COleLinksDialog
  305.  
  306. class COleLinksDialog : public COleDialog
  307. {
  308.     DECLARE_DYNAMIC(COleLinksDialog)
  309.  
  310. // Attributes
  311. public:
  312.     OLEUIEDITLINKS m_el;    // structure for OleUIEditLinks
  313.  
  314. // Constructors
  315.     COleLinksDialog(COleDocument* pDoc, CView* pView, DWORD dwFlags = 0,
  316.         CWnd* pParentWnd = NULL);
  317.  
  318. // Operations
  319.     virtual int DoModal();  // display the dialog and edit links
  320.  
  321. // Implementation
  322. public:
  323.     virtual ~COleLinksDialog();
  324. #ifdef _DEBUG
  325.     virtual void Dump(CDumpContext& dc) const;
  326.     virtual void AssertValid() const;
  327. #endif
  328.  
  329. public:
  330.     COleUILinkInfo m_xLinkInfo; // implements IOleUILinkContainer
  331. };
  332.  
  333. /////////////////////////////////////////////////////////////////////////////
  334. // COleUpdateDialog
  335.  
  336. class COleUpdateDialog : public COleLinksDialog
  337. {
  338.     DECLARE_DYNAMIC(COleUpdateDialog)
  339.  
  340. // Constructors
  341. public:
  342.     COleUpdateDialog(COleDocument* pDoc,
  343.         BOOL bUpdateLinks = TRUE, BOOL bUpdateEmbeddings = FALSE,
  344.         CWnd* pParentWnd = NULL);
  345.  
  346. // Operations
  347.     virtual int DoModal();
  348.  
  349. // Implementation
  350. public:
  351.     virtual ~COleUpdateDialog();
  352. #ifdef _DEBUG
  353.     virtual void Dump(CDumpContext& dc) const;
  354. #endif
  355.  
  356. protected:
  357.     CString m_strCaption;   // caption for the dialog
  358. };
  359.  
  360. /////////////////////////////////////////////////////////////////////////////
  361. // COleBusyDialog - useful in managing concurrency
  362.  
  363. class COleBusyDialog : public COleDialog
  364. {
  365.     DECLARE_DYNAMIC(COleBusyDialog)
  366.  
  367. // Attributes
  368. public:
  369.     OLEUIBUSY m_bz;
  370.  
  371. // Constructors
  372.     COleBusyDialog(HTASK htaskBusy, BOOL bNotResponding = FALSE,
  373.         DWORD dwFlags = 0, CWnd* pParentWnd = NULL);
  374.  
  375. // Operations
  376.     virtual int DoModal();
  377.  
  378.     enum Selection { switchTo = 1, retry = 2, callUnblocked = 3 };
  379.     UINT GetSelectionType() const;
  380.  
  381. // Implementation
  382. public:
  383.     ~COleBusyDialog();
  384. #ifdef _DEBUG
  385.     virtual void Dump(CDumpContext& dc) const;
  386. #endif
  387.  
  388. protected:
  389.     Selection m_selection;  // selection after DoModal returns IDOK
  390. };
  391.  
  392. /////////////////////////////////////////////////////////////////////////////
  393. // COleEditProperties
  394.  
  395. class COlePropertiesDialog : public COleDialog
  396. {
  397.     DECLARE_DYNAMIC(COlePropertiesDialog)
  398.  
  399. // Attributes
  400. public:
  401.     OLEUIOBJECTPROPS m_op;      // structure for OleUIObjectProperties
  402.     OLEUIGNRLPROPS m_gp;        // specific to "General" page
  403.     OLEUIVIEWPROPS m_vp;        // specific to "View" page
  404.     OLEUILINKPROPS m_lp;        // specific to "Link" page
  405.     PROPSHEETHEADER m_psh;      // PROPSHEETHEADER for customization
  406.  
  407. // Constructors
  408. public:
  409.     COlePropertiesDialog(COleClientItem* pItem,
  410.         UINT nScaleMin = 10, UINT nScaleMax = 500, CWnd* pParentWnd = NULL);
  411.  
  412. // Operations
  413.     virtual int DoModal();
  414.  
  415. // Overridables
  416.     virtual BOOL OnApplyScale(
  417.         COleClientItem* pItem, int nCurrentScale, BOOL bRelativeToOrig);
  418.  
  419. // Implementation
  420. public:
  421. #ifdef _DEBUG
  422.     virtual void Dump(CDumpContext& dc) const;
  423.     virtual void AssertValid() const;
  424. #endif
  425.     virtual BOOL OnInitDialog();
  426.  
  427.     BEGIN_INTERFACE_PART(OleUIObjInfo, IOleUIObjInfo)
  428.         INIT_INTERFACE_PART(COlePropertiesDialog, OleUIObjInfo)
  429.         STDMETHOD(GetObjectInfo) (THIS_ DWORD dwObject,
  430.             DWORD* lpdwObjSize, LPTSTR* lplpszLabel,
  431.             LPTSTR* lplpszType, LPTSTR* lplpszShortType,
  432.             LPTSTR* lplpszLocation);
  433.         STDMETHOD(GetConvertInfo) (THIS_ DWORD dwObject,
  434.             CLSID* lpClassID, WORD* lpwFormat,
  435.             CLSID* lpConvertDefaultClassID,
  436.             LPCLSID* lplpClsidExclude, UINT* lpcClsidExclude);
  437.         STDMETHOD(ConvertObject) (THIS_ DWORD dwObject, REFCLSID clsidNew);
  438.         STDMETHOD(GetViewInfo) (THIS_ DWORD dwObject,
  439.             HGLOBAL* phMetaPict, DWORD* pdvAspect, int* pnCurrentScale);
  440.         STDMETHOD(SetViewInfo) (THIS_ DWORD dwObject,
  441.             HGLOBAL hMetaPict, DWORD dvAspect,
  442.             int nCurrentScale, BOOL bRelativeToOrig);
  443.     END_INTERFACE_PART(OleUIObjInfo)
  444.     COleUILinkInfo m_xLinkInfo; // implements IOleUILinkContainer
  445. };
  446.  
  447. /////////////////////////////////////////////////////////////////////////////
  448. // COleChangeSourceDialog
  449.  
  450. class COleChangeSourceDialog : public COleDialog
  451. {
  452.     DECLARE_DYNAMIC(COleChangeSourceDialog)
  453.  
  454. // Attributes
  455. public:
  456.     OLEUICHANGESOURCE m_cs; // structure for OleUIChangeSource
  457.  
  458. // Constructors
  459. public:
  460.     COleChangeSourceDialog(COleClientItem* pItem, CWnd* pParentWnd = NULL);
  461.  
  462. // Operations
  463.     virtual int DoModal();
  464.  
  465. // Attributes (after DoModal returns IDOK)
  466.     BOOL IsValidSource();
  467.     CString GetDisplayName();
  468.     CString GetFileName();
  469.     CString GetItemName();
  470.     CString GetFromPrefix();
  471.     CString GetToPrefix();
  472.  
  473. // Implementation
  474. public:
  475.     COleUILinkInfo m_xLinkInfo;
  476.  
  477.     virtual ~COleChangeSourceDialog();
  478. #ifdef _DEBUG
  479.     virtual void Dump(CDumpContext& dc) const;
  480.     virtual void AssertValid() const;
  481. #endif
  482.     virtual void PreInitDialog();
  483. };
  484.  
  485. /////////////////////////////////////////////////////////////////////////////
  486. // Inline function declarations
  487.  
  488. #ifdef _AFX_PACKING
  489. #pragma pack(pop)
  490. #endif
  491.  
  492. #ifdef _AFX_ENABLE_INLINES
  493. #define _AFXODLGS_INLINE AFX_INLINE
  494. #include <afxole.inl>
  495. #undef _AFXODLGS_INLINE
  496. #endif
  497.  
  498. #undef AFX_DATA
  499. #define AFX_DATA
  500.  
  501. #ifdef _AFX_MINREBUILD
  502. #pragma component(minrebuild, on)
  503. #endif
  504. #ifndef _AFX_FULLTYPEINFO
  505. #pragma component(mintypeinfo, off)
  506. #endif
  507.  
  508. #endif //__AFXODLGS_H__
  509.  
  510. /////////////////////////////////////////////////////////////////////////////
  511.