home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / MDI.PAK / MDI.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.4 KB  |  73 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <owl/applicat.h>
  7. #include <owl/mdi.h>
  8. #include <owl/mdichild.h>
  9. #include <stdio.h>
  10.  
  11. #define IDM_MDIMENU 100
  12.  
  13. //
  14. // class TMyMDIClient
  15. // ~~~~~ ~~~~~~~~~~~~
  16. class TMyMDIClient : public TMDIClient {
  17.   public:
  18.     TMyMDIClient()
  19.     :
  20.       TMDIClient()
  21.     {
  22.       ChildNum = 0;
  23.     }
  24.  
  25.     void CmCreateChild();
  26.  
  27.   private:
  28.     int ChildNum;
  29.  
  30.   DECLARE_RESPONSE_TABLE(TMyMDIClient);
  31. };
  32.  
  33. DEFINE_RESPONSE_TABLE1(TMyMDIClient, TMDIClient)
  34.   EV_COMMAND(CM_CREATECHILD, CmCreateChild),
  35. END_RESPONSE_TABLE;
  36.  
  37. void
  38. TMyMDIClient::CmCreateChild()
  39. {
  40.   char childName[15];
  41.   sprintf(childName, "MDI Child %d", ChildNum++);
  42.   TMDIChild* child = new TMDIChild(*this, childName);
  43.   child->Create();
  44. }
  45.  
  46. //
  47. // class TMDIApp
  48. // ~~~~~ ~~~~~~~
  49. class TMDIApp : public TApplication {
  50.   public:
  51.     TMDIApp()
  52.     :
  53.       TApplication("MDI Conformist")
  54.     {
  55.     }
  56.  
  57.     void InitMainWindow();
  58. };
  59.  
  60. // Construct the TMDIApp's MainWindow object, loading its menu
  61. //
  62. void
  63. TMDIApp::InitMainWindow()
  64. {
  65.   SetMainWindow(new TMDIFrame(GetName(), IDM_MDIMENU, *new TMyMDIClient));
  66. }
  67.  
  68. int
  69. OwlMain(int /*argc*/, char* /*argv*/ [])
  70. {
  71.   return TMDIApp().Run();
  72. }
  73.