///////////////////////////////////////////////////////////////// // test.cpp - This is a small example of an ActiveX // // ver 1.0 control. It provides a dual interface // // that accepts a number, then after a // // few seconds, notifies its container // // about the number it received. // // - If the number is negative, the control // // sends an error, which the container can // // trap, using a try, catch block. // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2003 // ///////////////////////////////////////////////////////////////// // Note about builds: // // The test form holds a reference to the testConnPts2Lib // // typelibrary. Its toolbox contains a reference to the // // associated control. // // - Because of these references, the control's dll is // // locked any time this project is open, and you can not // // rebuild the control. // // - The only way I've figured to rebuild the control is // // to exit from Visual Studio, delete the control dll, // // and restart Visual Studio. Now you can rebuild the // // control. // // - When you rebuild the control, the .Net reference to it // // held by the C# form becomes invalid. // // - To fix that you have to: // // - add the control to the toolbox again, sigh // // - pull the control from the tool box onto the form // // again, sigh // // - fix up the event handler names, because when you pull // // the rebuild control onto the form it comes on with a // // modified name, double sigh // ///////////////////////////////////////////////////////////////// /// #include "stdafx.h" #include "test.h" STDMETHODIMP Ctest::Hello(LONG aNum) { ::Beep(2000,200); if(aNum < 0) return Error(_T("enter only positive numbers please")); m_lNumber = aNum; ::Sleep(500); Fire_Zap(m_lNumber); // fires event notification to client return S_OK; }