⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.cpp

📁 操作系统知识
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   DdeClientItem1->DdeConv=DdeClientConv1;
   // 设置链接,指定DDE服务:
   if( !(DdeClientConv1->SetLink("Project1","DdeServerConv1")) )
   {
      MessageBox(Handle, "链接失败", "错误", MB_OK|MB_ICONERROR);
      return;
   } 
   DdeClientItem1->DdeItem="DdeServerItem1";    // 指定DDE主题
   DdeClientConv1->OpenLink();                  // 打开链接
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DdeClientItem1Change(TObject *Sender)
{
   // 响应DDE服务器端数据的改变:
   Edit1->Text=DdeClientItem1->Text;   
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TStringList* BackStr = new TStringList;   // 回送信息
   
   DdeClientItem1->DdeItem="DdeServerItem1"; // 指定DDE项(DDE Item)
   //BackStr=TStringList.Create();
   try
   {
      BackStr->Add(Edit1->Text);        // 将Edit1组件中的字符回送
      if( !DdeClientConv1->PokeDataLines(DdeClientItem1->DdeItem, BackStr) )
         MessageBox(Handle, "回送数据失败", "错误", MB_OK|MB_ICONERROR);    
   }
   __finally
   {
      //BackStr.Free();
      delete BackStr;
   }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
   DdeClientConv1->CloseLink();  // 关闭链接   
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -