procedure TForm1.ManualRadioClick(Sender: TObject); begin if Automatic then begin RequestBtn.Enabled := ManualRadio.Checked; DDEClientConv1.ConnectMode := ddeManual; Automatic := False; end; end;
人工模式转换为自动模式:
procedure TForm1.AutoRadioClick(Sender: TObject); begin if not Automatic then begin RequestBtn.Enabled := ManualRadio.Checked; If (DDEService = '''''''') or (DDETopic = '''''''') then begin MessageDlg('''' Can not Set Link.'''',mtWarning,[mbOK],0); Exit; end; DDEClientConv1.SetLink (DDEService, DDETopic); DDEClientItem1.DdeConv := DDEClientConv1; DDEClientItem1.DDEItem := DDEItem; DDEClientConv1.ConnectMode := ddeAutomatic; Automatic := True; end; end;
procedure TForm1.PasteBtnClick(Sender: TObject); begin if GetPasteLinkInfo (DDEService, DDETopic, DDEItem) then begin DDEClientConv1.SetLink (DDEService, DDETopic); if Automatic then begin DDEClientItem1.DdeConv := DDEClientConv1; DDEClientItem1.DDEItem := DDEItem; end; end; end;
procedure TForm1.RequestBtnClick(Sender: TObject); var TheData: PChar; begin If DDEItem = '''''''' then begin MessageDlg(''''Can not Request Data'''',mtWarning,[mbOK],0); Exit; end; TheData := StrAlloc(79);
DDEClientConv1.OpenLink;
TheData := DDEClientConv1.RequestData(DDEItem);
DDEClientConv1.CloseLink;
if TheData <> nil then Memo1.Text := StrPas(TheData); StrDisPose(TheData); end;