home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / DIALOG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  3.8 KB  |  143 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   include\owl\dialog.h
  4. //   Definition of TDialog class and TDialogAttr struct
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_DIALOG_H)
  7. #define __OWL_DIALOG_H
  8.  
  9. #if !defined(__OWL_WINDOW_H)
  10.   #include <owl\window.h>
  11. #endif
  12.  
  13. //
  14. //  struct TDialogAttr
  15. //  ------ -----------
  16. //
  17. //  TDialog creation attributes
  18. //
  19. struct TDialogAttr {
  20.   char far* Name;
  21.   DWORD     Param;
  22. };
  23.  
  24. //
  25. //  class TDialog
  26. //  ----- -------
  27. //
  28. class _OWLCLASS TDialog : virtual public TWindow {
  29.   public:
  30.     TDialogAttr  Attr;
  31.     BOOL         IsModal;
  32.  
  33.     TDialog(TWindow* parent, TResId resId, TModule* module = 0);
  34.  
  35.    ~TDialog();
  36.  
  37.     //
  38.     // override this to process messages within the dialog function
  39.     // Return TRUE if message handled, FALSE if not.
  40.     //
  41.     // default behavior is to call EvInitDialog & EvSetFont
  42.     //
  43.     virtual BOOL    DialogFunction(UINT message, WPARAM wParam, LPARAM lParam);
  44.  
  45.     //
  46.     // override this to process WM_INITDIALOG message
  47.     //
  48.     // default behavior is to call PerformDlgInit & SetupWindow() and return 
  49.     // TRUE
  50.     //
  51.     virtual BOOL    EvInitDialog(HWND hWndFocus);
  52.  
  53.     //
  54.     // Initialize dialog controls with contents of RT_DLGINIT
  55.     //
  56.     BOOL            PerformDlgInit();
  57.  
  58.     //
  59.     // override this to process WM_SETFONT
  60.     //
  61.     virtual void    EvSetFont(HFONT);
  62.  
  63.     //
  64.     // create a modeless dialog box, and perform actual create call
  65.     //
  66.     virtual BOOL    Create();
  67.     virtual HWND    DoCreate();
  68.  
  69.     //
  70.     // create a modal dialog box, and perform actual modal call
  71.     //
  72.     virtual int     Execute();
  73.     virtual int     DoExecute();
  74.  
  75.     //
  76.     // override virtual functions defined by class TWindow
  77.     //
  78.     BOOL            PreProcessMsg(MSG& msg);
  79.     void            CloseWindow(int retValue = IDCANCEL);
  80.     void            Destroy(int retValue = IDCANCEL);
  81.  
  82.     void            SetCaption(const char far* title);
  83.  
  84.     //
  85.     // returns the handle of the dialog's control with the passed Id
  86.     // Obsolete- use TWindow::GetDlgItem(Id)
  87.     //
  88.     HWND            GetItemHandle(int childId) {return GetDlgItem(childId); }
  89.  
  90.     //
  91.     // sends the passed message to the dialog's control which has id DlgItemId
  92.     // Obsolete- use TWindow::SendDlgItemMessage()
  93.     //
  94.     DWORD SendDlgItemMsg(int ChildId, WORD Msg, WORD WParam, DWORD LParam);
  95.  
  96.     UINT            GetDefaultId() const;
  97.     void            SetDefaultId(UINT Id) {HandleMessage(DM_SETDEFID, Id, 0);}
  98.  
  99.     //
  100.     // message response functions
  101.     //
  102.     void            EvClose();
  103.     void            EvPaint();
  104.     HBRUSH          EvCtlColor(HDC, HWND hWndChild, UINT ctlType);
  105.  
  106.     //
  107.     // child notifications
  108.     //
  109.     void            CmOk();      // IDOK
  110.     void            CmCancel();  // IDCANCEL
  111.  
  112.   protected:
  113.     //
  114.     // override virtual functions defined by class TWindow
  115.     //
  116.     void            SetupWindow();
  117.     char far*       GetClassName();
  118.     void            GetWindowClass(WNDCLASS& wndClass);
  119.  
  120.   private:
  121.     //
  122.     // hidden to prevent accidental copying or assignment
  123.     //
  124.     TDialog(const TDialog&);
  125.     TDialog& operator =(const TDialog&);
  126.  
  127.   DECLARE_RESPONSE_TABLE(TDialog);
  128.   DECLARE_STREAMABLE(_OWLCLASS, TDialog, 1);
  129. };
  130.  
  131.  
  132. inline DWORD
  133. TDialog::SendDlgItemMsg(int ChildId, WORD Msg, WORD WParam, DWORD LParam) {
  134.   return SendDlgItemMessage(ChildId, Msg, WParam, LParam);
  135. }
  136.  
  137. inline UINT
  138. TDialog::GetDefaultId() const {
  139.   return LOWORD(CONST_CAST(TDialog*,this)->HandleMessage(DM_GETDEFID));
  140. }
  141.  
  142. #endif  // __OWL_DIALOG_H
  143.