using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Data.SqlClient;
using System.Text;
using System.Runtime.Remoting.Messaging;
using JuYuan.Lcq;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
///
class transferAPI
{
[StructLayout(LayoutKind.Sequential)]
private struct LPPOINT
{
public int X;
public int Y;
}
[DllImport("GDI32.DLL")]
static extern bool MoveToEx(IntPtr hdc,int X,int Y,LPPOINT lpPoint);
private int ordx;
private int ordy;
private LPPOINT m_point;
private Graphics m_g;
private IntPtr m_hDC;
public void begin
Move(Graphics g, int x,int y) //Call at MouseDown
{
m_g=g;
m_hDC=m_g.GetHdc();
ordx=x;
ordy=y;
m_point=new LPPOINT();
m_point.X=x;
m_point.Y=y;
}
public void Move(int x,int y) //call at MouseMove
{
MoveToEx(m_hDC,x,y,m_point);
}
}
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlCommand sqlCommand1;
private System.Data.DataView dataView1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private FileStream fileStm;
private byte[] readBuf;
private System.Windows.Forms.Button button2;
private static AsyncCallback Callback;
private transferAPI api;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataView1 = new System.Data.DataView();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).begin
Init();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(288, 32);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(8, 80);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(672, 296);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "richTextBox1";
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "data source=C://Documents and Settings//Administrator//Mydo
cuments//db1.mdb;password" +
"=/"/";user id=Admin";
//
// sqlCommand1
//
this.sqlCommand1.Connection = this.sqlConnection1;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(232, 56);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(384, 32);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(120, 32);
this.button2.TabIndex = 3;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(696, 421);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button2,
this.label1,
this.richTextBox1,
this.button1});
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
api = new transferAPI();
}
private void button1_Click(object sender, System.EventArgs e)
{
Callback = new AsyncCallback(CallBackFunction);
fileStm = new FileStream(@"c:/key.txt", FileMode.Open, FileAccess.Read, FileShare.Read, 64, true);
readBuf = new byte[fileStm.Length];
fileStm.begin
Read(readBuf, 0, readBuf.Length, Callback, null);
for(long i = 0;
i < 5000;
i++)
{
if(i % 1000 == 0)
{
richTextBox1.Text += "Execution in Main" + i.ToString() + "/r";
}
}
MyClass1 myClass1 = new MyClass1();
}
private void CallBackFunction(IAsyncResult asyncResult)
{
int readB = fileStm.EndRead(asyncResult);
if(readB > 0)
{
fileStm.begin
Read(readBuf, 0, readBuf.Length, Callback, null);
richTextBox1.Text += Encoding.ASCII.GetString(readBuf, 0, readB);
}
}
private void button2_Click(object sender, System.EventArgs e)
{
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
api.Move(e.X, e.Y);
}
}
}
你试试看