切换到宽版
  • 7378Read
  • 1Replay

NDde [复制链接]

上一主题 下一主题
离线Francis
 

只看楼主 倒序阅读 使用道具 楼主  posttime: 2016-04-12
DDE的全名为动态数据交换,主要是用在资料交换用。
而今天介绍的NDDE则是基于DDE环境下开发出来的开放源代码。

透过NDDE的协助,可以利用VB.net等程式语言来接收DDE资料,
或是架设成DDE服务器发送资料给其它客户端的DDE等。
      

Home
https://ndde.codeplex.com/

Help
http://www.5ichai.com/NDde/

GIthub
https://github.com/afedyanin/dde-net

CSDN--有错误需要加变量类型
http://blog.csdn.net/cncdns/article/details/8526887

C#与NDde-如何连结超级大三元

    

VB 例子
http://darkstorageroom.blogspot.com/2011/12/ndde-client.html
http://darkstorageroom.blogspot.com/2012/01/ndde-server.html

DDE wikipedia
https://en.wikipedia.org/wiki/Dynamic_Data_Exchange

NDDE_samples
http://www.limnor.com/support/NDDE_samples.pdf







离线Francis

只看该作者 沙发  posttime: 2016-04-12
續前文(台証超級大三元DDE)從Excel中找到需要的項目運算式,接著便是用C#與NDde去連結那些項目,以下就Visual C# 2008 Express為開發工具記錄作法。

0. 先啟動並登入台証超級大三元
登入台証超級大三元

1. 開啟新專案Windows Form應用程式
Windows Form應用程式

2. 在右邊方案總管的參考上按右鍵選加入參考
加入參考

3. 瀏覽到下載NDde的路徑,撰擇NDde.dll
NDde.dll

4. 從左邊工具箱中拉三個Label到Form1裡
拉三個Label到Form1

5. 在右邊方案總管的Form1.cs上按右鍵選檢視程式碼
檢視程式碼

6. 最後複製並貼上下述範例代碼
純文字複製列印?

    using System;  
    using System.Collections.Generic;  
    using System.ComponentModel;  
    using System.Data;  
    using System.Drawing;  
    using System.Linq;  
    using System.Text;  
    using System.Windows.Forms;  
    using NDde.Client;  
      
    namespace WindowsFormsApplication1  
    {  
        public partial class Form1 : Form  
        {  
            public Form1()  
            {  
                InitializeComponent();  
      
                //超級大三元每一個item都需要建立一個DDE連結,所以用陣列的方式建了三個  
                //如何找到大三元的連結參數TS及KS就不贅述了,請自行參閱blog文(台証超級大三元DDE)  
                DdeClient[] ddecon = new DdeClient[3] { new DdeClient("TS", "KS"), new DdeClient("TS", "KS"), new DdeClient("TS", "KS") };  
      
                for (int i=0;i<3;i++)  
                {  
                    try  
                    {  
                        ddecon.Connect();  
                    }  
                    catch (Exception e) { MessageBox.Show(e.ToString()); }  
                }  
      
                //連結並關注item,以下item分別表示時間、成交價及單量  
                //如何找到TXFL9.123等連結參數就不贅述了,請自行參閱blog文(台証超級大三元DDE)  
                ddecon[0].StartAdvise("TXFL9.123", 1, true, 60000);  
                ddecon[0].Advise += OnAdvise;  
      
                ddecon[1].StartAdvise("TXFL9.124", 1, true, 60000);  
                ddecon[1].Advise += OnAdvise;  
      
                ddecon[2].StartAdvise("TXFL9.128", 1, true, 60000);  
                ddecon[2].Advise += OnAdvise;  
            }  
      
            private void OnAdvise(object sender, DdeAdviseEventArgs args)  
            {  
                //如果NDde有通知參數值有異動,就更改label值  
                if (args.Item == "TXFL9.123") myUI(args.Text, label1);  
                else if (args.Item == "TXFL9.124") myUI(args.Text, label2);  
                else if (args.Item == "TXFL9.128") myUI(args.Text, label3);  
            }  
      
            //Form上變更Text函數,請參閱http://www.dotblogs.com.tw/yc421206/archive/2009/02/13/7141.aspx  
            private delegate void myUICallBack(string myStr, Control ctl);  
            private void myUI(string myStr, Control ctl)  
            {  
                if (this.InvokeRequired)  
                {  
                    myUICallBack myUpdate = new myUICallBack(myUI);  
                    this.Invoke(myUpdate, myStr, ctl);  
                }  
                else  
                {  
                    ctl.Text = myStr;  
                }  
            }  
        }  
    }  

7. 執行結果
執行結果

註1:記得下載NDde並解壓縮
註2:此範例可從這裡下載原始碼
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个