|
|
1.1 root 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 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: /////////////////////////////////////////////////////////////////////////////
15: // Classes declared in this file
16:
17: // CDialog
18: class CFindReplaceDialog; // Find/FindReplace dialogs
19: // class CModalDialog
20: class CFileDialog; // FileOpen/FileSaveAs dialogs
21: class CColorDialog; // Color picker dialog
22: class CFontDialog; // Font chooser dialog
23: class CPrintDialog; // Print/PrintSetup dialogs
24:
25:
26: /////////////////////////////////////////////////////////////////////////////
27: // Make sure 'afxwin.h' is included first
28:
29: #ifndef __AFXWIN_H__
30: #include "afxwin.h"
31: #endif
32:
33: extern "C" {
34: #include "commdlg.h" // common dialog APIs
35:
36: #ifndef _NTWIN
37: #include "print.h" // printer specific APIs (DEVMODE)
38: #endif
39: }
40: /////////////////////////////////////////////////////////////////////////////
41: // Standard dialogs using Windows 3.x dialog (COMMDLG.DLL must be on path)
42:
43: // CFileDialog - used for FileOpen... or FileSaveAs...
44: class CFileDialog : public CModalDialog
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 FAR PASCAL AFX_EXPORT _AfxCommDlgProc(HWND, UINT, UINT, LONG);
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: // CFontDialog - used to select a font
96: class CFontDialog : public CModalDialog
97: {
98: DECLARE_DYNAMIC(CFontDialog)
99:
100: public:
101: // Attributes
102: // font choosing parameter block
103: CHOOSEFONT m_cf;
104: LOGFONT m_lf;
105:
106: // Constructors
107: CFontDialog(LPLOGFONT lplfInitial = NULL,
108: DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
109: CDC* pdcPrinter = NULL,
110: CWnd* pParentWnd = NULL);
111:
112: // Operations
113: virtual int DoModal();
114:
115: // Retrieve the currently selected font while dialog is displayed
116: void GetCurrentFont(LPLOGFONT lplf);
117:
118: // Helpers for parsing information after successful return
119: CString GetFaceName() const; // return the face name of the font
120: CString GetStyleName() const; // return the style name of the font
121: int GetSize() const; // return the pt size of the font
122: COLORREF GetColor() const; // return the color of the font
123: int GetWeight() const; // return the chosen font weight
124: BOOL IsStrikeOut() const; // return TRUE if strikeout
125: BOOL IsUnderline() const; // return TRUE if underline
126: BOOL IsBold() const; // return TRUE if bold font
127: BOOL IsItalic() const; // return TRUE if italic font
128:
129: // Implementation
130:
131: #ifdef _DEBUG
132: public:
133: virtual void Dump(CDumpContext& dc) const;
134: #endif
135:
136: protected:
137: virtual void OnOK();
138: virtual void OnCancel();
139:
140: char m_szStyleName[64]; // contains style name after return
141: };
142:
143:
144:
145: // CColorDialog - used to select a color
146: class CColorDialog : public CModalDialog
147: {
148: DECLARE_DYNAMIC(CColorDialog)
149:
150: public:
151: // Attributes
152: // color picker parameter block
153: CHOOSECOLOR m_cc;
154:
155: // Constructors
156: CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0,
157: CWnd* pParentWnd = NULL);
158:
159: // Operations
160: virtual int DoModal();
161:
162: // Set the current color while dialog is displayed
163: void SetCurrentColor(COLORREF clr);
164:
165: // Helpers for parsing information after successful return
166: COLORREF GetColor() const;
167:
168: // Custom colors are held here and saved between calls
169: static COLORREF clrSavedCustom[16];
170:
171: // Overridable callbacks
172: protected:
173: friend UINT FAR PASCAL AFX_EXPORT _AfxCommDlgProc(HWND, UINT, UINT, LONG);
174: virtual BOOL OnColorOK(); // validate color
175:
176: // Implementation
177:
178: #ifdef _DEBUG
179: public:
180: virtual void Dump(CDumpContext& dc) const;
181: #endif
182:
183: protected:
184: virtual void OnOK();
185: virtual void OnCancel();
186: };
187:
188:
189: // CPrintDialog - used for Print... and PrintSetup...
190: class CPrintDialog : public CModalDialog
191: {
192: DECLARE_DYNAMIC(CPrintDialog)
193:
194: public:
195: // Attributes
196: // print dialog parameter block (note this is a reference)
197: PRINTDLG FAR& m_pd;
198:
199: // Constructors
200: CPrintDialog(BOOL bPrintSetupOnly, // FALSE for print dialog as well
201: DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS
202: | PD_HIDEPRINTTOFILE | PD_NOSELECTION,
203: CWnd* pParentWnd = NULL);
204:
205: // Operations
206: virtual int DoModal();
207:
208: // GetDefaults will not display a dialog but will get
209: // device defaults
210: BOOL GetDefaults();
211:
212: // Helpers for parsing information after successful return
213: int GetCopies() const; // num. copies requested
214: BOOL PrintCollate() const; // TRUE if collate checked
215: BOOL PrintSelection() const; // TRUE if printing selection
216: BOOL PrintAll() const; // TRUE if printing all pages
217: BOOL PrintRange() const; // TRUE if printing page range
218: int GetFromPage() const; // starting page if valid
219: int GetToPage() const; // starting page if valid
220: LPDEVMODE GetDevMode() const; // return DEVMODE
221: CString GetDriverName() const; // return driver name
222: CString GetDeviceName() const; // return device name
223: CString GetPortName() const; // return output port name
224: HDC GetPrinterDC() const; // return HDC (caller must delete)
225:
226: // Implementation
227:
228: #ifdef _DEBUG
229: public:
230: virtual void Dump(CDumpContext& dc) const;
231: #endif
232:
233: protected:
234: virtual void OnOK();
235: virtual void OnCancel();
236:
237: // The following handle the case of print setup... from the print dialog
238: CPrintDialog(PRINTDLG FAR& pdInit);
239: afx_msg void OnPrintSetup();
240: virtual CPrintDialog* AttachOnSetup();
241:
242: private:
243: PRINTDLG m_pdActual; // the Print/Print Setup need to share this
244:
245: DECLARE_MESSAGE_MAP()
246: };
247:
248: // Find/FindReplace modeless dialogs
249: class CFindReplaceDialog : public CDialog
250: {
251: DECLARE_DYNAMIC(CFindReplaceDialog)
252:
253: public:
254: // Attributes
255: FINDREPLACE m_fr;
256:
257: // Constructors
258: CFindReplaceDialog();
259: // NOTE: you must allocate these on the heap. If you do not,
260: // you must derive and override PostNcDestroy() and do not delete this.
261:
262: BOOL Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace
263: LPCSTR lpszFindWhat,
264: LPCSTR lpszReplaceWith = NULL,
265: DWORD dwFlags = FR_DOWN,
266: CWnd* pParentWnd = NULL);
267:
268: // find/replace parameter block
269: static CFindReplaceDialog* GetNotifier(LONG lParam);
270:
271: // Operations
272: // Helpers for parsing information after successful return
273: CString GetReplaceString() const;// get replacement string
274: CString GetFindString() const; // get find string
275: BOOL SearchDown() const; // TRUE if search down, FALSE is up
276: BOOL FindNext() const; // TRUE if command is find next
277: BOOL MatchCase() const; // TRUE if matching case
278: BOOL MatchWholeWord() const; // TRUE if matching whole words only
279: BOOL ReplaceCurrent() const; // TRUE if replacing current string
280: BOOL ReplaceAll() const; // TRUE if replacing all occurrences
281: BOOL IsTerminating() const; // TRUE if terminating dialog
282:
283: // Implementation
284: protected:
285: virtual void PostNcDestroy();
286:
287: #ifdef _DEBUG
288: public:
289: virtual void Dump(CDumpContext& dc) const;
290: #endif
291:
292: protected:
293: char m_szFindWhat[128];
294: char m_szReplaceWith[128];
295: };
296:
297:
298: // inline functions for classes in this file
299:
300: inline CString CFileDialog::GetPathName() const
301: { return m_ofn.lpstrFile; }
302: inline CString CFileDialog::GetFileExt() const
303: { if (m_ofn.nFileExtension == 0) return (char)'\0';
304: else return m_ofn.lpstrFile + m_ofn.nFileExtension; }
305: inline CString CFileDialog::GetFileTitle() const
306: { return m_ofn.lpstrFileTitle; }
307: inline BOOL CFileDialog::GetReadOnlyPref() const
308: { return m_ofn.Flags & OFN_READONLY ? TRUE : FALSE; }
309: inline void CFontDialog::GetCurrentFont(LPLOGFONT lplf)
310: { ASSERT(m_hWnd != NULL); this->SendMessage(WM_CHOOSEFONT_GETLOGFONT,
311: 0, (DWORD)(LPSTR)lplf); }
312: inline CString CFontDialog::GetFaceName() const
313: { return (PSTR)m_cf.lpLogFont->lfFaceName; } //REVIEW: NT cast
314: inline CString CFontDialog::GetStyleName() const
315: { return m_cf.lpszStyle; }
316: inline int CFontDialog::GetSize() const
317: { return m_cf.iPointSize; }
318: inline int CFontDialog::GetWeight() const
319: { return m_cf.lpLogFont->lfWeight; }
320: inline BOOL CFontDialog::IsItalic() const
321: { return m_cf.lpLogFont->lfItalic ? TRUE : FALSE; }
322: inline BOOL CFontDialog::IsStrikeOut() const
323: { return m_cf.lpLogFont->lfStrikeOut ? TRUE : FALSE; }
324: inline BOOL CFontDialog::IsBold() const
325: { return m_cf.lpLogFont->lfWeight == FW_BOLD ? TRUE : FALSE; }
326: inline BOOL CFontDialog::IsUnderline() const
327: { return m_cf.lpLogFont->lfUnderline ? TRUE : FALSE; }
328: inline COLORREF CFontDialog::GetColor() const
329: { return m_cf.rgbColors; }
330: inline COLORREF CColorDialog::GetColor() const
331: { return m_cc.rgbResult; }
332: inline BOOL CPrintDialog::GetDefaults()
333: { m_pd.Flags |= PD_RETURNDEFAULT;
334: return ::PrintDlg(&m_pd); }
335: inline BOOL CPrintDialog::PrintSelection() const
336: { return m_pd.Flags & PD_SELECTION ? TRUE : FALSE; }
337: inline BOOL CPrintDialog::PrintRange() const
338: { return m_pd.Flags & PD_PAGENUMS ? TRUE : FALSE; }
339: inline BOOL CPrintDialog::PrintAll() const
340: { return !PrintRange() && !PrintSelection() ? TRUE : FALSE; }
341: inline BOOL CPrintDialog::PrintCollate() const
342: { return m_pd.Flags & PD_COLLATE ? TRUE : FALSE; }
343: inline int CPrintDialog::GetFromPage() const
344: { return (PrintRange() ? m_pd.nFromPage :-1); }
345: inline int CPrintDialog::GetToPage() const
346: { return (PrintRange() ? m_pd.nToPage :-1); }
347: inline LPDEVMODE CPrintDialog::GetDevMode() const
348: { return (LPDEVMODE)::GlobalLock(m_pd.hDevMode); }
349: inline CString CPrintDialog::GetDriverName() const
350: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
351: return (LPSTR)(lpDev) + (UINT)(lpDev->wDriverOffset); }
352: inline CString CPrintDialog::GetDeviceName() const
353: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
354: return (LPSTR)(lpDev) + (UINT)(lpDev->wDeviceOffset); }
355: inline CString CPrintDialog::GetPortName() const
356: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
357: return (LPSTR)(lpDev) + (UINT)(lpDev->wOutputOffset); }
358: inline BOOL CFindReplaceDialog::IsTerminating() const
359: { return m_fr.Flags & FR_DIALOGTERM ? TRUE : FALSE ; }
360: inline CString CFindReplaceDialog::GetReplaceString() const
361: { return m_fr.lpstrReplaceWith; }
362: inline CString CFindReplaceDialog::GetFindString() const
363: { return m_fr.lpstrFindWhat; }
364: inline BOOL CFindReplaceDialog::SearchDown() const
365: { return m_fr.Flags & FR_DOWN ? TRUE : FALSE; }
366: inline BOOL CFindReplaceDialog::FindNext() const
367: { return m_fr.Flags & FR_FINDNEXT ? TRUE : FALSE; }
368: inline BOOL CFindReplaceDialog::MatchCase() const
369: { return m_fr.Flags & FR_MATCHCASE ? TRUE : FALSE; }
370: inline BOOL CFindReplaceDialog::MatchWholeWord() const
371: { return m_fr.Flags & FR_WHOLEWORD ? TRUE : FALSE; }
372: inline BOOL CFindReplaceDialog::ReplaceCurrent() const
373: { return m_fr. Flags & FR_REPLACE ? TRUE : FALSE; }
374: inline BOOL CFindReplaceDialog::ReplaceAll() const
375: { return m_fr.Flags & FR_REPLACEALL ? TRUE : FALSE; }
376:
377: #endif //__AFXDLGS_H__
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.