home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / controls / circ1 / circ1ctl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  5.7 KB  |  198 lines

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