home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / ddedemo.pak / DDEFORM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  1.4 KB  |  62 lines

  1. unit Ddeform;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls, DdeMan;
  6.  
  7. { DDEDemo - This demo establishes a DDE conversation with the Program
  8.   Manager, and creates a program group by executing the CreateGroup
  9.   macro. The difficulties normally associated with DDE conversions
  10.   (such as timeouts, etc) are automatically handled by the
  11.   TDDEClient object. }
  12.  
  13. type
  14.   TForm1 = class(TForm)
  15.     Label1: TLabel;
  16.     GroupName: TEdit;
  17.     Label2: TLabel;
  18.     CreateButton: TButton;
  19.     Button2: TButton;
  20.     DDEClient: TDdeClientConv;
  21.     procedure Button2Click(Sender: TObject);
  22.     procedure CreateButtonClick(Sender: TObject);
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. uses Dialogs, SysUtils;
  33.  
  34. procedure TForm1.Button2Click(Sender: TObject);
  35. begin
  36.   Close;
  37. end;
  38.  
  39. procedure TForm1.CreateButtonClick(Sender: TObject);
  40. var
  41.   Name: string;
  42.   Macro: string;
  43.   Cmd: array[0..255] of Char;
  44. begin
  45.   if GroupName.Text = '' then
  46.     MessageDlg('Group name can not be blank.', mtError, [mbOK], 0)
  47.   else
  48.   begin
  49.     Name := GroupName.Text;
  50.     Macro := Format('[CreateGroup(%s)]', [Name]) + #13#10;
  51.     StrPCopy (Cmd, Macro);
  52.     DDEClient.OpenLink;
  53.     if not DDEClient.ExecuteMacro(Cmd, False) then
  54.       MessageDlg('Unable to create group.', mtInformation, [mbOK], 0);
  55.     DDEClient.CloseLink;
  56.     GroupName.SelectAll;
  57.   end;
  58. end;
  59.  
  60. end.
  61.  
  62.