home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9302 / dynamix / dynamix.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-12  |  3.3 KB  |  150 lines

  1. /* ************************************ **
  2.  * Name: dynamix.h
  3.  *       Enthält die Klassendefinitionen
  4.  *       für die Anwendung und die dyna-
  5.  *       mischen Dialoge.
  6.  * Update:  12-Dec-1992 tw
  7. ** ************************************ */
  8.  
  9. // ///////////////////////////////////////
  10. // MainWindow
  11. //     Das Applikations-Hauptfenster. In
  12. //     diesem Fall eine Dialogbox
  13. // Update:  12-Dec-1992    tw
  14. // ///////////////////////////////////////
  15. class MainWindow : public CDialog
  16. {
  17. public:
  18.    // Construction
  19.    MainWindow()
  20.    {
  21.       VERIFY( Create( dynamix ));
  22.    }
  23.  
  24.    // Capture Close-Message
  25.    afx_msg void OnClose()
  26.    {
  27.       PostQuitMessage( 0 );
  28.    }
  29.  
  30.    // Capture Button clicked message
  31.    void OnBtnClicked();
  32.  
  33.    DECLARE_MESSAGE_MAP();
  34. };
  35.  
  36. // ///////////////////////////////////////
  37. // Die Anwendung
  38. // Enthält in diesem Fall nur die init-
  39. // instance-funktion
  40. // ///////////////////////////////////////
  41.  
  42. class theApp : public CWinApp
  43. {
  44. public:
  45.    BOOL InitInstance();
  46.  
  47. };
  48.  
  49. // ********[ dynamische Dialog ]**********
  50.  
  51. // DLGTEMPLATE, wie im Resources Manual
  52. // verlangt, nur das der Speicher für
  53. // die strings hier noch nicht definiert
  54. // werden können
  55. // Selbiges gilt für das
  56. // das DLGITEMTEMPLATE
  57.  
  58. typedef struct tagDLGTEMPLATE
  59. {
  60.    LONG Style;  // style bits
  61.    BYTE nItems; // Anzahl dialogelemente
  62.    int  x;      // left side
  63.    int  y;      // top
  64.    int  width;  // breite
  65.    int  height; // hoehe
  66.  
  67. }     DLGTEMPLATE, FAR *LPDLGTEMPLATE;
  68.  
  69. typedef struct tagDLGITEMTEMPLATE
  70. {
  71.    int  x;
  72.    int  y;
  73.    int  width;
  74.    int  height;
  75.    int  ID;
  76.    LONG Style;
  77.  
  78. }  DLGITEMTEMPLATE,
  79.    FAR *LPDLGITEMTEMPLATE;
  80.  
  81. // ///////////////////////////////////////
  82. // XDynamicDialogBox
  83. //    Eine Klasse für die dynamische Er-
  84. //    zeugung von Dialogboxen.
  85. //    Die Klasse ist von CModalDialog
  86. //    abgeleitet, und enthält einige
  87. //    private Daten, die für die Kapselung
  88. //    der etwas komplexen Speicherver-
  89. //    waltung benötigt werden.
  90. // Update:  12-Dec-1992 tw
  91. // ///////////////////////////////////////
  92.  
  93. class XDynamicDialogBox :
  94.       public CModalDialog
  95. {
  96. private:
  97.    // Handle auf globalen speicher
  98.    HANDLE m_hMem;
  99.  
  100.    // anzahl byte, die über das Handle
  101.    // erreicht werden können
  102.    int    m_nBytes;
  103.  
  104.    // Anzhal Kontrollelemente auf dem
  105.    // Dialog
  106.    int    m_nItems;
  107.  
  108. public:
  109.   // Construction/Destruction
  110.   XDynamicDialogBox(CWnd* pParentWnd=NULL)
  111.   : CModalDialog( (UINT)NULL, pParentWnd )
  112.   {
  113.      m_hMem   = NULL;
  114.      m_nBytes = 0;
  115.      m_nItems = 0;
  116.   }
  117.   ~XDynamicDialogBox()
  118.   {
  119.      ASSERT( m_hMem );
  120.      GlobalFree( m_hMem );
  121.   }
  122.  
  123.   // Funktionen zum definieren der Box
  124.   // sowie der einzelnen Kontrollelemente
  125.  
  126.   void DefineBox( LONG style, int x,
  127.                   int y, int cx, int cy,
  128.                   LPSTR szMenuName,
  129.                   LPSTR szClassName,
  130.                    LPSTR szCaption );
  131.   void AddItem( int x, int y, int cx,
  132.                 int cy, int nID,
  133.                 LONG style,
  134.                 LPSTR szClass,
  135.                 LPSTR szText,
  136.                 BYTE DataBytes,
  137.                 LPBYTE pData );
  138.  
  139.   int DoModal()
  140.   {
  141.      ASSERT( m_hMem );
  142.      ASSERT( m_nBytes );
  143.      VERIFY(
  144.         CModalDialog::CreateIndirect(
  145.            m_hMem ));
  146.      return CModalDialog::DoModal();
  147.   }
  148.  
  149. };
  150.