home *** CD-ROM | disk | FTP | other *** search
/ Program Metropolis - Software Boutique 95 / SOFTWARECD.iso / visio3 / disk4 / lib.c_ / lib.bin
Encoding:
Text File  |  1994-08-09  |  4.2 KB  |  158 lines

  1. /*    LIB.C - Source for Visio VSL Entry Point
  2.  *  Copyright (C) 1991-1994 Shapeware Corporation. All rights reserved.
  3.  *
  4.  *
  5.  *    Abstract
  6.  *        Provides the entry point for a Visio VSL.  Implements one add-on as
  7.  *        a demonstration of how C/C++ Automation add-ons can be run as a VSL
  8.  *        from within Visio's task space.
  9.  *
  10.  *    Routines:
  11.  *
  12.  *    VisioLibMain    Entry point that Visio calls.
  13.  *
  14.  */
  15.  
  16. /*    The only include dependency that is required by a VSL
  17.  *    is vao.h. Note that vao.h depends on types defined
  18.  *    defined in windows.h which it automatically includes
  19.  *    if necessary.
  20.  */
  21.  
  22. #include "vao.h"                                // Visio Add-ons interface
  23.  
  24.  
  25. /*
  26.  *    ADD-ON DESCRIPTORS
  27.  *
  28.  *    This is the information needed to describe hello's Add-ons to Visio.
  29.  *    This info is packed into an Add-on registration structure that gets
  30.  *    sent to Visio when Visio asks this library to enumerate its Add-ons.
  31.  */
  32.  
  33. enum AddOnIndexes
  34. {
  35.     IDX_DEMO                        = 1,
  36. };
  37.  
  38. PRIVATE VAOREGSTRUCT stc_myAddons[] =
  39. {
  40.     {
  41.     IDX_DEMO,                    // Ordinal of Add-on
  42.     VAO_AOATTS_ISACTION | VAO_AOATTS_HASABOUT,
  43.     VAO_ENABLEALWAYS,            // It is is always enabled.
  44.     0,
  45.     0,
  46.     "VSL Automation Demo",        // Name shown in Visio's "run Add-on" dialog.
  47.     },
  48. };
  49.  
  50. //
  51. //    FUNCTION:    VisioLibMain(VAOMSG,WORD,LPVOID)
  52. //
  53. //    PURPOSE:    VisioLibMain() implements the Visio/Add-on protocol defined
  54. //                in vao.h. When Visio loads this library, it will do a 
  55. //                GetProcAddress(VisioLibMain) and then start calling
  56. //                VisioLibMain() at appropriate times.
  57. //
  58. //                When Visio calls VisioLibMain(), it will pass a directive
  59. //                (wMsg) to VisioLibMain() indicating what is to be done.
  60. //                Associated with the message will be a word argument and a
  61. //                far pointer argument. The meaning of these is dependent on
  62. //                wMsg.
  63. //
  64. //                This sample Add-on library is pretty simple. For most types
  65. //                of messages that Visio can pass to it, VisioLibMain() can
  66. //                simply call the Visio Add-on utility that provides default
  67. //                responses to Visio messages, namely VAOUtil_DefVisMainProc().
  68. //
  69. //                The only messages that generic.vsl's VisioLibMain() must
  70. //                respond to are those that implement behavior specific to
  71. //                generic.vsl. Generic.vsl must register those Add-ons it
  72. //                implements, and it must be able to run the Add-ons it
  73. //                implements. Running "VSL Automation Demo" entails calling
  74. //                RunDemo and simple returning when it's done.
  75. //
  76.  
  77. VAORC VAOCB VisioLibMain ( VAOMSG wMsg, WORD wParam, LPVOID lpParam )
  78.     {
  79.     VAORC result = VAORC_SUCCESS;
  80.  
  81.     switch ( wMsg )
  82.         {
  83.         case V2LMSG_ENUMADDONS:
  84.             {
  85.             // wParam:      0
  86.             // lpParam: LPVAOV2LSTRUCT
  87.             //
  88.             // Visio is telling us to register this library's Add-ons.
  89.             // The Visio Add-on utility VAOUtil_RegisterAddons() will
  90.             // do this for us if we pass it a pointer to descriptors
  91.             // for this lib's Add-ons, namely stc_myAddons which was
  92.             // declared above.
  93.             //
  94.             result = VAOUtil_RegisterAddons(
  95.                             ((LPVAOV2LSTRUCT)lpParam)->wSessID,
  96.                             stc_myAddons,
  97.                             sizeof(stc_myAddons)/sizeof(VAOREGSTRUCT));
  98.             break;
  99.             }
  100.  
  101.         case V2LMSG_RUN:
  102.             {
  103.             // wParam:      Ordinal of Add-on to run
  104.             // lpParam: LPVAOV2LSTRUCT
  105.             //
  106.             // Visio is telling us to run the Add-on with the given ordinal.
  107.             // In the case of ordinal 1, we want to run the automation demo.
  108.             //
  109.  
  110.             int RunDemo();
  111.             
  112.             switch ( wParam )
  113.                 {
  114.                 case IDX_DEMO:
  115.                     RunDemo();
  116.                     break;
  117.                 default:
  118.                     /* Unknown Add-on ordinal passed */
  119.                     break;
  120.                 }
  121.                 
  122.             break;
  123.             }
  124.  
  125.         case V2LMSG_RUNABOUT:
  126.             {
  127.             // wParam:      Ordinal of Add-on
  128.             // lpParam: 
  129.             //
  130.             // Visio is telling us to run the Add-ons about dialog.
  131.             // In the case of ordinal 1, we want to run the automation demo.
  132.             //
  133.  
  134.             int ShowAboutDialog(HINSTANCE);
  135.             
  136.             switch ( wParam )
  137.                 {
  138.                 case IDX_DEMO:
  139.                     ShowAboutDialog(VLIBUTL_hModule());
  140.                     break;
  141.                 default:
  142.                     /* Unknown Add-on ordinal passed */
  143.                     break;
  144.                 }
  145.                 
  146.             break;
  147.             }
  148.  
  149.         default:
  150.             result = VAOUtil_DefVisMainProc(wMsg, wParam,
  151.                                             lpParam, VLIBUTL_hModule());
  152.             break;
  153.         };
  154.  
  155.     return result;
  156.     }
  157.  
  158.