home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 6.ddi / WEXAMPLE.ZIP / TODODLGS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  5.8 KB  |  199 lines

  1. #if !defined( __TODODLGS_H )
  2. #define __TODODLGS_H
  3.  
  4. //---------------------------------------------------------------------
  5. //
  6. //  TODODLGS.H
  7. //
  8. //      Copyright (c) 1991, 1992 by Borland International
  9. //      All Rights Reserved.
  10. //
  11. //  defines the following classes, which handle all the dialog boxes for
  12. //  the Todo program.
  13. //
  14. //      AboutBox
  15. //
  16. //      FileBox     - provides a basic dialog for selecting a file.
  17. //
  18. //      EditBox     - provides a dialog box for editing an entry in the
  19. //                    Todo list.
  20. //
  21. //---------------------------------------------------------------------
  22.  
  23. #if !defined( __WINDOWS_H )
  24. #define STRICT
  25. #include <Windows.h>
  26. #endif  // __WINDOWS_H
  27.  
  28. #if !defined( __DIR_H )
  29. #include <Dir.h>
  30. #endif  // __DIR_H
  31.  
  32. #if !defined( __STRSTREAM_H )
  33. #include <strstream.h>
  34. #endif  // __STRSTREAM_H
  35.  
  36. #if !defined( __TODOWIN_H )
  37. #include "TodoWin.h"
  38. #endif  // __TODOWIN_H
  39.  
  40. #if !defined( __TODOLIST_H )
  41. #include "TodoList.h"
  42. #endif  // __TODOLIST_H
  43.  
  44. //---------------------------------------------------------------------
  45. //
  46. //  class AboutBox
  47. //
  48. //      draws and manages the About dialog.
  49. //
  50. //---------------------------------------------------------------------
  51.  
  52. class AboutBox : public ModalDialog
  53. {
  54.  
  55. public:
  56.  
  57.     AboutBox( HWND );
  58.  
  59. private:
  60.  
  61.     virtual LPSTR getDialogName();
  62.  
  63.     virtual BOOL dispatch( HWND, UINT, WPARAM, LPARAM );
  64.  
  65. };
  66.  
  67. //---------------------------------------------------------------------
  68. //
  69. //  class FileBox
  70. //
  71. //      draws and manages a dialog box for selecting a file.
  72. //
  73. //---------------------------------------------------------------------
  74.  
  75. class FileBox : public ModalDialog
  76. {
  77.  
  78. public:
  79.  
  80.     FileBox( HWND, const char *, const char *, const char *, BOOL = TRUE );
  81.  
  82.                                 // constructor for the FileBox.
  83.                                 //
  84.                                 // Arguments:
  85.                                 //
  86.                                 // HWND owner - handle of the owner of
  87.                                 //              this dialog
  88.                                 // const char *c - caption for this dialog
  89.                                 // const char *p - initial path
  90.                                 // const char *s - file spec (wildcards
  91.                                 //                 accepted)
  92.                                 // BOOL me       - indicates whether the
  93.                                 //                 selected file must exist
  94.                                 //                 in order to be valid.
  95.                                 //                 For an input file, this
  96.                                 //                 should be TRUE.  For an
  97.                                 //                 output file it can
  98.                                 //                 be FALSE.
  99.  
  100.  
  101.     const char *getPath();      // after executing run(), this function
  102.                                 // can be called to get the full path
  103.                                 // to the selected file.
  104.  
  105.     virtual WORD run();         // draws the dialog box and handles
  106.                                 // user input
  107.  
  108. protected:
  109.  
  110.     virtual BOOL dispatch( HWND, UINT, WPARAM, LPARAM );
  111.  
  112. private:
  113.  
  114.     virtual LPSTR getDialogName();
  115.  
  116.     const char *caption;        // store initial parameter
  117.     const char *iPath;          // store initial parameter
  118.     const char *iSpec;          // store initial parameter
  119.     BOOL mustExist;             // store initial parameter
  120.  
  121.     char path[MAXPATH];         // used internally to keep track of
  122.                                 // current selection
  123.  
  124.     char res[MAXPATH];          // holds the selected path after run()
  125.                                 // has been executed.
  126.  
  127.     void resetDlg( HWND );      // used internally
  128.     void initDlg( HWND );       // used internally
  129.     BOOL flistCmd( HWND, LONG );  // used internally
  130.     BOOL fnameCmd( HWND, LONG );  // used internally
  131.     void okCmd( HWND );         // used internally
  132.     void cancelCmd( HWND );     // used internally
  133.  
  134. };
  135.  
  136. class TodoEntry;                // forward reference
  137.  
  138. //---------------------------------------------------------------------
  139. //
  140. //  class EditBox
  141. //
  142. //      draws and manages a dialog box to edit an entry in the Todo list.
  143. //
  144. //---------------------------------------------------------------------
  145.  
  146. class EditBox : public ModalDialog
  147. {
  148.  
  149. public:
  150.  
  151.     EditBox( HWND, TodoEntry& );
  152.                                 // constructor for the EditBox.
  153.                                 //
  154.                                 // Arguments:
  155.                                 //
  156.                                 // HWND owner - handle of the owner
  157.                                 //              of this dialog
  158.                                 // TodoEntry& td - the entry to be edited
  159.  
  160. private:
  161.  
  162.     virtual LPSTR getDialogName();
  163.  
  164.     virtual BOOL dispatch( HWND, UINT, WPARAM, LPARAM );
  165.  
  166.     TodoEntry& current;         // the entry to be edited
  167.  
  168.     int button;                 // current selection among the radio
  169.                                 // buttons that set the priority
  170.  
  171.     void initDlg( HWND );       // used internally
  172.     void checkButton( HWND, WPARAM );  // used internally
  173.     void okCmd( HWND );         // used internally
  174.     void cancelCmd( HWND );     // used internally
  175. };
  176.  
  177. //---------------------------------------------------------------------
  178. //
  179. //  inline functions
  180. //
  181. //---------------------------------------------------------------------
  182.  
  183. inline AboutBox::AboutBox( HWND hOwner ) : ModalDialog( hOwner )
  184. {
  185. }
  186.  
  187. inline const char *FileBox::getPath()
  188. {
  189.     return res;
  190. }
  191.  
  192. inline EditBox::EditBox( HWND hOwner, TodoEntry& td ) :
  193.     ModalDialog( hOwner ), current( td )
  194. {
  195. }
  196.  
  197. #endif  // __TODODLGS_H
  198.  
  199.