home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / INCLUDE / AFXDLGS.H_ / AFXDLGS.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  10.0 KB  |  343 lines

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 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 Microsoft
  7. // QuickHelp and/or WinHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXDLGS_H__
  12. #define __AFXDLGS_H__
  13.  
  14. #ifndef __AFXWIN_H__
  15. #include "afxwin.h"
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // AFXDLGS - MFC Standard dialogs
  20.  
  21. // Classes declared in this file
  22.  
  23.         // CDialog
  24.             // modeless dialogs
  25.             class CFindReplaceDialog; // Find/FindReplace dialog
  26.             // modal dialogs
  27.             class CFileDialog;    // FileOpen/FileSaveAs dialogs
  28.             class CColorDialog;   // Color picker dialog
  29.             class CFontDialog;    // Font chooser dialog
  30.             class CPrintDialog;   // Print/PrintSetup dialogs
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33.  
  34. #include "commdlg.h"    // common dialog APIs
  35. #include "print.h"      // printer specific APIs (DEVMODE)
  36.  
  37. // AFXDLL support
  38. #undef AFXAPP_DATA
  39. #define AFXAPP_DATA     AFXAPI_DATA
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CFileDialog - used for FileOpen... or FileSaveAs...
  43.  
  44. class CFileDialog : public CDialog
  45. {
  46.     DECLARE_DYNAMIC(CFileDialog)
  47.  
  48. public:
  49. // Attributes
  50.     // open file parameter block
  51.     OPENFILENAME m_ofn;
  52.  
  53. // Constructors
  54.     CFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
  55.         LPCSTR lpszDefExt = NULL,
  56.         LPCSTR lpszFileName = NULL,
  57.         DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  58.         LPCSTR lpszFilter = NULL,
  59.         CWnd* pParentWnd = NULL);
  60.  
  61. // Operations
  62.     virtual int DoModal();
  63.  
  64.     // Helpers for parsing file name after successful return
  65.     CString GetPathName() const;  // return full path name
  66.     CString GetFileName() const;  // return only filename
  67.     CString GetFileExt() const;   // return only ext
  68.     CString GetFileTitle() const; // return file title
  69.     BOOL GetReadOnlyPref() const; // return TRUE if readonly checked
  70.  
  71. // Overridable callbacks
  72. protected:
  73.     friend UINT CALLBACK AFX_EXPORT _AfxCommDlgProc(HWND, UINT, WPARAM, LPARAM);
  74.     virtual UINT OnShareViolation(LPCSTR lpszPathName);
  75.     virtual BOOL OnFileNameOK();
  76.     virtual void OnLBSelChangedNotify(UINT nIDBox, UINT iCurSel, UINT nCode);
  77.  
  78. // Implementation
  79. #ifdef _DEBUG
  80. public:
  81.     virtual void Dump(CDumpContext& dc) const;
  82. #endif
  83.  
  84. protected:
  85.     virtual void OnOK();
  86.     virtual void OnCancel();
  87.  
  88.     BOOL m_bOpenFileDialog;       // TRUE for file open, FALSE for file save
  89.     CString m_strFilter;          // filter string
  90.                         // separate fields with '|', terminate with '||\0'
  91.     char m_szFileTitle[64];       // contains file title after return
  92.     char m_szFileName[_MAX_PATH]; // contains full path name after return
  93. };
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CFontDialog - used to select a font
  97.  
  98. class CFontDialog : public CDialog
  99. {
  100.     DECLARE_DYNAMIC(CFontDialog)
  101.  
  102. public:
  103. // Attributes
  104.     // font choosing parameter block
  105.     CHOOSEFONT m_cf;
  106.  
  107. // Constructors
  108.     CFontDialog(LPLOGFONT lplfInitial = NULL,
  109.         DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
  110.         CDC* pdcPrinter = NULL,
  111.         CWnd* pParentWnd = NULL);
  112.  
  113. // Operations
  114.     virtual int DoModal();
  115.  
  116.     // Retrieve the currently selected font while dialog is displayed
  117.     void GetCurrentFont(LPLOGFONT lplf);
  118.  
  119.     // Helpers for parsing information after successful return
  120.     CString GetFaceName() const;  // return the face name of the font
  121.     CString GetStyleName() const; // return the style name of the font
  122.     int GetSize() const;          // return the pt size of the font
  123.     COLORREF GetColor() const;    // return the color of the font
  124.     int GetWeight() const;        // return the chosen font weight
  125.     BOOL IsStrikeOut() const;     // return TRUE if strikeout
  126.     BOOL IsUnderline() const;     // return TRUE if underline
  127.     BOOL IsBold() const;          // return TRUE if bold font
  128.     BOOL IsItalic() const;        // return TRUE if italic font
  129.  
  130. // Implementation
  131.     LOGFONT m_lf; // default LOGFONT to store the info
  132.  
  133. #ifdef _DEBUG
  134. public:
  135.     virtual void Dump(CDumpContext& dc) const;
  136. #endif
  137.  
  138. protected:
  139.     virtual void OnOK();
  140.     virtual void OnCancel();
  141.  
  142.     char m_szStyleName[64]; // contains style name after return
  143. };
  144.  
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CColorDialog - used to select a color
  148.  
  149. class CColorDialog : public CDialog
  150. {
  151.     DECLARE_DYNAMIC(CColorDialog)
  152.  
  153. public:
  154. // Attributes
  155.     // color chooser parameter block
  156.     CHOOSECOLOR m_cc;
  157.  
  158. // Constructors
  159.     CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0,
  160.             CWnd* pParentWnd = NULL);
  161.  
  162. // Operations
  163.     virtual int DoModal();
  164.  
  165.     // Set the current color while dialog is displayed
  166.     void SetCurrentColor(COLORREF clr);
  167.  
  168.     // Helpers for parsing information after successful return
  169.     COLORREF GetColor() const;
  170.  
  171.     // Custom colors are held here and saved between calls
  172.     static COLORREF AFXAPI_DATA clrSavedCustom[16];
  173.  
  174. // Overridable callbacks
  175. protected:
  176.     friend UINT CALLBACK AFX_EXPORT _AfxCommDlgProc(HWND, UINT, WPARAM, LPARAM);
  177.     virtual BOOL OnColorOK();       // validate color
  178.  
  179. // Implementation
  180.  
  181. #ifdef _DEBUG
  182. public:
  183.     virtual void Dump(CDumpContext& dc) const;
  184. #endif
  185.  
  186. protected:
  187.     virtual void OnOK();
  188.     virtual void OnCancel();
  189.  
  190.     //{{AFX_MSG(CColorDialog)
  191.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  192.     //}}AFX_MSG
  193.     DECLARE_MESSAGE_MAP()
  194. };
  195.  
  196.  
  197. /////////////////////////////////////////////////////////////////////////////
  198. // CPrintDialog - used for Print... and PrintSetup...
  199.  
  200. class CPrintDialog : public CDialog
  201. {
  202.     DECLARE_DYNAMIC(CPrintDialog)
  203.  
  204. public:
  205. // Attributes
  206.     // print dialog parameter block (note this is a reference)
  207. #ifdef AFX_CLASS_MODEL
  208.     PRINTDLG FAR& m_pd;
  209. #else
  210.     PRINTDLG& m_pd;
  211. #endif
  212.  
  213. // Constructors
  214.     CPrintDialog(BOOL bPrintSetupOnly,
  215.         // TRUE for Print Setup, FALSE for Print Dialog
  216.         DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS
  217.             | PD_HIDEPRINTTOFILE | PD_NOSELECTION,
  218.         CWnd* pParentWnd = NULL);
  219.  
  220. // Operations
  221.     virtual int DoModal();
  222.  
  223.     // GetDefaults will not display a dialog but will get
  224.     // device defaults
  225.     BOOL GetDefaults();
  226.  
  227.     // Helpers for parsing information after successful return
  228.     int GetCopies() const;          // num. copies requested
  229.     BOOL PrintCollate() const;      // TRUE if collate checked
  230.     BOOL PrintSelection() const;    // TRUE if printing selection
  231.     BOOL PrintAll() const;          // TRUE if printing all pages
  232.     BOOL PrintRange() const;        // TRUE if printing page range
  233.     int GetFromPage() const;        // starting page if valid
  234.     int GetToPage() const;          // starting page if valid
  235.     LPDEVMODE GetDevMode() const;   // return DEVMODE
  236.     CString GetDriverName() const;  // return driver name
  237.     CString GetDeviceName() const;  // return device name
  238.     CString GetPortName() const;    // return output port name
  239.     HDC GetPrinterDC() const;       // return HDC (caller must delete)
  240.  
  241.     // This helper creates a DC based on the DEVNAMES and DEVMODE structures.
  242.     // This DC is returned, but also stored in m_pd.hDC as though it had been
  243.     // returned by CommDlg.  It is assumed that any previously obtained DC
  244.     // has been/will be deleted by the user.  This may be
  245.     // used without ever invoking the print/print setup dialogs.
  246.  
  247.     HDC CreatePrinterDC();
  248.  
  249. // Implementation
  250.  
  251. #ifdef _DEBUG
  252. public:
  253.     virtual void Dump(CDumpContext& dc) const;
  254. #endif
  255.  
  256. private:
  257.     PRINTDLG m_pdActual; // the Print/Print Setup need to share this
  258. protected:
  259.     virtual void OnOK();
  260.     virtual void OnCancel();
  261.  
  262.     // The following handle the case of print setup... from the print dialog
  263. #ifdef AFX_CLASS_MODEL
  264.     CPrintDialog(PRINTDLG FAR& pdInit);
  265. #else
  266.     CPrintDialog(PRINTDLG& pdInit);
  267. #endif
  268.     virtual CPrintDialog* AttachOnSetup();
  269.  
  270.     //{{AFX_MSG(CPrintDialog)
  271.     afx_msg void OnPrintSetup();
  272.     //}}AFX_MSG
  273.  
  274.     DECLARE_MESSAGE_MAP()
  275. };
  276.  
  277. /////////////////////////////////////////////////////////////////////////////
  278. // Find/FindReplace modeless dialogs
  279.  
  280. class CFindReplaceDialog : public CDialog
  281. {
  282.     DECLARE_DYNAMIC(CFindReplaceDialog)
  283.  
  284. public:
  285. // Attributes
  286.     FINDREPLACE m_fr;
  287.  
  288. // Constructors
  289.     CFindReplaceDialog();
  290.     // NOTE: you must allocate these on the heap.
  291.     // If you do not, you must derive and override PostNcDestroy()
  292.  
  293.     BOOL Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace
  294.             LPCSTR lpszFindWhat,
  295.             LPCSTR lpszReplaceWith = NULL,
  296.             DWORD dwFlags = FR_DOWN,
  297.             CWnd* pParentWnd = NULL);
  298.  
  299.     // find/replace parameter block
  300.     static CFindReplaceDialog* PASCAL GetNotifier(LPARAM lParam);
  301.  
  302. // Operations
  303.     // Helpers for parsing information after successful return
  304.     CString GetReplaceString() const;// get replacement string
  305.     CString GetFindString() const;   // get find string
  306.     BOOL SearchDown() const;         // TRUE if search down, FALSE is up
  307.     BOOL FindNext() const;           // TRUE if command is find next
  308.     BOOL MatchCase() const;          // TRUE if matching case
  309.     BOOL MatchWholeWord() const;     // TRUE if matching whole words only
  310.     BOOL ReplaceCurrent() const;     // TRUE if replacing current string
  311.     BOOL ReplaceAll() const;         // TRUE if replacing all occurrences
  312.     BOOL IsTerminating() const;      // TRUE if terminating dialog
  313.  
  314. // Implementation
  315. protected:
  316.     virtual void OnOK();
  317.     virtual void OnCancel();
  318.     virtual void PostNcDestroy();
  319.  
  320. #ifdef _DEBUG
  321. public:
  322.     virtual void Dump(CDumpContext& dc) const;
  323. #endif
  324.  
  325. protected:
  326.     char m_szFindWhat[128];
  327.     char m_szReplaceWith[128];
  328. };
  329.  
  330. /////////////////////////////////////////////////////////////////////////////
  331. // Inline function declarations
  332.  
  333. #ifdef _AFX_ENABLE_INLINES
  334. #define _AFXDLGS_INLINE inline
  335. #include "afxdlgs.inl"
  336. #endif
  337.  
  338. #undef AFXAPP_DATA
  339. #define AFXAPP_DATA     NEAR
  340.  
  341. /////////////////////////////////////////////////////////////////////////////
  342. #endif //__AFXDLGS_H__
  343.