home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch10 / calencod / calenctl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-01  |  5.3 KB  |  189 lines

  1. // CalenCtl.cpp : Implementation of the CCalenCtrl OLE control class.
  2.  
  3. #include "stdafx.h"
  4. #include "Calen.h"
  5. #include "CalenCtl.h"
  6. #include "CalenPpg.h"
  7.  
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15.  
  16. IMPLEMENT_DYNCREATE(CCalenCtrl, COleControl)
  17.  
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // Message map
  21.  
  22. BEGIN_MESSAGE_MAP(CCalenCtrl, COleControl)
  23.     //{{AFX_MSG_MAP(CCalenCtrl)
  24.     // NOTE - ClassWizard will add and remove message map entries
  25.     //    DO NOT EDIT what you see in these blocks of generated code !
  26.     //}}AFX_MSG_MAP
  27.     ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
  28. END_MESSAGE_MAP()
  29.  
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Dispatch map
  33.  
  34. BEGIN_DISPATCH_MAP(CCalenCtrl, COleControl)
  35.     //{{AFX_DISPATCH_MAP(CCalenCtrl)
  36.     // NOTE - ClassWizard will add and remove dispatch map entries
  37.     //    DO NOT EDIT what you see in these blocks of generated code !
  38.     //}}AFX_DISPATCH_MAP
  39.     DISP_FUNCTION_ID(CCalenCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
  40. END_DISPATCH_MAP()
  41.  
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Event map
  45.  
  46. BEGIN_EVENT_MAP(CCalenCtrl, COleControl)
  47.     //{{AFX_EVENT_MAP(CCalenCtrl)
  48.     // NOTE - ClassWizard will add and remove event map entries
  49.     //    DO NOT EDIT what you see in these blocks of generated code !
  50.     //}}AFX_EVENT_MAP
  51. END_EVENT_MAP()
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Property pages
  56.  
  57. // TODO: Add more property pages as needed.  Remember to increase the count!
  58. BEGIN_PROPPAGEIDS(CCalenCtrl, 1)
  59.     PROPPAGEID(CCalenPropPage::guid)
  60. END_PROPPAGEIDS(CCalenCtrl)
  61.  
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Initialize class factory and guid
  65.  
  66. IMPLEMENT_OLECREATE_EX(CCalenCtrl, "CALEN.CalenCtrl.1",
  67.     0x5daa5a23, 0x149d, 0x11cf, 0x95, 0x2f, 0, 0x20, 0xaf, 0x6e, 0x90, 0x3f)
  68.  
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Type library ID and version
  72.  
  73. IMPLEMENT_OLETYPELIB(CCalenCtrl, _tlid, _wVerMajor, _wVerMinor)
  74.  
  75.  
  76. /////////////////////////////////////////////////////////////////////////////
  77. // Interface IDs
  78.  
  79. const IID BASED_CODE IID_DCalen =
  80.         { 0x5daa5a21, 0x149d, 0x11cf, { 0x95, 0x2f, 0, 0x20, 0xaf, 0x6e, 0x90, 0x3f } };
  81. const IID BASED_CODE IID_DCalenEvents =
  82.         { 0x5daa5a22, 0x149d, 0x11cf, { 0x95, 0x2f, 0, 0x20, 0xaf, 0x6e, 0x90, 0x3f } };
  83.  
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // Control type information
  87.  
  88. static const DWORD BASED_CODE _dwCalenOleMisc =
  89.     OLEMISC_ACTIVATEWHENVISIBLE |
  90.     OLEMISC_SETCLIENTSITEFIRST |
  91.     OLEMISC_INSIDEOUT |
  92.     OLEMISC_CANTLINKINSIDE |
  93.     OLEMISC_RECOMPOSEONRESIZE;
  94.  
  95. IMPLEMENT_OLECTLTYPE(CCalenCtrl, IDS_CALEN, _dwCalenOleMisc)
  96.  
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CCalenCtrl::CCalenCtrlFactory::UpdateRegistry -
  100. // Adds or removes system registry entries for CCalenCtrl
  101.  
  102. BOOL CCalenCtrl::CCalenCtrlFactory::UpdateRegistry(BOOL bRegister)
  103. {
  104.     if (bRegister)
  105.         return AfxOleRegisterControlClass(
  106.             AfxGetInstanceHandle(),
  107.             m_clsid,
  108.             m_lpszProgID,
  109.             IDS_CALEN,
  110.             IDB_CALEN,
  111.             FALSE,                      //  Not insertable
  112.             _dwCalenOleMisc,
  113.             _tlid,
  114.             _wVerMajor,
  115.             _wVerMinor);
  116.     else
  117.         return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
  118. }
  119.  
  120.  
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CCalenCtrl::CCalenCtrl - Constructor
  123.  
  124. CCalenCtrl::CCalenCtrl()
  125. {
  126.     InitializeIIDs(&IID_DCalen, &IID_DCalenEvents);
  127.  
  128.     // TODO: Initialize your control's instance data here.
  129. }
  130.  
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CCalenCtrl::~CCalenCtrl - Destructor
  134.  
  135. CCalenCtrl::~CCalenCtrl()
  136. {
  137.     // TODO: Cleanup your control's instance data here.
  138. }
  139.  
  140.  
  141. /////////////////////////////////////////////////////////////////////////////
  142. // CCalenCtrl::OnDraw - Drawing function
  143.  
  144. void CCalenCtrl::OnDraw(
  145.             CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
  146. {
  147.     // TODO: Replace the following code with your own drawing code.
  148.     pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
  149.     pdc->Ellipse(rcBounds);
  150. }
  151.  
  152.  
  153. /////////////////////////////////////////////////////////////////////////////
  154. // CCalenCtrl::DoPropExchange - Persistence support
  155.  
  156. void CCalenCtrl::DoPropExchange(CPropExchange* pPX)
  157. {
  158.     ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
  159.     COleControl::DoPropExchange(pPX);
  160.  
  161.     // TODO: Call PX_ functions for each persistent custom property.
  162.  
  163. }
  164.  
  165.  
  166. /////////////////////////////////////////////////////////////////////////////
  167. // CCalenCtrl::OnResetState - Reset control to default state
  168.  
  169. void CCalenCtrl::OnResetState()
  170. {
  171.     COleControl::OnResetState();  // Resets defaults found in DoPropExchange
  172.  
  173.     // TODO: Reset any other control state here.
  174. }
  175.  
  176.  
  177. /////////////////////////////////////////////////////////////////////////////
  178. // CCalenCtrl::AboutBox - Display an "About" box to the user
  179.  
  180. void CCalenCtrl::AboutBox()
  181. {
  182.     CDialog dlgAbout(IDD_ABOUTBOX_CALEN);
  183.     dlgAbout.DoModal();
  184. }
  185.  
  186.  
  187. /////////////////////////////////////////////////////////////////////////////
  188. // CCalenCtrl message handlers
  189.