|
|
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: }
1.1.1.3 ! root 40:
1.1 root 41: /////////////////////////////////////////////////////////////////////////////
42: // Standard dialogs using Windows 3.x dialog (COMMDLG.DLL must be on path)
43:
44: // CFileDialog - used for FileOpen... or FileSaveAs...
45: class CFileDialog : public CModalDialog
46: {
47: DECLARE_DYNAMIC(CFileDialog)
48:
49: public:
50: // Attributes
51: // open file parameter block
52: OPENFILENAME m_ofn;
53:
54: // Constructors
55: CFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
56: LPCSTR lpszDefExt = NULL,
57: LPCSTR lpszFileName = NULL,
58: DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
59: LPCSTR lpszFilter = NULL,
60: CWnd* pParentWnd = NULL);
61:
62: // Operations
63: virtual int DoModal();
64:
65: // Helpers for parsing file name after successful return
66: CString GetPathName() const; // return full path name
67: CString GetFileName() const; // return only filename
68: CString GetFileExt() const; // return only ext
69: CString GetFileTitle() const; // return file title
70: BOOL GetReadOnlyPref() const; // return TRUE if readonly checked
71:
72: // Overridable callbacks
73: protected:
74: friend UINT FAR PASCAL AFX_EXPORT _AfxCommDlgProc(HWND, UINT, UINT, LONG);
75: virtual UINT OnShareViolation(LPCSTR lpszPathName);
76: virtual BOOL OnFileNameOK();
77: virtual void OnLBSelChangedNotify(UINT nIDBox, UINT iCurSel, UINT nCode);
78:
79: // Implementation
80: #ifdef _DEBUG
81: public:
82: virtual void Dump(CDumpContext& dc) const;
83: #endif
84:
85: protected:
86: virtual void OnOK();
87: virtual void OnCancel();
88:
89: BOOL m_bOpenFileDialog; // TRUE for file open, FALSE for file save
90: CString m_strFilter; // filter string
91: // separate fields with '|', terminate with '||\0'
92: char m_szFileTitle[64]; // contains file title after return
93: char m_szFileName[_MAX_PATH]; // contains full path name after return
94: };
95:
96: // CFontDialog - used to select a font
97: class CFontDialog : public CModalDialog
98: {
99: DECLARE_DYNAMIC(CFontDialog)
100:
101: public:
102: // Attributes
103: // font choosing parameter block
104: CHOOSEFONT m_cf;
105: LOGFONT m_lf;
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:
132: #ifdef _DEBUG
133: public:
134: virtual void Dump(CDumpContext& dc) const;
135: #endif
136:
137: protected:
138: virtual void OnOK();
139: virtual void OnCancel();
140:
141: char m_szStyleName[64]; // contains style name after return
142: };
143:
144:
145:
146: // CColorDialog - used to select a color
147: class CColorDialog : public CModalDialog
148: {
149: DECLARE_DYNAMIC(CColorDialog)
150:
151: public:
152: // Attributes
153: // color picker parameter block
154: CHOOSECOLOR m_cc;
155:
156: // Constructors
157: CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0,
158: CWnd* pParentWnd = NULL);
159:
160: // Operations
161: virtual int DoModal();
162:
163: // Set the current color while dialog is displayed
164: void SetCurrentColor(COLORREF clr);
165:
166: // Helpers for parsing information after successful return
167: COLORREF GetColor() const;
168:
169: // Custom colors are held here and saved between calls
170: static COLORREF clrSavedCustom[16];
171:
172: // Overridable callbacks
173: protected:
174: friend UINT FAR PASCAL AFX_EXPORT _AfxCommDlgProc(HWND, UINT, UINT, LONG);
175: virtual BOOL OnColorOK(); // validate color
176:
177: // Implementation
178:
179: #ifdef _DEBUG
180: public:
181: virtual void Dump(CDumpContext& dc) const;
182: #endif
183:
184: protected:
185: virtual void OnOK();
186: virtual void OnCancel();
187: };
188:
189:
190: // CPrintDialog - used for Print... and PrintSetup...
191: class CPrintDialog : public CModalDialog
192: {
193: DECLARE_DYNAMIC(CPrintDialog)
194:
195: public:
196: // Attributes
197: // print dialog parameter block (note this is a reference)
198: PRINTDLG FAR& m_pd;
199:
200: // Constructors
201: CPrintDialog(BOOL bPrintSetupOnly, // FALSE for print dialog as well
202: DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS
203: | PD_HIDEPRINTTOFILE | PD_NOSELECTION,
204: CWnd* pParentWnd = NULL);
205:
206: // Operations
207: virtual int DoModal();
208:
209: // GetDefaults will not display a dialog but will get
210: // device defaults
211: BOOL GetDefaults();
212:
213: // Helpers for parsing information after successful return
214: int GetCopies() const; // num. copies requested
215: BOOL PrintCollate() const; // TRUE if collate checked
216: BOOL PrintSelection() const; // TRUE if printing selection
217: BOOL PrintAll() const; // TRUE if printing all pages
218: BOOL PrintRange() const; // TRUE if printing page range
219: int GetFromPage() const; // starting page if valid
220: int GetToPage() const; // starting page if valid
221: LPDEVMODE GetDevMode() const; // return DEVMODE
222: CString GetDriverName() const; // return driver name
223: CString GetDeviceName() const; // return device name
224: CString GetPortName() const; // return output port name
225: HDC GetPrinterDC() const; // return HDC (caller must delete)
226:
227: // Implementation
228:
229: #ifdef _DEBUG
230: public:
231: virtual void Dump(CDumpContext& dc) const;
232: #endif
233:
234: protected:
235: virtual void OnOK();
236: virtual void OnCancel();
237:
238: // The following handle the case of print setup... from the print dialog
239: CPrintDialog(PRINTDLG FAR& pdInit);
240: afx_msg void OnPrintSetup();
241: virtual CPrintDialog* AttachOnSetup();
242:
243: private:
244: PRINTDLG m_pdActual; // the Print/Print Setup need to share this
245:
246: DECLARE_MESSAGE_MAP()
247: };
248:
249: // Find/FindReplace modeless dialogs
250: class CFindReplaceDialog : public CDialog
251: {
252: DECLARE_DYNAMIC(CFindReplaceDialog)
253:
254: public:
255: // Attributes
256: FINDREPLACE m_fr;
257:
258: // Constructors
259: CFindReplaceDialog();
260: // NOTE: you must allocate these on the heap. If you do not,
261: // you must derive and override PostNcDestroy() and do not delete this.
262:
263: BOOL Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace
264: LPCSTR lpszFindWhat,
265: LPCSTR lpszReplaceWith = NULL,
266: DWORD dwFlags = FR_DOWN,
267: CWnd* pParentWnd = NULL);
268:
269: // find/replace parameter block
270: static CFindReplaceDialog* GetNotifier(LONG lParam);
271:
272: // Operations
273: // Helpers for parsing information after successful return
274: CString GetReplaceString() const;// get replacement string
275: CString GetFindString() const; // get find string
276: BOOL SearchDown() const; // TRUE if search down, FALSE is up
277: BOOL FindNext() const; // TRUE if command is find next
278: BOOL MatchCase() const; // TRUE if matching case
279: BOOL MatchWholeWord() const; // TRUE if matching whole words only
280: BOOL ReplaceCurrent() const; // TRUE if replacing current string
281: BOOL ReplaceAll() const; // TRUE if replacing all occurrences
282: BOOL IsTerminating() const; // TRUE if terminating dialog
283:
284: // Implementation
285: protected:
286: virtual void PostNcDestroy();
287:
288: #ifdef _DEBUG
289: public:
290: virtual void Dump(CDumpContext& dc) const;
291: #endif
292:
293: protected:
294: char m_szFindWhat[128];
295: char m_szReplaceWith[128];
296: };
297:
298:
299: // inline functions for classes in this file
300:
301: inline CString CFileDialog::GetPathName() const
302: { return m_ofn.lpstrFile; }
303: inline CString CFileDialog::GetFileExt() const
304: { if (m_ofn.nFileExtension == 0) return (char)'\0';
305: else return m_ofn.lpstrFile + m_ofn.nFileExtension; }
306: inline CString CFileDialog::GetFileTitle() const
307: { return m_ofn.lpstrFileTitle; }
308: inline BOOL CFileDialog::GetReadOnlyPref() const
309: { return m_ofn.Flags & OFN_READONLY ? TRUE : FALSE; }
310: inline void CFontDialog::GetCurrentFont(LPLOGFONT lplf)
311: { ASSERT(m_hWnd != NULL); this->SendMessage(WM_CHOOSEFONT_GETLOGFONT,
312: 0, (DWORD)(LPSTR)lplf); }
313: inline CString CFontDialog::GetFaceName() const
1.1.1.2 root 314: { return m_cf.lpLogFont->lfFaceName; }
1.1 root 315: inline CString CFontDialog::GetStyleName() const
316: { return m_cf.lpszStyle; }
317: inline int CFontDialog::GetSize() const
318: { return m_cf.iPointSize; }
319: inline int CFontDialog::GetWeight() const
320: { return m_cf.lpLogFont->lfWeight; }
321: inline BOOL CFontDialog::IsItalic() const
322: { return m_cf.lpLogFont->lfItalic ? TRUE : FALSE; }
323: inline BOOL CFontDialog::IsStrikeOut() const
324: { return m_cf.lpLogFont->lfStrikeOut ? TRUE : FALSE; }
325: inline BOOL CFontDialog::IsBold() const
326: { return m_cf.lpLogFont->lfWeight == FW_BOLD ? TRUE : FALSE; }
327: inline BOOL CFontDialog::IsUnderline() const
328: { return m_cf.lpLogFont->lfUnderline ? TRUE : FALSE; }
329: inline COLORREF CFontDialog::GetColor() const
330: { return m_cf.rgbColors; }
331: inline COLORREF CColorDialog::GetColor() const
332: { return m_cc.rgbResult; }
333: inline BOOL CPrintDialog::GetDefaults()
334: { m_pd.Flags |= PD_RETURNDEFAULT;
335: return ::PrintDlg(&m_pd); }
336: inline BOOL CPrintDialog::PrintSelection() const
337: { return m_pd.Flags & PD_SELECTION ? TRUE : FALSE; }
338: inline BOOL CPrintDialog::PrintRange() const
339: { return m_pd.Flags & PD_PAGENUMS ? TRUE : FALSE; }
340: inline BOOL CPrintDialog::PrintAll() const
341: { return !PrintRange() && !PrintSelection() ? TRUE : FALSE; }
342: inline BOOL CPrintDialog::PrintCollate() const
343: { return m_pd.Flags & PD_COLLATE ? TRUE : FALSE; }
344: inline int CPrintDialog::GetFromPage() const
345: { return (PrintRange() ? m_pd.nFromPage :-1); }
346: inline int CPrintDialog::GetToPage() const
347: { return (PrintRange() ? m_pd.nToPage :-1); }
348: inline LPDEVMODE CPrintDialog::GetDevMode() const
349: { return (LPDEVMODE)::GlobalLock(m_pd.hDevMode); }
350: inline CString CPrintDialog::GetDriverName() const
351: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
352: return (LPSTR)(lpDev) + (UINT)(lpDev->wDriverOffset); }
353: inline CString CPrintDialog::GetDeviceName() const
354: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
355: return (LPSTR)(lpDev) + (UINT)(lpDev->wDeviceOffset); }
356: inline CString CPrintDialog::GetPortName() const
357: { LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(m_pd.hDevNames);
358: return (LPSTR)(lpDev) + (UINT)(lpDev->wOutputOffset); }
359: inline BOOL CFindReplaceDialog::IsTerminating() const
360: { return m_fr.Flags & FR_DIALOGTERM ? TRUE : FALSE ; }
361: inline CString CFindReplaceDialog::GetReplaceString() const
362: { return m_fr.lpstrReplaceWith; }
363: inline CString CFindReplaceDialog::GetFindString() const
364: { return m_fr.lpstrFindWhat; }
365: inline BOOL CFindReplaceDialog::SearchDown() const
366: { return m_fr.Flags & FR_DOWN ? TRUE : FALSE; }
367: inline BOOL CFindReplaceDialog::FindNext() const
368: { return m_fr.Flags & FR_FINDNEXT ? TRUE : FALSE; }
369: inline BOOL CFindReplaceDialog::MatchCase() const
370: { return m_fr.Flags & FR_MATCHCASE ? TRUE : FALSE; }
371: inline BOOL CFindReplaceDialog::MatchWholeWord() const
372: { return m_fr.Flags & FR_WHOLEWORD ? TRUE : FALSE; }
373: inline BOOL CFindReplaceDialog::ReplaceCurrent() const
374: { return m_fr. Flags & FR_REPLACE ? TRUE : FALSE; }
375: inline BOOL CFindReplaceDialog::ReplaceAll() const
376: { return m_fr.Flags & FR_REPLACEALL ? TRUE : FALSE; }
377:
378: #endif //__AFXDLGS_H__
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.