home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / DIALOG.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  145 lines

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