home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / MYAUTO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-19  |  1.6 KB  |  60 lines

  1. /*
  2.   This object has one method and one property that are available via OLE
  3.   automation. The property allows you to set the value of a string, and
  4.   the method shows the string in a dialog.
  5.  
  6.   For this example to work, you need to run the TestAp program, stored in this
  7.   same directory. Before running TestAp, you should run this program once,
  8.   passing in /regserver as the program's sole parameter.
  9.  
  10.   Open up the DPR file to see the call to Automation.ServerRegistration. }
  11. */
  12.  
  13. int Initialization();
  14. static int Initializer = Initialization();
  15.  
  16. #undef RegisterClass
  17.  
  18. #include "myauto.h"
  19. #include <Dialogs.hpp>
  20.  
  21. __fastcall TMyAuto::TMyAuto() : TAutoObject(){
  22. }
  23.  
  24. void __fastcall TMyAuto::ShowDialog(){
  25.         if (FMyProp == ""){
  26.            FMyProp = "This object has a property called MyProp";
  27.            ShowMessage(FMyProp);
  28.         }
  29. }
  30.  
  31. void __fastcall TMyAuto::SetMyProp(String S){
  32.                 ShowMessage("In SetMyProp()");
  33.                 ShowMessage(S);
  34.  
  35.         FMyProp = S;
  36. }
  37.  
  38. String __fastcall TMyAuto::GetMyProp(){
  39.                 ShowMessage("In GetMyProp()");
  40.        return FMyProp;
  41. }
  42.  
  43. void RegisterMyAuto(){
  44.       TAutoClassInfo AutoClassInfo;
  45.       AutoClassInfo.AutoClass = __classid(TMyAuto);
  46.       AutoClassInfo.ProgID = "AUTOPROJ.MyAuto";
  47.       AutoClassInfo.ClassID = "{FE67CF61-2EDD-11CF-B536-0080C72EFD43}";
  48.       AutoClassInfo.Description = "Sam";
  49.       AutoClassInfo.Instancing = acMultiInstance;
  50.  
  51.       Automation->RegisterClass(AutoClassInfo);
  52. }
  53.  
  54. int Initialization(){
  55.   RegisterMyAuto();
  56.   return 0;
  57. }
  58.  
  59.  
  60.