home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Games / INFESPGAMES.mdf / os2 / ribble / support / win / cdialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-01  |  3.9 KB  |  141 lines

  1. #ifdef __OS2__
  2.  
  3. // -------------------------------
  4. //  Name:           CDialog.h
  5. //  Author:         J.R.Shannon
  6. //  Language:       C++
  7. //  Date:           6/11/92
  8. //  Revison:        2.1
  9. //  Last revision:  9/7/93
  10. //  Licence:        Public Domain
  11. //  Purpose:        Basic dialog window handling.
  12. // -------------------------------
  13. //
  14. // Remarks:
  15. //      The header file <os2.h> must have been included
  16. //   prior to this one, with at least INCL_WIN defined.
  17. //
  18. //
  19. // Using this CDialog class:
  20. //
  21. //      Construction of the dialog window does not actually
  22. //   take place until the open() method is called.  It
  23. //   should be called after (or during) the constructor
  24. //   of the derived class which contains the overridden
  25. //   version of ProcessMsg.
  26. //      The reason for this is that
  27. //   if the dialog window is opened in the CDialog
  28. //   constructor then the virtual function jump tables
  29. //   will contain a pointer to the wrong ProcessMsg
  30. //   and some of the early messages will be lost
  31. //   to CDialog::ProcessMsg rather than the derived
  32. //   class's ProcessMsg.
  33. //
  34. //      If the dialog window is created modeless, then
  35. //   the user is responsible for running of the calling
  36. //   thread's message queue.  A modal dialog window
  37. //   runs the queue for the window's life-time.
  38. //
  39. //  Warning:
  40. //
  41. //   The ULONG at QWL_USER in the dialog's window words
  42. //   is *NOT* available for use by the user.  Use
  43. //   storage inside your derived CDialog object instead.
  44. //
  45.  
  46. #ifndef _CDialog_h
  47. #define _CDialog_h
  48.  
  49.  
  50. // Class for a dialog window
  51.  
  52. class CDialog
  53. {
  54. public:
  55.   // _owner    = the window which is to own the dialog window
  56.   // _resID    = id of dialog template in .exe resource section
  57.   // _modeless = TRUE: create a modeless dialog window - control returns after creation
  58.   // _parent   = parent window for dialog window. (Window is clipped to the parent)
  59.   CDialog(HWND _owner, ULONG _resID, BOOL _modeless = FALSE, HWND _parent = HWND_DESKTOP, HMODULE _module = 0);
  60.  
  61.   virtual ~CDialog();
  62.  
  63.   HWND hwnd(void);          // Get handle on window.
  64.   virtual void Create(void);  // Open the dialog window.  Returns after creation if
  65.                             // it is modeless, and after the window has closed if it
  66.                             // is modal.
  67.   virtual void Destroy(void); // Force the window to close.
  68.   virtual void SetupWindow(void);
  69.   virtual void show(BOOL _show = TRUE);
  70.   HAB QueryHAB(void);
  71.  
  72. protected:
  73.   friend MRESULT EXPENTRY CDialogInitialDialogWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  74.   friend MRESULT EXPENTRY CDialogDialogWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  75.   virtual MRESULT ProcessMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  76.  
  77.   PVOID       MsgSpec;
  78.  
  79. public:
  80.   union
  81.     {
  82.       HWND    hwndDialog;
  83.       HWND    HWindow;
  84.     };
  85.  
  86. private:
  87.   HWND    owner;
  88.   HWND    parent;
  89.   ULONG   resID;
  90.   HMODULE module;
  91.   BOOL    modeless;
  92. };
  93.  
  94.  
  95. #endif
  96.  
  97. #else
  98.  
  99. // $Source: C:\logical\store\classes/RCS/CDIALOG.H,v $
  100. // $Revision: 1.5 $
  101. // $Date: 1994/01/22 14:47:12 $
  102. //
  103.  
  104. #ifndef _cdialog_h
  105. #define _cdialog_h
  106.  
  107. class CDialog
  108. {
  109. public:
  110.        CDialog(HWND _owner, HINSTANCE _hInst, char* _resID, BOOL _modal = FALSE);
  111.        ~CDialog();
  112.        void Close(void);
  113.        void Create(void);
  114.        void Show(void);
  115.        void Hide(void);
  116.        void Move(int _x, int _y);
  117.        void BringToTop(void);
  118.        HWND handle(void) { return hwnd; }
  119.        //--
  120.        virtual LRESULT RealProc(HWND, UINT, WPARAM, LPARAM);
  121.  
  122.        union
  123.          {
  124.            HWND hwnd;
  125.            HWND HWindow;
  126.          };
  127. private:
  128.         HWND      owner;
  129.         HINSTANCE hInst;
  130.         CString   resID;
  131.         DLGPROC   proc;
  132.         BOOL      modal;
  133.         //--
  134.         static LRESULT CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);
  135. };
  136.  
  137. #endif
  138.  
  139. #endif
  140.  
  141.