home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / TUTORIAL / EXAMPLE4.CC < prev    next >
C/C++ Source or Header  |  1995-08-30  |  3KB  |  108 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: example4.cc 1.1 1995/08/30 11:08:07 teb Exp $ */
  8.  
  9. /*******************************************
  10.  *   Example4.cc 
  11.  * 
  12.  *******************************************/
  13.  
  14. #define INCL_WIN
  15. #include<os2.h>
  16.  
  17. //DHO application object header file
  18. #include<applicat.h>
  19. #include<framewin.h>
  20.  
  21. #define kAppId 100
  22.  
  23.  
  24. class TExampleClientWin : public TWindow
  25. {
  26.       SHORT sPageX, sPageY;
  27.    public:
  28.       TExampleClientWin(ULONG id, TWinBase *parent):TWindow(id, parent){;};
  29.       virtual void doSize(WinMsg wm)
  30.       {
  31.          sPageX = SHORT1FROMMP(wm.mp2);
  32.          sPageY = SHORT2FROMMP(wm.mp2);
  33.       }
  34.       virtual void paintWindow(HPS ps, RECTL rcl)
  35.       {
  36.          POINTL ptl;
  37.          SHORT w;
  38.  
  39.          if ((sPageX == 0) && (sPageY == 0))         
  40.          {
  41.             sPageX = rcl.xRight - rcl.xLeft;
  42.             sPageY = rcl.yTop - rcl.yBottom; 
  43.          }
  44.  
  45.          if (sPageX > sPageY)
  46.             w = sPageY / 2;
  47.          else
  48.             w = sPageX / 2;         
  49.  
  50.          WinFillRect(ps, &rcl, CLR_BLUE);
  51.  
  52.          rcl.xLeft = (sPageX/2) -(w/2);
  53.          rcl.xRight = rcl.xLeft +w;
  54.          rcl.yBottom = (sPageY /2) -(w/2);
  55.          rcl.yTop = rcl.yBottom+w;
  56.  
  57.          WinFillRect(ps, &rcl, CLR_YELLOW);
  58.          
  59.       }
  60. };
  61.  
  62.  
  63.  
  64. class TExampleFrameWin : public TFrameWindow
  65. {
  66.  
  67.    public:
  68.       TExampleFrameWin(ULONG id, char *title):TFrameWindow(id, title)
  69.       {   fShellPos = TRUE;};
  70.       virtual BOOL init()
  71.       {
  72.          if (TFrameWindow::init())
  73.          {   // add a frame icon
  74.             this->setIcon(WinQuerySysPointer(HWND_DESKTOP, 
  75.                     SPTR_ICONINFORMATION, FALSE));
  76.  
  77.             TExampleClientWin *client = new
  78.                 TExampleClientWin(FID_CLIENT, this);
  79.             return client->init();
  80.          }
  81.          return FALSE;
  82.       }
  83. };
  84.  
  85.  
  86. class TExampleApp : public TApplication
  87. {
  88.    public:
  89.       TExampleApp(ULONG res):TApplication(res){;};
  90.       virtual void CreateMainWindow()
  91.       {
  92.          MainWin=new TExampleFrameWin(fResource, "DHO Tutorial App");
  93.       }
  94. };
  95.  
  96.  
  97.  
  98. //=========================================
  99. //  program entry point
  100. INT main(void)
  101. {
  102.    TExampleApp app(kAppId);
  103.  
  104.    app.init();     // initialize object
  105.    app.run();      // begin event loop          
  106.  
  107.    return 0;
  108. }