home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 June / HDC50.iso / Runimage / Delphi50 / Doc / DDEMAN.INT < prev    next >
Text File  |  1999-08-11  |  5KB  |  150 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {       Copyright (c) 1995,99 Inprise Corporation       }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit DdeMan;
  11.  
  12. {$R-,T-,H+,X+}
  13.  
  14. interface
  15.  
  16. uses
  17.   Windows, Classes, Graphics, Forms, Controls, DDEML, StdCtrls;
  18.  
  19. type
  20.   TDataMode = (ddeAutomatic, ddeManual);
  21.   TDdeServerConv = class;
  22.  
  23.   TMacroEvent = procedure(Sender: TObject; Msg: TStrings) of object;
  24.  
  25.   TDdeClientItem = class;
  26.  
  27. { TDdeClientConv }
  28.  
  29.   TDdeClientConv = class(TComponent)
  30.   protected
  31.     function CreateDdeConv(FHszApp: HSZ; FHszTopic: HSZ): Boolean;
  32.     function GetCliItemByName(const ItemName: string): TPersistent;
  33.     function GetCliItemByCtrl(ACtrl: TDdeClientItem): TPersistent;
  34.     procedure Loaded; override;
  35.     procedure DefineProperties(Filer: TFiler); override;
  36.     procedure ReadLinkInfo(Reader: TReader);
  37.     procedure WriteLinkInfo(Writer: TWriter);
  38.     function OnSetItem(aCtrl: TDdeClientItem; const S: string): Boolean;
  39.     procedure OnAttach(aCtrl: TDdeClientItem);
  40.     procedure OnDetach(aCtrl: TDdeClientItem);
  41.     procedure Close; dynamic;
  42.     procedure Open; dynamic;
  43.     function ChangeLink(const App, Topic, Item: string): Boolean;
  44.     procedure ClearItems;
  45.     procedure Notification(AComponent: TComponent;
  46.       Operation: TOperation); override;
  47.   public
  48.     constructor Create(AOwner: TComponent); override;
  49.     destructor Destroy; override;
  50.     function PasteLink: Boolean;
  51.     function OpenLink: Boolean;
  52.     function SetLink(const Service, Topic: string): Boolean;
  53.     procedure CloseLink;
  54.     function StartAdvise: Boolean;
  55.     function PokeDataLines(const Item: string; Data: TStrings): Boolean;
  56.     function PokeData(const Item: string; Data: PChar): Boolean;
  57.     function ExecuteMacroLines(Cmd: TStrings; waitFlg: Boolean): Boolean;
  58.     function ExecuteMacro(Cmd: PChar; waitFlg: Boolean): Boolean;
  59.     function RequestData(const Item: string): PChar;
  60.     property DdeFmt: Integer;
  61.     property WaitStat: Boolean;
  62.     property Conv: HConv;
  63.     property DataMode: TDataMode;
  64.   published
  65.     property ServiceApplication: string;
  66.     property DdeService: string;
  67.     property DdeTopic: string;
  68.     property ConnectMode: TDataMode default ddeAutomatic;
  69.     property FormatChars: Boolean default False;
  70.     property OnClose: TNotifyEvent;
  71.     property OnOpen: TNotifyEvent;
  72.   end;
  73.  
  74. { TDdeClientItem }
  75.  
  76.   TDdeClientItem = class(TComponent)
  77.   protected
  78.     procedure Notification(AComponent: TComponent;
  79.       Operation: TOperation); override;
  80.   public
  81.     constructor Create(AOwner: TComponent); override;
  82.     destructor Destroy; override;
  83.   published
  84.     property Text: string;
  85.     property Lines: TStrings;
  86.     property DdeConv: TDdeClientConv;
  87.     property DdeItem: string;
  88.     property OnChange: TNotifyEvent;
  89.   end;
  90.  
  91. { TDdeServerConv }
  92.  
  93.   TDdeServerConv = class(TComponent)
  94.   protected
  95.     procedure Connect; dynamic;
  96.     procedure Disconnect; dynamic;
  97.   public
  98.     constructor Create(AOwner: TComponent); override;
  99.     destructor Destroy; override;
  100.     function ExecuteMacro(Data: HDdeData): LongInt;
  101.   published
  102.     property OnOpen: TNotifyEvent;
  103.     property OnClose: TNotifyEvent;
  104.     property OnExecuteMacro: TMacroEvent;
  105.   end;
  106.  
  107. { TDdeServerItem }
  108.  
  109.   TDdeServerItem = class(TComponent)
  110.   protected
  111.     function GetText: string;
  112.     procedure SetText(const Item: string);
  113.     procedure SetLines(Value: TStrings);
  114.     procedure SetServerConv(SConv: TDdeServerConv);
  115.     procedure Notification(AComponent: TComponent;
  116.       Operation: TOperation); override;
  117.   public
  118.     constructor Create(AOwner: TComponent); override;
  119.     destructor Destroy; override;
  120.     function PokeData(Data: HDdeData): LongInt;
  121.     procedure CopyToClipboard;
  122.     procedure Change; dynamic;
  123.     property Fmt: Integer;
  124.   published
  125.     property ServerConv: TDdeServerConv;
  126.     property Text: string;
  127.     property Lines: TStrings;
  128.     property OnChange: TNotifyEvent;
  129.     property OnPokeData: TNotifyEvent;
  130.   end;
  131.  
  132. { TDdeMgr }
  133.  
  134.   TDdeMgr = class(TComponent)
  135.   public
  136.     constructor Create(AOwner: TComponent); override;
  137.     destructor Destroy; override;
  138.     function GetExeName: string;     // obsolete
  139.     property DdeInstId: LongInt;
  140.     property AppName: string;
  141.     property LinkClipFmt: Word;
  142.   end;
  143.  
  144.   function GetPasteLinkInfo(var Service: string; var Topic: string;
  145.     var Item: string): Boolean;
  146. var
  147.   ddeMgr: TDdeMgr;
  148.  
  149. implementation
  150.