home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / source / cppwin10 / cwind1.cpp < prev    next >
C/C++ Source or Header  |  1991-01-11  |  3KB  |  119 lines

  1. /***
  2.     Class Wind #1.
  3.     Used to test the inheritance of the CWind class.
  4. Revisions:
  5. 10/21/90 KM Initial coding.
  6. ***/
  7.  
  8. #include    <windows.h>
  9. #include    <stdio.h>
  10.  
  11. #include "cdlg1.hpp"
  12. #include "cdlgabt.hpp"
  13. #include "copendlg.hpp"
  14. #include "cselprn.hpp"
  15. #include "menudef.h"
  16.  
  17. #define BUTTONID    1000        // ID of button on main window.
  18. #define EDITID        1001        // ID of edit class on main window.
  19.  
  20. // $HPP:Start
  21. /***
  22.     Test window class.
  23. ***/
  24.  
  25. #ifndef CWind1_INC
  26. #define CWind1_INC
  27.  
  28. #include "cwind.hpp"
  29.  
  30. class   CWind1 : public CWind   {
  31.     public:
  32.         CWind1(HANDLE ,HANDLE);
  33.         LONG DoCommand(WORD wMenuId, LONG lParam);
  34.         LONG DoSize(WORD wCmd, LPPOINT lpPoint);
  35.         ~CWind1();
  36.  
  37.         CWind *pButton;
  38.         CWind *pList;
  39.         int Ctr;
  40. };
  41. #endif
  42. // $HPP:End
  43.  
  44. /***
  45.     Command functions.
  46. ***/        
  47. LONG CWind1 :: DoCommand(WORD wMenuId, LONG lParam)
  48. {
  49.     CDlg1 *pDlgCl;
  50.     CDlgAbout *pDlgAbout;
  51.     COpenDlg *pOpenDlg;
  52.     CSelPrnterDlg *pSelPrn;
  53.     char szBuf[50];
  54.  
  55.     switch (wMenuId) {
  56.     case IDM_TEST:
  57.         pDlgCl = new CDlg1;
  58.         pDlgCl->DoDialog(WhInstance, "TEST_DIALOG", WhWnd, 0l);
  59.         delete pDlgCl;
  60.         break;
  61.     case IDM_ABOUT:
  62.         pDlgAbout = new CDlgAbout;
  63.         pDlgAbout->DoAboutBox(WhInstance, WhWnd);
  64.         delete pDlgAbout;
  65.         break;
  66.     case IDM_EXIT:
  67.         SendMessage(WhWnd, WM_DESTROY, 0, 0l);
  68.         break;
  69.     case IDM_OPEN:
  70.         pOpenDlg = new COpenDlg((LPSTR)"*.cpp", TRUE);
  71.         pOpenDlg->DoDialog(WhInstance, "OPEN_DLG", WhWnd, 0l);
  72.         delete pOpenDlg;
  73.         break;
  74.     case IDM_PRNSETUP:
  75.         pSelPrn = new CSelPrnterDlg;
  76.         pSelPrn->DoDialog(WhInstance, "SELPRN_DLG", WhWnd, 0l);
  77.         delete pSelPrn;
  78.         break;
  79.     case BUTTONID:
  80.         sprintf(szBuf, "%d", ++Ctr);
  81.         pButton->SetWndText(szBuf);
  82.         break;
  83.     default:
  84.         return CWind :: DoCommand(wMenuId, lParam);
  85.     }
  86.     return 0l;
  87. }
  88.  
  89. LONG CWind1 :: DoSize(WORD wCmd, LPPOINT lpPoint)
  90. {
  91.     pButton->Move(0, lpPoint->y - 30, lpPoint->x, 30, TRUE);
  92.     pList->Move(0, 0, lpPoint->x, lpPoint->y - 30, TRUE);
  93.     return DoDefault(WM_SIZE, wCmd, MAKELONG(lpPoint->x, lpPoint->y));
  94. }
  95.  
  96. CWind1 :: CWind1(HANDLE hInstance, HANDLE hPrev)
  97. : CWind(hInstance, hPrev)
  98. {
  99.     RECT r;
  100.     int width, height;
  101.  
  102.     GetWndClientRect(&r);
  103.     width = r.right - r.left;
  104.     height = r.bottom - r.top;
  105.     pButton = new CWind(this, (LPSTR)"Button", (LPSTR)"0",
  106.             WS_CHILDWINDOW, 0, r.bottom - 10, width, 10, BUTTONID);
  107.     pList = new CWind(this, (LPSTR)"Edit", (LPSTR)NULL,
  108.             WS_CHILDWINDOW | WS_HSCROLL | WS_VSCROLL | ES_LEFT | 
  109.             ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  110.             0, 0, width, height - 10, EDITID);
  111. }
  112.  
  113. CWind1 :: ~CWind1()
  114. {
  115.     delete pButton;
  116.     delete pList;
  117. }
  118.  
  119.