剪贴板对象 [英] Clipboard object

查看:77
本文介绍了剪贴板对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从注册数据类型获取clipbaord中的数据。

下面的代码片段不起作用?但是VB6的例子确实如此。

我做错了什么。

private void lstItems_DragDrop(对象发送者,

System.Windows.Forms.DragEventArgs e)


{


//创建一种新的数据格式。


DataFormats.Format myFormat = DataFormats.GetFormat(" myDataType");

//创建DataObject接口的新实例。


IDataObject data = Clipboard.GetDataObject( );

lstItems.Items.Add(data.GetData(myFormat));


}


In VB6这个工作,这看起来很简单。


私有子Text2_OLEDragDrop(数据为数据对象,效果为长,按钮为

整数,Shift为整数, X单身,Y单身)

My_Format = RegisterClipboardFormat(" myFormat")

Dim a()As Byte

a =数据。 GetData(My_Format)


MsgBox a

End Sub

解决方案

你好罗u,


Drag& Drop不使用剪贴板。所以,如果你检查剪贴板,就像你做的那样,你可能会找到一些东西,但它可能不会是你想要的b $ b。而不是阅读剪贴板使用

DragEventArgs参数的Data属性。您必须使用IDataObject来获取您拖动的数据




-

HTH

B \ rgds




" Lou" <螺******** @ comcast.net>在消息中写道

新闻:%2 ****************** @ tk2msftngp13.phx.gbl ...

如何从注册数据类型获取clipbaord中的数据。
下面的代码片段不起作用?但是VB6的例子确实如此。
我做错了什么。

private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

//创建一种新的数据格式。

DataFormats.Format myFormat = DataFormats.GetFormat(" myDataType");

//创建DataObject接口的新实例。

IDataObject data = Clipboard.GetDataObject();

lstItems.Items.Add(data.GetData(myFormat));



在VB6中这个工作,这看起来很简单。

私有Sub Text2_OLEDragDrop(数据为DataObject,效果为长,按钮
As Integer,Shift As Integer,X as Single,Y as Single)
My_Format = RegisterClipboardFormat(" myFormat")
Dim a()As Byte
a = Data.GetData (My_Format)

MsgBox a
End Sub



你能举个例子吗?

这将非常有帮助。

我正在努力克服来自VB的C#。


Stoitcho Goutsev(100)[C#MVP]" < 10*@100.com>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

嗨楼,

拖放不会使用剪贴板。因此,如果你检查剪贴板,就像你做的那样,你可能会在那里找到一些东西,但它可能不会是你所期望的。而不是读取剪贴板使用
DragEventArgs参数的Data属性。您必须使用IDataObject来获取拖动的数据。

-
HTH
B \ _ggds
100

娄 <螺******** @ comcast.net>在消息中写道
新闻:%2 ****************** @ tk2msftngp13.phx.gbl ...

我如何获得clipbaord中的数据来自已注册的数据类型。
下面的代码片段不起作用?但是VB6的例子确实如此。
我做错了什么。

private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

//创建一种新的数据格式。

DataFormats.Format myFormat = DataFormats.GetFormat(" myDataType");

//创建DataObject接口的新实例。

IDataObject data = Clipboard.GetDataObject();

lstItems.Items.Add(data.GetData(myFormat));



在VB6中这个工作,这看起来很简单。

Private Sub Text2_OLEDragDrop(Data As DataObject,Effect As Long,Button


As

Integer,Shift As Integer,X as Single,Y as Single)
My_Format = RegisterClipboardFormat(" myFormat")
Dim a( )作为Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub



这个窝rks标准文本但不是我的注册格式?

如果我从wordpad拖动文本它可以工作,但不能从我的其他应用程序中删除

" CF_MOSCtrlData" ????

private void lstItems_DragDrop(对象发送者,

System.Windows.Forms.DragEventArgs e)


{


//创建一种新的数据格式。

DataFormats.Format myFormat = DataFormats.GetFormat(" CF_MOSCtrlData");


if(e.Data.GetDataPresent(typeof(System.String)))


{


Object item =(object)e.Data.GetData(typeof(System.String));


lstItems.Items.Add(item);

Debug.WriteLine(" Data preesent");


}


" Stoitcho Goutsev(100)[C# MVP] QUOT; < 10*@100.com>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

嗨楼,

拖放不会使用剪贴板。因此,如果你检查剪贴板,就像你做的那样,你可能会在那里找到一些东西,但它可能不会是你所期望的。而不是读取剪贴板使用
DragEventArgs参数的Data属性。您必须使用IDataObject来获取拖动的数据。

-
HTH
B \ _ggds
100

娄 <螺******** @ comcast.net>在消息中写道
新闻:%2 ****************** @ tk2msftngp13.phx.gbl ...

我如何获得clipbaord中的数据来自已注册的数据类型。
下面的代码片段不起作用?但是VB6的例子确实如此。
我做错了什么。

private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

//创建一种新的数据格式。

DataFormats.Format myFormat = DataFormats.GetFormat(" myDataType");

//创建DataObject接口的新实例。

IDataObject data = Clipboard.GetDataObject();

lstItems.Items.Add(data.GetData(myFormat));



在VB6中这个工作,这看起来很简单。

Private Sub Text2_OLEDragDrop(Data As DataObject,Effect As Long,Button


As

Integer,Shift As Integer,X as Single,Y as Single)
My_Format = RegisterClipboardFormat(" myFormat")
Dim a( )作为Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub



How do I get the data in the clipbaord fro a registered data type.
The code snippet below doesn''t work? But the VB6 example does.
What am I doing wrong.
private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("myDataType");
// Create a new instance of the DataObject interface.

IDataObject data = Clipboard.GetDataObject();
lstItems.Items.Add (data.GetData(myFormat));

}

In VB6 this DOES work, this seems very simple.

Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button As
Integer, Shift As Integer, X As Single, Y As Single)
My_Format = RegisterClipboardFormat("myFormat")
Dim a() As Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub

解决方案

Hi Lou,

Drag&Drop doesn''t use the clipboard. So if you check the clipboard, as you
do, you might find something there, but it probably won''t be what you
expect. Instead of reading the clipboard use the Data property of the
DragEventArgs parameter. There is the IDataObject you have to use to get
your dragged data.

--
HTH
B\rgds
100

"Lou" <lo********@comcast.net> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...

How do I get the data in the clipbaord fro a registered data type.
The code snippet below doesn''t work? But the VB6 example does.
What am I doing wrong.
private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("myDataType");
// Create a new instance of the DataObject interface.

IDataObject data = Clipboard.GetDataObject();
lstItems.Items.Add (data.GetData(myFormat));

}

In VB6 this DOES work, this seems very simple.

Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
My_Format = RegisterClipboardFormat("myFormat")
Dim a() As Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub



Can you give me an example?
That would be very helpful.
i am struggling with C# comming from VB.

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

Hi Lou,

Drag&Drop doesn''t use the clipboard. So if you check the clipboard, as you
do, you might find something there, but it probably won''t be what you
expect. Instead of reading the clipboard use the Data property of the
DragEventArgs parameter. There is the IDataObject you have to use to get
your dragged data.

--
HTH
B\rgds
100

"Lou" <lo********@comcast.net> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...

How do I get the data in the clipbaord fro a registered data type.
The code snippet below doesn''t work? But the VB6 example does.
What am I doing wrong.
private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("myDataType");
// Create a new instance of the DataObject interface.

IDataObject data = Clipboard.GetDataObject();
lstItems.Items.Add (data.GetData(myFormat));

}

In VB6 this DOES work, this seems very simple.

Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button


As

Integer, Shift As Integer, X As Single, Y As Single)
My_Format = RegisterClipboardFormat("myFormat")
Dim a() As Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub




This works with standard text but not with my registered format?
if i drag text from wordpad it works but not from my other app that drops
"CF_MOSCtrlData" ???

private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("CF_MOSCtrlData");

if (e.Data.GetDataPresent(typeof(System.String)))

{

Object item = (object)e.Data.GetData(typeof(System.String));

lstItems.Items.Add (item);

Debug.WriteLine ("Data preesent");

}

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

Hi Lou,

Drag&Drop doesn''t use the clipboard. So if you check the clipboard, as you
do, you might find something there, but it probably won''t be what you
expect. Instead of reading the clipboard use the Data property of the
DragEventArgs parameter. There is the IDataObject you have to use to get
your dragged data.

--
HTH
B\rgds
100

"Lou" <lo********@comcast.net> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...

How do I get the data in the clipbaord fro a registered data type.
The code snippet below doesn''t work? But the VB6 example does.
What am I doing wrong.
private void lstItems_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

{

// Creates a new data format.

DataFormats.Format myFormat = DataFormats.GetFormat("myDataType");
// Create a new instance of the DataObject interface.

IDataObject data = Clipboard.GetDataObject();
lstItems.Items.Add (data.GetData(myFormat));

}

In VB6 this DOES work, this seems very simple.

Private Sub Text2_OLEDragDrop(Data As DataObject, Effect As Long, Button


As

Integer, Shift As Integer, X As Single, Y As Single)
My_Format = RegisterClipboardFormat("myFormat")
Dim a() As Byte
a = Data.GetData(My_Format)

MsgBox a
End Sub




这篇关于剪贴板对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆