home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / CTLIMPL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  20.6 KB  |  723 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1997 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 __CTLIMPL_H__
  12. #define __CTLIMPL_H__
  13.  
  14. // MFC data definition for data exported from the runtime DLL
  15.  
  16. #undef AFX_DATA
  17. #define AFX_DATA AFX_OLE_DATA
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // Codes for COleControl::SendAdvise
  21. //......Code.........................Method called
  22. #define OBJECTCODE_SAVED          0  //IOleAdviseHolder::SendOnSave
  23. #define OBJECTCODE_CLOSED         1  //IOleAdviseHolder::SendOnClose
  24. #define OBJECTCODE_RENAMED        2  //IOleAdviseHolder::SendOnRename
  25. #define OBJECTCODE_SAVEOBJECT     3  //IOleClientSite::SaveObject
  26. #define OBJECTCODE_DATACHANGED    4  //IDataAdviseHolder::SendOnDataChange
  27. #define OBJECTCODE_SHOWWINDOW     5  //IOleClientSite::OnShowWindow(TRUE)
  28. #define OBJECTCODE_HIDEWINDOW     6  //IOleClientSite::OnShowWindow(FALSE)
  29. #define OBJECTCODE_SHOWOBJECT     7  //IOleClientSite::ShowObject
  30. #define OBJECTCODE_VIEWCHANGED    8  //IOleAdviseHolder::SendOnViewChange
  31.  
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Typedefs
  35.  
  36. typedef LPVOID* LPLPVOID;
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // Functions
  40.  
  41. LPSTREAM AFXAPI _AfxGetArchiveStream(CArchive& ar, CArchiveStream& stm);
  42. CLIPFORMAT AFXAPI _AfxGetClipboardFormatConvertVBX();
  43. CLIPFORMAT AFXAPI _AfxGetClipboardFormatPersistPropset();
  44. BOOL AFXAPI _AfxOleMatchPropsetClipFormat(CLIPFORMAT cfFormat, LPCLSID lpFmtID);
  45. BOOL AFXAPI _AfxCopyPropValue(VARTYPE vtProp, void* pvDest, const void * pvSrc);
  46. BOOL AFXAPI _AfxPeekAtClassIDInStream(LPSTREAM pstm, LPCLSID lpClassID);
  47. BOOL AFXAPI _AfxIsSamePropValue(VARTYPE vtProp, const void* pv1, const void* pv2);
  48. BOOL AFXAPI _AfxIsSameFont(CFontHolder& font, const FONTDESC* pFontDesc,
  49.     LPFONTDISP pFontDispAmbient);
  50. BOOL AFXAPI _AfxIsSameUnknownObject(REFIID iid, LPUNKNOWN pUnk1, LPUNKNOWN pUnk2);
  51. BOOL AFXAPI _AfxInitBlob(HGLOBAL* phDst, void* pvSrc);
  52. BOOL AFXAPI _AfxCopyBlob(HGLOBAL* phDst, HGLOBAL hSrc);
  53. LPFONT AFXAPI _AfxCreateFontFromStream(LPSTREAM);
  54. BOOL AFXAPI _AfxTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew);
  55. void AFXAPI _AfxXformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
  56. void AFXAPI _AfxXformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
  57. void AFXAPI _AfxDrawBorders(CDC* pDC, CRect& rc, BOOL bBorder, BOOL bClientEdge);
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // _AFXCTL_ADVISE_INFO - Information about an advise sink
  61.  
  62. struct _AFXCTL_ADVISE_INFO
  63. {
  64.     DWORD m_dwAspects;
  65.     DWORD m_dwAdvf;
  66.     LPADVISESINK m_pAdvSink;
  67.  
  68.     _AFXCTL_ADVISE_INFO() : m_dwAspects(0), m_dwAdvf(0), m_pAdvSink(NULL) {}
  69. };
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // _AFXCTL_AMBIENT_CACHE - cache of common ambient property values
  73.  
  74. class _AFXCTL_AMBIENT_CACHE : public CNoTrackObject
  75. {
  76. // Constructor
  77. public:
  78.     _AFXCTL_AMBIENT_CACHE();
  79.  
  80. // Attributes
  81.     BOOL m_bValid;
  82.     DWORD m_dwAmbientFlags;
  83.     OLE_COLOR m_colorFore;
  84.     OLE_COLOR m_colorBack;
  85.     IFont* m_pFont;
  86.     void* m_pReserved;
  87.     DWORD m_dwAppearance;
  88.  
  89. // Operations
  90.     void Cache(QACONTAINER* pQAContainer);
  91. };
  92.  
  93. EXTERN_THREAD_LOCAL(_AFXCTL_AMBIENT_CACHE, _afxAmbientCache)
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CControlFrameWnd - used for a control's "open" (non-in-place) state.
  97.  
  98. class CControlFrameWnd : public CWnd
  99. {
  100. public:
  101.     CControlFrameWnd(COleControl* pCtrl);
  102.     virtual BOOL Create(LPCTSTR pszTitle);
  103.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  104.  
  105. protected:
  106.     virtual void PostNcDestroy();
  107.  
  108.     COleControl* m_pCtrl;
  109.  
  110.     //{{AFX_MSG(CControlFrameWnd)
  111.     afx_msg void OnClose();
  112.     afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
  113.     //}}AFX_MSG
  114.     DECLARE_MESSAGE_MAP()
  115. };
  116.  
  117.  
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CReflectorWnd - reflects window messages to a subclassed control.
  120.  
  121. class CReflectorWnd : public CWnd
  122. {
  123. public:
  124.     CReflectorWnd() : m_pCtrl(NULL) { }
  125.  
  126.     BOOL Create(const CRect& rect, HWND hWndParent);
  127.     void SetControl(COleControl* pCtrl);
  128.  
  129. protected:
  130.     virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  131.     virtual void PostNcDestroy();
  132.  
  133.     COleControl* m_pCtrl;
  134. };
  135.  
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CParkingWnd - "parking space" for not-yet-activated subclassed controls
  139.  
  140. class CParkingWnd : public CWnd
  141. {
  142. public:
  143.     CParkingWnd()
  144.         { AfxDeferRegisterClass(AFX_WNDOLECONTROL_REG);
  145.           CreateEx(WS_EX_NOPARENTNOTIFY|WS_EX_TOOLWINDOW,
  146.             AFX_WNDOLECONTROL, NULL, WS_VISIBLE|WS_CHILD,
  147.             -1000, -1000, 1, 1, ::GetDesktopWindow(), 0); }
  148.     virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  149.  
  150. protected:
  151.     CMapPtrToPtr m_idMap;
  152. };
  153.  
  154.  
  155. /////////////////////////////////////////////////////////////////////////////
  156. //  Property sets
  157.  
  158. typedef struct tagSECTIONHEADER
  159. {
  160.     DWORD       cbSection ;
  161.     DWORD       cProperties ;  // Number of props.
  162. } SECTIONHEADER, *LPSECTIONHEADER ;
  163.  
  164. typedef struct tagPROPERTYIDOFFSET
  165. {
  166.     DWORD       propertyID;
  167.     DWORD       dwOffset;
  168. } PROPERTYIDOFFSET, *LPPROPERTYIDOFFSET;
  169.  
  170. typedef struct tagPROPHEADER
  171. {
  172.     WORD        wByteOrder ;    // Always 0xFFFE
  173.     WORD        wFormat ;       // Always 0
  174.     DWORD       dwOSVer ;       // System version
  175.     CLSID       clsID ;         // Application CLSID
  176.     DWORD       cSections ;     // Number of sections (must be at least 1)
  177. } PROPHEADER, *LPPROPHEADER ;
  178.  
  179. typedef struct tagFORMATIDOFFSET
  180. {
  181.     GUID        formatID;
  182.     DWORD       dwOffset;
  183. } FORMATIDOFFSET, *LPFORMATIDOFFSET;
  184.  
  185.  
  186. /////////////////////////////////////////////////////////////////////////////
  187. // CProperty
  188.  
  189. class CProperty
  190. {
  191.     friend class CPropertySet ;
  192.     friend class CPropertySection ;
  193.  
  194. public:
  195. // Construction
  196.     CProperty( void ) ;
  197.     CProperty( DWORD dwID, const LPVOID pValue, DWORD dwType ) ;
  198.  
  199. // Attributes
  200.     BOOL    Set( DWORD dwID, const LPVOID pValue, DWORD dwType ) ;
  201.     BOOL    Set( const LPVOID pValue, DWORD dwType ) ;
  202.     BOOL    Set( const LPVOID pValue ) ;
  203.     LPVOID  Get( DWORD* pcb ) ;     // Returns pointer to actual value
  204.     LPVOID  Get( void ) ;           // Returns pointer to actual value
  205.     DWORD   GetType( void ) ;       // Returns property type
  206.     void    SetType( DWORD dwType ) ;
  207.     DWORD   GetID( void ) ;
  208.     void    SetID( DWORD dwPropID ) ;
  209.  
  210.     LPVOID  GetRawValue( void ) ;   // Returns pointer internal value (may
  211.                                     // include size information)
  212. // Operations
  213.     BOOL    WriteToStream( IStream* pIStream ) ;
  214.     BOOL    ReadFromStream( IStream* pIStream ) ;
  215.  
  216. private:
  217.     DWORD       m_dwPropID ;
  218.     DWORD       m_dwType ;
  219.     LPVOID      m_pValue ;
  220.  
  221.     LPVOID  AllocValue(ULONG cb);
  222.     void    FreeValue();
  223.  
  224. public:
  225.     ~CProperty() ;
  226. } ;
  227.  
  228.  
  229. /////////////////////////////////////////////////////////////////////////////
  230. // CPropertySection
  231.  
  232. class CPropertySection
  233. {
  234.     friend class CPropertySet ;
  235.     friend class CProperty ;
  236.  
  237. public:
  238. // Construction
  239.     CPropertySection( void ) ;
  240.     CPropertySection( CLSID FormatID ) ;
  241.  
  242. // Attributes
  243.     CLSID   GetFormatID( void ) ;
  244.     void    SetFormatID( CLSID FormatID ) ;
  245.  
  246.     BOOL    Set( DWORD dwPropID, LPVOID pValue, DWORD dwType ) ;
  247.     BOOL    Set( DWORD dwPropID, LPVOID pValue ) ;
  248.     LPVOID  Get( DWORD dwPropID, DWORD* pcb ) ;
  249.     LPVOID  Get( DWORD dwPropID ) ;
  250.     void    Remove( DWORD dwPropID ) ;
  251.     void    RemoveAll() ;
  252.  
  253.     CProperty* GetProperty( DWORD dwPropID ) ;
  254.     void AddProperty( CProperty* pProp ) ;
  255.  
  256.     DWORD   GetSize( void ) ;
  257.     DWORD   GetCount( void ) ;
  258.     CPtrList* GetList( void ) ;
  259.  
  260.     BOOL    GetID( LPCTSTR pszName, DWORD* pdwPropID ) ;
  261.     BOOL    SetName( DWORD dwPropID, LPCTSTR pszName ) ;
  262.  
  263.     BOOL    SetSectionName( LPCTSTR pszName );
  264.     LPCTSTR GetSectionName( void );
  265.  
  266. // Operations
  267.     BOOL    WriteToStream( IStream* pIStream ) ;
  268.     BOOL    ReadFromStream( IStream* pIStream, LARGE_INTEGER liPropSet ) ;
  269.     BOOL    WriteNameDictToStream( IStream* pIStream ) ;
  270.     BOOL    ReadNameDictFromStream( IStream* pIStream ) ;
  271.  
  272. private:
  273. // Implementation
  274.     CLSID           m_FormatID ;
  275.     SECTIONHEADER   m_SH ;
  276.     // List of properties (CProperty)
  277.     CPtrList         m_PropList ;
  278.     // Dictionary of property names
  279.     CMapStringToPtr m_NameDict ;
  280.     CString         m_strSectionName;
  281.  
  282. public:
  283.     ~CPropertySection();
  284. } ;
  285.  
  286.  
  287. /////////////////////////////////////////////////////////////////////////////
  288. // CPropertySet
  289.  
  290. class CPropertySet
  291. {
  292.     friend class CPropertySection ;
  293.     friend class CProperty ;
  294.  
  295. public:
  296. // Construction
  297.     CPropertySet( void ) ;
  298.     CPropertySet( CLSID clsID )  ;
  299.  
  300. // Attributes
  301.     BOOL    Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue, DWORD dwType ) ;
  302.     BOOL    Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue ) ;
  303.     LPVOID  Get( CLSID FormatID, DWORD dwPropID, DWORD* pcb ) ;
  304.     LPVOID  Get( CLSID FormatID, DWORD dwPropID ) ;
  305.     void    Remove( CLSID FormatID, DWORD dwPropID ) ;
  306.     void    Remove( CLSID FormatID ) ;
  307.     void    RemoveAll( ) ;
  308.  
  309.     CProperty* GetProperty( CLSID FormatID, DWORD dwPropID ) ;
  310.     void AddProperty( CLSID FormatID, CProperty* pProp ) ;
  311.     CPropertySection* GetSection( CLSID FormatID ) ;
  312.     CPropertySection* AddSection( CLSID FormatID ) ;
  313.     void AddSection( CPropertySection* psect ) ;
  314.  
  315.     WORD    GetByteOrder( void ) ;
  316.     WORD    GetFormatVersion( void ) ;
  317.     void    SetFormatVersion( WORD wFmtVersion ) ;
  318.     DWORD   GetOSVersion( void ) ;
  319.     void    SetOSVersion( DWORD dwOSVer ) ;
  320.     CLSID   GetClassID( void ) ;
  321.     void    SetClassID( CLSID clsid ) ;
  322.     DWORD   GetCount( void ) ;
  323.     CPtrList* GetList( void ) ;
  324.  
  325. // Operations
  326.     BOOL    WriteToStream( IStream* pIStream ) ;
  327.     BOOL    ReadFromStream( IStream* pIStream ) ;
  328.  
  329. // Implementation
  330. private:
  331.     PROPHEADER      m_PH ;
  332.     CPtrList         m_SectionList ;
  333.  
  334. public:
  335.     ~CPropertySet();
  336. } ;
  337.  
  338.  
  339. /////////////////////////////////////////////////////////////////////////////
  340. // CArchivePropExchange - for persistence in an archive.
  341.  
  342. class CArchivePropExchange : public CPropExchange
  343. {
  344. // Constructors
  345. public:
  346.     CArchivePropExchange(CArchive& ar);
  347.  
  348. // Operations
  349.     virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
  350.                 void* pvProp, const void* pvDefault = NULL);
  351.     virtual BOOL ExchangeBlobProp(LPCTSTR pszPropName, HGLOBAL* phBlob,
  352.                 HGLOBAL hBlobDefault = NULL);
  353.     virtual BOOL ExchangeFontProp(LPCTSTR pszPropName, CFontHolder& font,
  354.                 const FONTDESC* pFontDesc, LPFONTDISP pFontDispAmbient);
  355.     virtual BOOL ExchangePersistentProp(LPCTSTR pszPropName,
  356.                 LPUNKNOWN* ppUnk, REFIID iid, LPUNKNOWN pUnkDefault);
  357.  
  358. // Implementation
  359. protected:
  360.     CArchive& m_ar;
  361. };
  362.  
  363.  
  364. /////////////////////////////////////////////////////////////////////////////
  365. // CResetPropExchange - for resetting property state to defaults.
  366.  
  367. class CResetPropExchange : public CPropExchange
  368. {
  369. // Constructors
  370. public:
  371.     CResetPropExchange(void);
  372.  
  373. // Operations
  374.     virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
  375.                 void* pvProp, const void* pvDefault = NULL);
  376.     virtual BOOL ExchangeBlobProp(LPCTSTR pszPropName, HGLOBAL* phBlob,
  377.                 HGLOBAL hBlobDefault = NULL);
  378.     virtual BOOL ExchangeFontProp(LPCTSTR pszPropName, CFontHolder& font,
  379.                 const FONTDESC* pFontDesc, LPFONTDISP pFontDispAmbient);
  380.     virtual BOOL ExchangePersistentProp(LPCTSTR pszPropName,
  381.                 LPUNKNOWN* ppUnk, REFIID iid, LPUNKNOWN pUnkDefault);
  382. };
  383.  
  384.  
  385. /////////////////////////////////////////////////////////////////////////////
  386. // CPropsetPropExchange - for persistence in a property set.
  387.  
  388. class CPropsetPropExchange : public CPropExchange
  389. {
  390. // Constructors
  391. public:
  392.     CPropsetPropExchange(CPropertySection& psec, LPSTORAGE lpStorage,
  393.         BOOL bLoading);
  394.  
  395. // Operations
  396.     virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
  397.                 void* pvProp, const void* pvDefault = NULL);
  398.     virtual BOOL ExchangeBlobProp(LPCTSTR pszPropName, HGLOBAL* phBlob,
  399.                 HGLOBAL hBlobDefault = NULL);
  400.     virtual BOOL ExchangeFontProp(LPCTSTR pszPropName, CFontHolder& font,
  401.                 const FONTDESC* pFontDesc, LPFONTDISP pFontDispAmbient);
  402.     virtual BOOL ExchangePersistentProp(LPCTSTR pszPropName,
  403.                 LPUNKNOWN* ppUnk, REFIID iid, LPUNKNOWN pUnkDefault);
  404.  
  405. // Implementation
  406.     CPropertySection& m_psec;
  407.     LPSTORAGE m_lpStorage;
  408.     DWORD m_dwPropID;
  409. };
  410.  
  411. /////////////////////////////////////////////////////////////////////////////
  412. // CAsyncPropExchange - for launching asynchronous downloads set.
  413.  
  414. class CAsyncPropExchange : public CPropExchange
  415. {
  416. // Constructors
  417. public:
  418.     CAsyncPropExchange(DWORD dwVersion);
  419.  
  420. // Operations
  421. public:
  422.     virtual BOOL ExchangeVersion(DWORD& dwVersionLoaded,
  423.         DWORD dwVersionDefault, BOOL bConvert);
  424.  
  425.     virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
  426.                 void* pvProp, const void* pvDefault = NULL);
  427.     virtual BOOL ExchangeBlobProp(LPCTSTR pszPropName, HGLOBAL* phBlob,
  428.                 HGLOBAL hBlobDefault = NULL);
  429.     virtual BOOL ExchangeFontProp(LPCTSTR pszPropName, CFontHolder& font,
  430.                 const FONTDESC* pFontDesc,
  431.                 LPFONTDISP pFontDispAmbient);
  432.     virtual BOOL ExchangePersistentProp(LPCTSTR pszPropName,
  433.                 LPUNKNOWN* ppUnk, REFIID iid, LPUNKNOWN pUnkDefault);
  434. };
  435.  
  436.  
  437. /////////////////////////////////////////////////////////////////////////////
  438. // COleDispatchExceptionEx - dispatch exception that includes an SCODE
  439.  
  440. class COleDispatchExceptionEx : public COleDispatchException
  441. {
  442. public:
  443.     COleDispatchExceptionEx(LPCTSTR lpszDescription, UINT nHelpID, SCODE sc);
  444. };
  445.  
  446. /////////////////////////////////////////////////////////////////////////////
  447. //  CStockPropPage
  448.  
  449. class CStockPropPage : public COlePropertyPage
  450. {
  451.     DECLARE_DYNAMIC(CStockPropPage)
  452.  
  453. // Constructor
  454. public:
  455.     CStockPropPage(UINT idDlg, UINT idCaption);
  456.  
  457. // Implementation
  458. protected:
  459.     void FillPropnameList(REFGUID guid, int nIndirect, CComboBox& combo);
  460.     void OnSelchangePropname(CComboBox& combo);
  461.     BOOL OnEditProperty(DISPID dispid, CComboBox& combo);
  462.  
  463.     LCID m_lcid;
  464.     CString m_strPropName;
  465.     int m_iPropName;
  466.  
  467.     DECLARE_MESSAGE_MAP()
  468. };
  469.  
  470. ///////////////////////////////////////////////////////////////////////////////
  471. // CColorButton: used by CColorPropPage
  472.  
  473. class CColorButton : public CButton
  474. {
  475. public:
  476.     CColorButton(void);
  477.     void SetFaceColor(COLORREF colFace);
  478.     COLORREF colGetFaceColor(void);
  479.     void SetState(BOOL fSelected);
  480.     static UINT idClicked;
  481. protected:
  482.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  483. private:
  484.     BOOL m_fSelected;
  485.     COLORREF m_colFace;
  486. };
  487.  
  488. /////////////////////////////////////////////////////////////////////////////
  489. // CColorPropPage
  490.  
  491. #define NB_COLORS   (16)
  492.  
  493. class CColorPropPage : public CStockPropPage
  494. {
  495.     DECLARE_DYNCREATE(CColorPropPage)
  496.     DECLARE_OLECREATE_EX(CColorPropPage)
  497.  
  498. // Construction
  499. public:
  500.     CColorPropPage();   // Constructor
  501.  
  502. // Dialog Data
  503.     //{{AFX_DATA(CColorPropPage)
  504.     enum { IDD = AFX_IDD_PROPPAGE_COLOR };
  505.     CComboBox   m_SysColors;
  506.     CComboBox   m_ColorProp;
  507.     //}}AFX_DATA
  508.  
  509. // Implementation
  510. protected:
  511.     virtual void DoDataExchange(CDataExchange* pDX);        // DDX/DDV support
  512.     virtual BOOL OnInitDialog(void);
  513.     virtual BOOL OnEditProperty(DISPID dispid);
  514.     virtual void OnObjectsChanged();
  515.     void FillSysColors();
  516.     BOOL SetColorProp(CDataExchange* pDX, COLORREF color, LPCTSTR pszPropName);
  517.     BOOL GetColorProp(CDataExchange* pDX, COLORREF* pcolor, LPCTSTR pszPropName);
  518.  
  519. private:
  520.     CColorButton m_Buttons[NB_COLORS];
  521.     CColorButton *m_pSelectedButton;
  522.  
  523.     void SetButton(CColorButton *Button);
  524.  
  525.     // Generated message map functions
  526.     //{{AFX_MSG(CColorPropPage)
  527.     afx_msg void OnSelchangeColorprop();
  528.     afx_msg void OnSelect(void);
  529.     afx_msg void OnSelchangeSystemcolors();
  530.     //}}AFX_MSG
  531.     DECLARE_MESSAGE_MAP()
  532. };
  533.  
  534. // Stores all the information about a font
  535. typedef struct tagFONTOBJECT
  536. {
  537.     CString strName;
  538.     CY  cySize;
  539.     BOOL bBold;
  540.     BOOL bItalic;
  541.     BOOL bUnderline;
  542.     BOOL bStrikethrough;
  543.     short sWeight;
  544. } FONTOBJECT;
  545.  
  546. // Merge objects are used when trying to consolidate multiple font properties.
  547. // If the characteristics of these multiple properties differ then this is
  548. // represented in the merge object.
  549. typedef struct tagMERGEOBJECT
  550. {
  551.     BOOL bNameOK;
  552.     BOOL bSizeOK;
  553.     BOOL bStyleOK;
  554.     BOOL bUnderlineOK;
  555.     BOOL bStrikethroughOK;
  556. } MERGEOBJECT;
  557.  
  558. /////////////////////////////////////////////////////////////////////////////
  559. // CSizeComboBox window
  560.  
  561. class CSizeComboBox : public CComboBox
  562. {
  563. // Operations
  564. public:
  565.     int AddSize(int PointSize, LONG lfHeight);
  566.  
  567.     void            GetPointSize(CY& cy);
  568.     LONG            GetHeight(int sel=-1);
  569.     void            UpdateLogFont( LPLOGFONT lpLF, int sel=-1 );
  570. };
  571.  
  572. /////////////////////////////////////////////////////////////////////////////
  573. // CFontComboBox window
  574.  
  575. struct FONTITEM_PPG
  576. {
  577.     DWORD dwFontType;
  578.     LOGFONT lf;
  579. };
  580.  
  581. class CFontComboBox : public CComboBox
  582. {
  583. // Construction
  584. public:
  585.     CFontComboBox();
  586.     virtual ~CFontComboBox();
  587.  
  588. // Operations
  589. public:
  590.     int AddFont(LOGFONT *, DWORD);
  591.     CString GetCurrentName();
  592.  
  593.     FONTITEM_PPG* GetFontItem(int sel=-1);
  594.     LPLOGFONT GetLogFont(int sel=-1);
  595.     DWORD GetFontType(int sel=-1);
  596.  
  597. // Implementation
  598. public:
  599.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
  600.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDIS);
  601.  
  602. protected:
  603.     CBitmap m_bmpTrueType;
  604.     CBitmap m_bmpMask;
  605. };
  606.  
  607. ///////////////////////////////////////////////////////////////////////////
  608. // CFontPropPage class
  609.  
  610. class CFontPropPage : public CStockPropPage
  611. {
  612.     DECLARE_DYNCREATE(CFontPropPage)
  613.     DECLARE_OLECREATE_EX(CFontPropPage)
  614.  
  615. public:
  616.     CFontPropPage();
  617.  
  618.     // Dialog Data
  619.     //{{AFX_DATA(CFontPropPage)
  620.     enum { IDD = AFX_IDD_PROPPAGE_FONT };
  621.     CComboBox   m_FontProp;
  622.     CStatic m_SampleBox;
  623.     CComboBox   m_FontStyles;
  624.     CSizeComboBox   m_FontSizes;
  625.     CFontComboBox   m_FontNames;
  626.     //}}AFX_DATA
  627.  
  628. // Attributes
  629. protected:
  630.     int nPixelsY;
  631.     CFont SampleFont;
  632.     DWORD m_nCurrentStyle;
  633.     DWORD m_nActualStyle;
  634.     DWORD m_nStyles;
  635.     BOOL m_bStrikeOut;
  636.     BOOL m_bUnderline;
  637.     CString m_strFontSize;
  638.  
  639. // Implementation
  640. protected:
  641.  
  642.     void FillFacenameList();
  643.     void FillSizeList();
  644.     virtual void DoDataExchange(CDataExchange* pDX);
  645.     virtual void OnPaint();
  646.     virtual BOOL OnEditProperty(DISPID dispid);
  647.     virtual void OnObjectsChanged();
  648.     void UpdateSampleFont();
  649.     void SelectFontFromList(CString strFaceName, MERGEOBJECT* pmobj);
  650.  
  651.     //{{AFX_MSG(CFontPropPage)
  652.     virtual BOOL OnInitDialog();
  653.     afx_msg void OnEditupdateFontnames();
  654.     afx_msg void OnEditupdateFontsizes();
  655.     afx_msg void OnSelchangeFontnames();
  656.     afx_msg void OnSelchangeFontsizes();
  657.     afx_msg void OnSelchangeFontstyles();
  658.     afx_msg void OnEditchangeFontstyles();
  659.     afx_msg void OnStrikeout();
  660.     afx_msg void OnUnderline();
  661.     afx_msg void OnSelchangeFontprop();
  662.     //}}AFX_MSG
  663.     DECLARE_MESSAGE_MAP()
  664.  
  665.     static int CALLBACK EnumFontFamiliesCallBack(ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm, int FontType, LPARAM lParam);
  666.     static int CALLBACK EnumFontFamiliesCallBack2(ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm, int FontType, LPARAM lParam);
  667.  
  668.     BOOL SetFontProps(CDataExchange* pDX, FONTOBJECT fobj, LPCTSTR pszPropName);
  669.     BOOL GetFontProps(CDataExchange* pDX, FONTOBJECT*  pfobj, LPCTSTR pszPropName, MERGEOBJECT* pmobj);
  670. };
  671.  
  672. ////////////////////////////////////////////////////////////////////////////
  673. //  CPicturePropPage
  674.  
  675. class CPicturePropPage : public CStockPropPage
  676. {
  677.     DECLARE_DYNCREATE(CPicturePropPage)
  678.     DECLARE_OLECREATE_EX(CPicturePropPage)
  679.  
  680. // Construction
  681. public:
  682.     CPicturePropPage(); // standard constructor
  683.     ~CPicturePropPage();
  684.  
  685. // Dialog Data
  686.     //{{AFX_DATA(CPicturePropPage)
  687.     enum { IDD = AFX_IDD_PROPPAGE_PICTURE };
  688.     CComboBox   m_PropName;
  689.     CStatic m_Static;
  690.     //}}AFX_DATA
  691.  
  692. // Implementation
  693. protected:
  694.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  695.     virtual BOOL OnInitDialog(void);
  696.     virtual BOOL OnEditProperty(DISPID dispid);
  697.     virtual void OnObjectsChanged();
  698.  
  699.     BOOL SetPictureProp(CDataExchange* pDX, LPPICTUREDISP pPictDisp, LPCTSTR pszPropName);
  700.     BOOL GetPictureProp(CDataExchange* pDX, LPPICTUREDISP* ppPictDisp, LPCTSTR pszPropName);
  701.     void ChangePicture(LPPICTURE pPict);
  702.  
  703.     LPPICTUREDISP m_pPictDisp;
  704.  
  705. // Generated message map functions
  706. protected:
  707.     //{{AFX_MSG(CPicturePropPage)
  708.     afx_msg void OnPaint();
  709.     afx_msg void OnBrowse();
  710.     afx_msg void OnClear();
  711.     afx_msg void OnSelchangePictProp();
  712.     //}}AFX_MSG
  713.     DECLARE_MESSAGE_MAP()
  714. };
  715.  
  716. /////////////////////////////////////////////////////////////////////////////
  717. // Reset MFC data definitions
  718.  
  719. #undef AFX_DATA
  720. #define AFX_DATA
  721.  
  722. #endif  //__CTLIMPL_H__
  723.