home *** CD-ROM | disk | FTP | other *** search
- // buttoctl.cpp : Implementation of the CButtonCtrl OLE control class.
-
- #include "stdafx.h"
- #include "button.h"
- #include "buttoctl.h"
- #include "buttoppg.h"
-
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
-
- IMPLEMENT_DYNCREATE(CButtonCtrl, COleControl)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Message map
-
- BEGIN_MESSAGE_MAP(CButtonCtrl, COleControl)
- //{{AFX_MSG_MAP(CButtonCtrl)
- // NOTE - ClassWizard will add and remove message map entries
- // DO NOT EDIT what you see in these blocks of generated code !
- ON_MESSAGE(OCM_COMMAND, OnOcmCommand)
- //}}AFX_MSG_MAP
- ON_OLEVERB(AFX_IDS_VERB_EDIT, OnEdit)
- ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Dispatch map
-
- BEGIN_DISPATCH_MAP(CButtonCtrl, COleControl)
- //{{AFX_DISPATCH_MAP(CButtonCtrl)
- // NOTE - ClassWizard will add and remove dispatch map entries
- // DO NOT EDIT what you see in these blocks of generated code !
- //}}AFX_DISPATCH_MAP
- DISP_FUNCTION_ID(CButtonCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
- END_DISPATCH_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Event map
-
- BEGIN_EVENT_MAP(CButtonCtrl, COleControl)
- //{{AFX_EVENT_MAP(CButtonCtrl)
- EVENT_STOCK_CLICK()
- //}}AFX_EVENT_MAP
- END_EVENT_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Property pages
-
- // TODO: Add more property pages as needed. Remember to increase the count!
- BEGIN_PROPPAGEIDS(CButtonCtrl, 1)
- PROPPAGEID(CButtonPropPage::guid)
- END_PROPPAGEIDS(CButtonCtrl)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Initialize class factory and guid
-
- IMPLEMENT_OLECREATE_EX(CButtonCtrl, "BUTTON.ButtonCtrl.1",
- 0x56a2c5a0, 0x240a, 0x11ce, 0x96, 0xf, 0x52, 0x41, 0x53, 0x48, 0x0, 0x5)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Type library ID and version
-
- IMPLEMENT_OLETYPELIB(CButtonCtrl, _tlid, _wVerMajor, _wVerMinor)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Interface IDs
-
- const IID BASED_CODE IID_DButton =
- { 0x56a2c5a1, 0x240a, 0x11ce, { 0x96, 0xf, 0x52, 0x41, 0x53, 0x48, 0x0, 0x5 } };
- const IID BASED_CODE IID_DButtonEvents =
- { 0x56a2c5a2, 0x240a, 0x11ce, { 0x96, 0xf, 0x52, 0x41, 0x53, 0x48, 0x0, 0x5 } };
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Control type information
-
- static const DWORD BASED_CODE _dwButtonOleMisc =
- OLEMISC_ACTIVATEWHENVISIBLE |
- OLEMISC_SETCLIENTSITEFIRST |
- OLEMISC_INSIDEOUT |
- OLEMISC_CANTLINKINSIDE |
- OLEMISC_RECOMPOSEONRESIZE;
-
- IMPLEMENT_OLECTLTYPE(CButtonCtrl, IDS_BUTTON, _dwButtonOleMisc)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::CButtonCtrlFactory::UpdateRegistry -
- // Adds or removes system registry entries for CButtonCtrl
-
- BOOL CButtonCtrl::CButtonCtrlFactory::UpdateRegistry(BOOL bRegister)
- {
- if (bRegister)
- return AfxOleRegisterControlClass(
- AfxGetInstanceHandle(),
- m_clsid,
- m_lpszProgID,
- IDS_BUTTON,
- IDB_BUTTON,
- TRUE, // Insertable
- _dwButtonOleMisc,
- _tlid,
- _wVerMajor,
- _wVerMinor);
- else
- return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::CButtonCtrl - Constructor
-
- CButtonCtrl::CButtonCtrl()
- {
- InitializeIIDs(&IID_DButton, &IID_DButtonEvents);
-
- // TODO: Initialize your control's instance data here.
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::~CButtonCtrl - Destructor
-
- CButtonCtrl::~CButtonCtrl()
- {
- // TODO: Cleanup your control's instance data here.
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::OnDraw - Drawing function
-
- void CButtonCtrl::OnDraw(
- CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
- {
- DoSuperclassPaint(pdc, rcBounds);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::DoPropExchange - Persistence support
-
- void CButtonCtrl::DoPropExchange(CPropExchange* pPX)
- {
- ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
- COleControl::DoPropExchange(pPX);
-
- // TODO: Call PX_ functions for each persistent custom property.
-
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::OnResetState - Reset control to default state
-
- void CButtonCtrl::OnResetState()
- {
- COleControl::OnResetState(); // Resets defaults found in DoPropExchange
-
- // TODO: Reset any other control state here.
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::AboutBox - Display an "About" box to the user
-
- void CButtonCtrl::AboutBox()
- {
- CDialog dlgAbout(IDD_ABOUTBOX_BUTTON);
- dlgAbout.DoModal();
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::PreCreateWindow - Modify parameters for CreateWindowEx
-
- BOOL CButtonCtrl::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.lpszClass = _T("BUTTON");
- return COleControl::PreCreateWindow(cs);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::GetSuperWndProcAddr - Provide storage for window proc
-
- WNDPROC* CButtonCtrl::GetSuperWndProcAddr(void)
- {
- static WNDPROC NEAR pfnSuper;
- return &pfnSuper;
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl::OnOcmCommand - Handle command messages
-
- LRESULT CButtonCtrl::OnOcmCommand(WPARAM wParam, LPARAM lParam)
- {
- #ifdef _WIN32
- WORD wNotifyCode = HIWORD(wParam);
- #else
- WORD wNotifyCode = HIWORD(lParam);
- #endif
-
- // TODO: Switch on wNotifyCode here.
- switch (wNotifyCode )
- {
- // Issue a message when the button is clicked
- case BN_CLICKED : MessageBox("Button Clicked");
- break;
- }
-
- return 0;
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CButtonCtrl message handlers
-