home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / ADS / CPP / DDE / DDECONX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  3.7 KB  |  109 lines

  1. /* 
  2.     DDECONX.CPP -
  3.     
  4.     This file:
  5.  
  6.         Defines pure virtual DDE connection object, DDE_CONNECTION. 
  7.  
  8.     (C) Copyright 1988-1994 by Autodesk, Inc.
  9.  
  10.     This program is copyrighted by Autodesk, Inc. and is  licensed
  11.     to you under the following conditions.  You may not distribute
  12.     or  publish the source code of this program in any form.   You
  13.     may  incorporate this code in object form in derivative  works
  14.     provided  such  derivative  works  are  (i.) are  designed and
  15.     intended  to  work  solely  with  Autodesk, Inc. products, and
  16.     (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright
  17.     1988-1994 by Autodesk, Inc."
  18.  
  19.     AUTODESK  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
  20.     AUTODESK  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
  21.     CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,  INC.
  22.     DOES  NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
  23.     UNINTERRUPTED OR ERROR FREE.
  24.  
  25. */
  26. #include "ddeinc.h"
  27.  
  28. //-----------------------------------------------------------------------------
  29. DDE_CONNECTION::DDE_CONNECTION()
  30. {
  31.     dde_service         = NULL;
  32.     dde_topic           = NULL;
  33.     dde_item            = NULL;
  34.     linkage             = HOT_LINK;
  35.     cur_conv            = new DDE_HCONV();
  36.     linking             = FALSE;
  37.     cur_format          = CF_TEXT;
  38.     connecting          = FALSE;
  39. }
  40.  
  41. //-----------------------------------------------------------------------------
  42. DDE_CONNECTION::~DDE_CONNECTION()
  43. {
  44.     if ( dde_service ) delete dde_service; dde_service = NULL;
  45.     if ( dde_topic ) delete dde_topic; dde_topic = NULL;
  46.     if ( dde_item ) delete dde_item; dde_item = NULL;
  47.     delete cur_conv;
  48. }
  49.  
  50. //-----------------------------------------------------------------------------
  51. BOOL DDE_CONNECTION::Valid()
  52. {
  53.     return ( cur_conv && cur_conv->Valid()
  54.             && dde_service && dde_service->Valid()
  55.             && dde_topic && dde_topic->Valid()
  56.             && dde_item && dde_item->Valid() );
  57. }
  58.  
  59. //-----------------------------------------------------------------------------
  60. BOOL DDE_CONNECTION::RemoveConnection()
  61. {
  62.     if ( linking )
  63.     {
  64.         Unlink();
  65.     }
  66.     return cur_conv->DisConnect();
  67. }
  68.  
  69. //-----------------------------------------------------------------------------
  70. //
  71. // This is used to initialize all variables in the class that are
  72. // depending on the construction of the class, like this pointer.
  73. //
  74. BOOL DDE_CONNECTION::Init( ADS_STRING& default_service_name 
  75.                                     , ADS_STRING& default_topic_name
  76.                                     , ADS_STRING& default_item_name )
  77. {
  78.     return ( InitService( default_service_name ) 
  79.             && InitTopic( default_topic_name )
  80.             && InitItem( default_item_name ) );
  81. }
  82.  
  83. //-----------------------------------------------------------------------------
  84. BOOL DDE_CONNECTION::InitService( ADS_STRING& service_name )
  85. {
  86.     ASSERT( dde_service == NULL );
  87.     dde_service = new DDE_SERVICE( this );
  88.     ASSERT( dde_service );
  89.     return ( dde_service->NewHandle( service_name ) != NULL );
  90. }
  91.  
  92. //-----------------------------------------------------------------------------
  93. BOOL DDE_CONNECTION::InitTopic( ADS_STRING& topic_name )
  94. {
  95.     ASSERT( dde_topic == NULL );
  96.     dde_topic = new DDE_TOPIC( this );
  97.     ASSERT( dde_topic );
  98.     return ( dde_topic->NewHandle( topic_name ) != NULL );
  99. }
  100. //-----------------------------------------------------------------------------
  101. BOOL DDE_CONNECTION::InitItem( ADS_STRING& item_name )
  102. {
  103.     ASSERT( dde_item == NULL );
  104.     dde_item = new DDE_ITEM( this );
  105.     ASSERT( dde_item );
  106.     return ( dde_item->NewHandle( item_name ) != NULL );
  107. }
  108.  
  109.