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 15 5056
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
Hi Lou,
It depends how your data have been put in the data object.
1. If you use one of the standard clipboard data formats (despite these are
clipboard data formats the actual data don't come from the clipboard)
lstItems.Items.Add (e.Data.GetData(DataFormats.Text)); for example
2. If the data have been given with private data format as a string
(SetData(string, object) overload)
you should use
For example for data format has been used the string "MyDataFormat"
lstItems.Items.Add (e.Data.GetData("MyDataFormat"));
3. For setting data has been used SetData(object) or SetData(Type, object)
overload. To retrieve the data:
For example data type is MyDataType and SetData(data) has been used
lstItems.Items.Add (e.Data.GetData(typeof(MyDataType)));
If different type has been used, say MyType, as DataFormat -
SetData(typeof(MyType), data)
lstItems.Items.Add (e.Data.GetData(typeof(MyType)));
But bare in mind that the data of expected format may not be in the data
object
So you have to check with
e.Data.GetDataPresent(...) or checking the returned object from GetData(...)
against *null* before using the data.
--
HTH
B\rgds
100
Lou,
Private clipboard formats are registered by their symbolic name (string).
You should know the name of the format (the string) because there is no way
to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" private void lstItems_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Creates a new data format. if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat"))
{
Object item = e.Data.GetData("MyFormat");
lstItems.Items.Add (item);
Debug.WriteLine ("Data preesent");
}
I haven't tested this so, if it doesn't work change the string "MyFormat"
with
DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a local
variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat");
use it like
e.Data.GetData(format);
HTH
B\rgds
100
It does not work.
I tried all the ones you mentioned
This really seems like it should be simple. the other app is just dropping
text with a registered clipboard
type. Why is this so difficult for me????
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("CF_MOSCtrlData"))
//if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")));
{
Object item = e.Data.GetData("MyFormat");
Object item = e.Data.GetData(DataFormats.GetFormat("MyFormat"));
lstItems.Items.Add (item);
//lstItems.Items.Add (e.Data.GetData("MyDataFormat"));
//Debug.WriteLine ("Data->" + (e.Data.GetData("MyDataFormat")));
//lstItems.Items.Add (e.Data.GetData(typeof(MyDataType)));
//lstItems.Items.Add (e.Data.GetData(typeof(MyType)));
}
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:uV*************@TK2MSFTNGP12.phx.gbl... Lou, Private clipboard formats are registered by their symbolic name (string). You should know the name of the format (the string) because there is no
way to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" private void lstItems_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Creates a new data format. if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat"))
{
Object item = e.Data.GetData("MyFormat");
lstItems.Items.Add (item);
Debug.WriteLine ("Data preesent");
}
I haven't tested this so, if it doesn't work change the string "MyFormat" with DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a local variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat"); use it like e.Data.GetData(format);
HTH B\rgds 100
If I add a watch to the "item" variable, I can see the data in the "buffer"
as bytes?
How can I get to that data? the line with lstItems.Items,Add does nothing?
Object item = e.Data.GetData("CF_MOSCtrlData");
lstItems.Items.Add (item.ToString());
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:uV*************@TK2MSFTNGP12.phx.gbl... Lou, Private clipboard formats are registered by their symbolic name (string). You should know the name of the format (the string) because there is no
way to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" private void lstItems_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Creates a new data format. if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat"))
{
Object item = e.Data.GetData("MyFormat");
lstItems.Items.Add (item);
Debug.WriteLine ("Data preesent");
}
I haven't tested this so, if it doesn't work change the string "MyFormat" with DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a local variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat"); use it like e.Data.GetData(format);
HTH B\rgds 100
Lou do you know how the other application prepares the dataobject?
Is it .NET application? Are you sure CF_MOSCtrlData is the string used to
register the format.
Usually CF_XXXXX are integer constants used for the well-known clipboard
formats.
If you have VS.NET try to use IDataObject Viewer utility. In my computer it
is located in
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\Bin\dobjview.exe
Start dobjview.exe drag something from your source program and drop it over
the IDataObject Viewer window. It will show all data formats the data have.
You will see the *string* names for all private formats. that name you have
to use with DataFormats.GetFormat method.
--
B\rgds
100
"Lou" <lo********@comcast.net> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl... It does not work. I tried all the ones you mentioned This really seems like it should be simple. the other app is just dropping text with a registered clipboard type. Why is this so difficult for me????
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("CF_MOSCtrlData"))
//if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")));
{
Object item = e.Data.GetData("MyFormat");
Object item = e.Data.GetData(DataFormats.GetFormat("MyFormat"));
lstItems.Items.Add (item);
//lstItems.Items.Add (e.Data.GetData("MyDataFormat"));
//Debug.WriteLine ("Data->" + (e.Data.GetData("MyDataFormat")));
//lstItems.Items.Add (e.Data.GetData(typeof(MyDataType)));
//lstItems.Items.Add (e.Data.GetData(typeof(MyType)));
} "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:uV*************@TK2MSFTNGP12.phx.gbl... Lou, Private clipboard formats are registered by their symbolic name
(string). You should know the name of the format (the string) because there is no way to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" private void lstItems_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Creates a new data format. if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat"))
{
Object item = e.Data.GetData("MyFormat");
lstItems.Items.Add (item);
Debug.WriteLine ("Data preesent");
}
I haven't tested this so, if it doesn't work change the string
"MyFormat" with DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a local variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat"); use it like e.Data.GetData(format);
HTH B\rgds 100
Lou,
In other words you do get data from the IDataObject, don't you?
What is the problem then?
--
B\rgds
100
"Lou" <lo********@comcast.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... If I add a watch to the "item" variable, I can see the data in the
"buffer" as bytes? How can I get to that data? the line with lstItems.Items,Add does nothing?
Object item = e.Data.GetData("CF_MOSCtrlData");
lstItems.Items.Add (item.ToString()); "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:uV*************@TK2MSFTNGP12.phx.gbl... Lou, Private clipboard formats are registered by their symbolic name
(string). You should know the name of the format (the string) because there is no way to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" private void lstItems_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Creates a new data format. if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat"))
{
Object item = e.Data.GetData("MyFormat");
lstItems.Items.Add (item);
Debug.WriteLine ("Data preesent");
}
I haven't tested this so, if it doesn't work change the string
"MyFormat" with DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a local variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat"); use it like e.Data.GetData(format);
HTH B\rgds 100
The other app is NOT a .Net app, its a standard windows app.
I can see the "item" object has a "buffer" section in the "Watch" window.
where I can see the data in bytes. Looks like unicode raw data.
I'm close but can't seem to get at the data?
- _buffer {Length=0xd8a} byte[]
[0x0] 0x3c byte
[0x1] 0x0 byte
[0x2] 0x6d byte
[0x3] 0x0 byte
[0x4] 0x6f byte
[0x5] 0x0 byte
[0x6] 0x73 byte
[0x7] 0x0 byte
[0x8] 0x3e byte
[0x9] 0x0 byte
[0xa] 0x3c byte
[0xb] 0x0 byte
[0xc] 0x6d byte
[0xd] 0x0 byte
[0xe] 0x6f byte
[0xf] 0x0 byte
[0x10] 0x73 byte
[0x11] 0x0 byte
[0x12] 0x49 byte
[0x13] 0x0 byte
and theres more
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl... Lou, In other words you do get data from the IDataObject, don't you? What is the problem then? -- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... If I add a watch to the "item" variable, I can see the data in the "buffer" as bytes? How can I get to that data? the line with lstItems.Items,Add does
nothing?
Object item = e.Data.GetData("CF_MOSCtrlData");
lstItems.Items.Add (item.ToString()); "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:uV*************@TK2MSFTNGP12.phx.gbl... Lou, Private clipboard formats are registered by their symbolic name (string). You should know the name of the format (the string) because there is
no way to know the numeric value. Since it might vary.
In this case I belive it is enough to do
Say the clipboard format has been registered as "MyFormat" > private void lstItems_DragDrop(object sender, > System.Windows.Forms.DragEventArgs e) > > { > > // Creates a new data format. > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > { > > Object item = e.Data.GetData("MyFormat"); > > lstItems.Items.Add (item); > > Debug.WriteLine ("Data preesent"); > > }
I haven't tested this so, if it doesn't work change the string "MyFormat" with DataFromats.GetFormat("MyFormat");
To save the calls to that method you can save the returned ID in a
local variable and use that variable instead.
int format = DataFormats.GetFormat("MyFormat"); use it like e.Data.GetData(format);
HTH B\rgds 100
Yeah, it seems the _buffer is not a public variable. Anyway the are should
be public method, property or indexer to get the data. what the "Watch"
says about the type of "item" what is it?
--
B\rgds
100
"Lou" <lo********@comcast.net> wrote in message
news:ek*************@TK2MSFTNGP10.phx.gbl... The other app is NOT a .Net app, its a standard windows app. I can see the "item" object has a "buffer" section in the "Watch" window. where I can see the data in bytes. Looks like unicode raw data. I'm close but can't seem to get at the data? - _buffer {Length=0xd8a} byte[] [0x0] 0x3c byte [0x1] 0x0 byte [0x2] 0x6d byte [0x3] 0x0 byte [0x4] 0x6f byte [0x5] 0x0 byte [0x6] 0x73 byte [0x7] 0x0 byte [0x8] 0x3e byte [0x9] 0x0 byte [0xa] 0x3c byte [0xb] 0x0 byte [0xc] 0x6d byte [0xd] 0x0 byte [0xe] 0x6f byte [0xf] 0x0 byte [0x10] 0x73 byte [0x11] 0x0 byte [0x12] 0x49 byte [0x13] 0x0 byte
and theres more "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:Oj**************@TK2MSFTNGP12.phx.gbl... Lou, In other words you do get data from the IDataObject, don't you? What is the problem then? -- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... If I add a watch to the "item" variable, I can see the data in the "buffer" as bytes? How can I get to that data? the line with lstItems.Items,Add does nothing?
Object item = e.Data.GetData("CF_MOSCtrlData");
lstItems.Items.Add (item.ToString()); "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:uV*************@TK2MSFTNGP12.phx.gbl... > Lou, > Private clipboard formats are registered by their symbolic name (string). > You should know the name of the format (the string) because there is no way > to know the numeric value. Since it might vary. > > In this case I belive it is enough to do > > Say the clipboard format has been registered as "MyFormat" > > private void lstItems_DragDrop(object sender, > > System.Windows.Forms.DragEventArgs e) > > > > { > > > > // Creates a new data format. > > > > > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > > > { > > > > Object item = e.Data.GetData("MyFormat"); > > > > lstItems.Items.Add (item); > > > > Debug.WriteLine ("Data preesent"); > > > > } > > I haven't tested this so, if it doesn't work change the string "MyFormat" > with > DataFromats.GetFormat("MyFormat"); > > To save the calls to that method you can save the returned ID in a local > variable and use that variable instead. > > int format = DataFormats.GetFormat("MyFormat"); > use it like > e.Data.GetData(format); > > HTH > B\rgds > 100 > >
I believe it was Object
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OO****************@TK2MSFTNGP10.phx.gbl... Yeah, it seems the _buffer is not a public variable. Anyway the are should be public method, property or indexer to get the data. what the "Watch" says about the type of "item" what is it?
-- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... The other app is NOT a .Net app, its a standard windows app. I can see the "item" object has a "buffer" section in the "Watch"
window. where I can see the data in bytes. Looks like unicode raw data. I'm close but can't seem to get at the data? - _buffer {Length=0xd8a} byte[] [0x0] 0x3c byte [0x1] 0x0 byte [0x2] 0x6d byte [0x3] 0x0 byte [0x4] 0x6f byte [0x5] 0x0 byte [0x6] 0x73 byte [0x7] 0x0 byte [0x8] 0x3e byte [0x9] 0x0 byte [0xa] 0x3c byte [0xb] 0x0 byte [0xc] 0x6d byte [0xd] 0x0 byte [0xe] 0x6f byte [0xf] 0x0 byte [0x10] 0x73 byte [0x11] 0x0 byte [0x12] 0x49 byte [0x13] 0x0 byte
and theres more "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:Oj**************@TK2MSFTNGP12.phx.gbl... Lou, In other words you do get data from the IDataObject, don't you? What is the problem then? -- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... > If I add a watch to the "item" variable, I can see the data in the "buffer" > as bytes? > How can I get to that data? the line with lstItems.Items,Add does nothing? > > > Object item = e.Data.GetData("CF_MOSCtrlData"); > > lstItems.Items.Add (item.ToString()); > > > > "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message > news:uV*************@TK2MSFTNGP12.phx.gbl... > > Lou, > > Private clipboard formats are registered by their symbolic name (string). > > You should know the name of the format (the string) because there
is no > way > > to know the numeric value. Since it might vary. > > > > In this case I belive it is enough to do > > > > Say the clipboard format has been registered as "MyFormat" > > > private void lstItems_DragDrop(object sender, > > > System.Windows.Forms.DragEventArgs e) > > > > > > { > > > > > > // Creates a new data format. > > > > > > > > > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > > > > > { > > > > > > Object item = e.Data.GetData("MyFormat"); > > > > > > lstItems.Items.Add (item); > > > > > > Debug.WriteLine ("Data preesent"); > > > > > > } > > > > I haven't tested this so, if it doesn't work change the string "MyFormat" > > with > > DataFromats.GetFormat("MyFormat"); > > > > To save the calls to that method you can save the returned ID in a local > > variable and use that variable instead. > > > > int format = DataFormats.GetFormat("MyFormat"); > > use it like > > e.Data.GetData(format); > > > > HTH > > B\rgds > > 100 > > > > > >
- item {System.IO.MemoryStream} System.Object
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OO****************@TK2MSFTNGP10.phx.gbl... Yeah, it seems the _buffer is not a public variable. Anyway the are should be public method, property or indexer to get the data. what the "Watch" says about the type of "item" what is it?
-- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... The other app is NOT a .Net app, its a standard windows app. I can see the "item" object has a "buffer" section in the "Watch"
window. where I can see the data in bytes. Looks like unicode raw data. I'm close but can't seem to get at the data? - _buffer {Length=0xd8a} byte[] [0x0] 0x3c byte [0x1] 0x0 byte [0x2] 0x6d byte [0x3] 0x0 byte [0x4] 0x6f byte [0x5] 0x0 byte [0x6] 0x73 byte [0x7] 0x0 byte [0x8] 0x3e byte [0x9] 0x0 byte [0xa] 0x3c byte [0xb] 0x0 byte [0xc] 0x6d byte [0xd] 0x0 byte [0xe] 0x6f byte [0xf] 0x0 byte [0x10] 0x73 byte [0x11] 0x0 byte [0x12] 0x49 byte [0x13] 0x0 byte
and theres more "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:Oj**************@TK2MSFTNGP12.phx.gbl... Lou, In other words you do get data from the IDataObject, don't you? What is the problem then? -- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... > If I add a watch to the "item" variable, I can see the data in the "buffer" > as bytes? > How can I get to that data? the line with lstItems.Items,Add does nothing? > > > Object item = e.Data.GetData("CF_MOSCtrlData"); > > lstItems.Items.Add (item.ToString()); > > > > "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message > news:uV*************@TK2MSFTNGP12.phx.gbl... > > Lou, > > Private clipboard formats are registered by their symbolic name (string). > > You should know the name of the format (the string) because there
is no > way > > to know the numeric value. Since it might vary. > > > > In this case I belive it is enough to do > > > > Say the clipboard format has been registered as "MyFormat" > > > private void lstItems_DragDrop(object sender, > > > System.Windows.Forms.DragEventArgs e) > > > > > > { > > > > > > // Creates a new data format. > > > > > > > > > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > > > > > { > > > > > > Object item = e.Data.GetData("MyFormat"); > > > > > > lstItems.Items.Add (item); > > > > > > Debug.WriteLine ("Data preesent"); > > > > > > } > > > > I haven't tested this so, if it doesn't work change the string "MyFormat" > > with > > DataFromats.GetFormat("MyFormat"); > > > > To save the calls to that method you can save the returned ID in a local > > variable and use that variable instead. > > > > int format = DataFormats.GetFormat("MyFormat"); > > use it like > > e.Data.GetData(format); > > > > HTH > > B\rgds > > 100 > > > > > >
- item {System.IO.MemoryStream} System.Object
- [System.IO.MemoryStream] {System.IO.MemoryStream} System.IO.MemoryStream
+ System.IO.Stream {System.IO.MemoryStream} System.IO.Stream
+ _buffer {Length=0x712} byte[]
_capacity 0x712 int
_expandable false bool
_exposable false bool
_isOpen true bool
_length 0x712 int
_origin 0x0 int
_position 0x0 int
_writable true bool
CanRead true bool
CanSeek true bool
CanWrite true bool
Capacity 0x712 int
Length 0x712 long
MemStreamMaxLength 0x7fffffff int
Position 0x0 long
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OO****************@TK2MSFTNGP10.phx.gbl... Yeah, it seems the _buffer is not a public variable. Anyway the are should be public method, property or indexer to get the data. what the "Watch" says about the type of "item" what is it?
-- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... The other app is NOT a .Net app, its a standard windows app. I can see the "item" object has a "buffer" section in the "Watch"
window. where I can see the data in bytes. Looks like unicode raw data. I'm close but can't seem to get at the data? - _buffer {Length=0xd8a} byte[] [0x0] 0x3c byte [0x1] 0x0 byte [0x2] 0x6d byte [0x3] 0x0 byte [0x4] 0x6f byte [0x5] 0x0 byte [0x6] 0x73 byte [0x7] 0x0 byte [0x8] 0x3e byte [0x9] 0x0 byte [0xa] 0x3c byte [0xb] 0x0 byte [0xc] 0x6d byte [0xd] 0x0 byte [0xe] 0x6f byte [0xf] 0x0 byte [0x10] 0x73 byte [0x11] 0x0 byte [0x12] 0x49 byte [0x13] 0x0 byte
and theres more "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:Oj**************@TK2MSFTNGP12.phx.gbl... Lou, In other words you do get data from the IDataObject, don't you? What is the problem then? -- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... > If I add a watch to the "item" variable, I can see the data in the "buffer" > as bytes? > How can I get to that data? the line with lstItems.Items,Add does nothing? > > > Object item = e.Data.GetData("CF_MOSCtrlData"); > > lstItems.Items.Add (item.ToString()); > > > > "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message > news:uV*************@TK2MSFTNGP12.phx.gbl... > > Lou, > > Private clipboard formats are registered by their symbolic name (string). > > You should know the name of the format (the string) because there
is no > way > > to know the numeric value. Since it might vary. > > > > In this case I belive it is enough to do > > > > Say the clipboard format has been registered as "MyFormat" > > > private void lstItems_DragDrop(object sender, > > > System.Windows.Forms.DragEventArgs e) > > > > > > { > > > > > > // Creates a new data format. > > > > > > > > > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > > > > > { > > > > > > Object item = e.Data.GetData("MyFormat"); > > > > > > lstItems.Items.Add (item); > > > > > > Debug.WriteLine ("Data preesent"); > > > > > > } > > > > I haven't tested this so, if it doesn't work change the string "MyFormat" > > with > > DataFromats.GetFormat("MyFormat"); > > > > To save the calls to that method you can save the returned ID in a local > > variable and use that variable instead. > > > > int format = DataFormats.GetFormat("MyFormat"); > > use it like > > e.Data.GetData(format); > > > > HTH > > B\rgds > > 100 > > > > > >
Yes, it can't be Object because Object class doesn't have _buffer member.
System.IO.MemoryStream that's it.
Read the stream the same way you would read a file. But what is the data
inside and what is the structure of the data you should know if you know
what CF_MOSCtrlData means.
To read the stream you can use the stream object directly or you can use one
of the reader classes
StreamReader, BinaryReader, etc
--
HTH
B\rgds
100
"Lou" <lo********@comcast.net> wrote in message
news:eC*************@TK2MSFTNGP10.phx.gbl... - item {System.IO.MemoryStream} System.Object - [System.IO.MemoryStream] {System.IO.MemoryStream} System.IO.MemoryStream + System.IO.Stream {System.IO.MemoryStream} System.IO.Stream + _buffer {Length=0x712} byte[] _capacity 0x712 int _expandable false bool _exposable false bool _isOpen true bool _length 0x712 int _origin 0x0 int _position 0x0 int _writable true bool CanRead true bool CanSeek true bool CanWrite true bool Capacity 0x712 int Length 0x712 long MemStreamMaxLength 0x7fffffff int Position 0x0 long
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:OO****************@TK2MSFTNGP10.phx.gbl... Yeah, it seems the _buffer is not a public variable. Anyway the are
should be public method, property or indexer to get the data. what the "Watch" says about the type of "item" what is it?
-- B\rgds 100
"Lou" <lo********@comcast.net> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... The other app is NOT a .Net app, its a standard windows app. I can see the "item" object has a "buffer" section in the "Watch" window. where I can see the data in bytes. Looks like unicode raw data. I'm close but can't seem to get at the data? - _buffer {Length=0xd8a} byte[] [0x0] 0x3c byte [0x1] 0x0 byte [0x2] 0x6d byte [0x3] 0x0 byte [0x4] 0x6f byte [0x5] 0x0 byte [0x6] 0x73 byte [0x7] 0x0 byte [0x8] 0x3e byte [0x9] 0x0 byte [0xa] 0x3c byte [0xb] 0x0 byte [0xc] 0x6d byte [0xd] 0x0 byte [0xe] 0x6f byte [0xf] 0x0 byte [0x10] 0x73 byte [0x11] 0x0 byte [0x12] 0x49 byte [0x13] 0x0 byte
and theres more "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message news:Oj**************@TK2MSFTNGP12.phx.gbl... > Lou, > In other words you do get data from the IDataObject, don't you? > What is the problem then? > -- > B\rgds > 100 > > > "Lou" <lo********@comcast.net> wrote in message > news:%2****************@TK2MSFTNGP11.phx.gbl... > > If I add a watch to the "item" variable, I can see the data in the > "buffer" > > as bytes? > > How can I get to that data? the line with lstItems.Items,Add does nothing? > > > > > > Object item = e.Data.GetData("CF_MOSCtrlData"); > > > > lstItems.Items.Add (item.ToString()); > > > > > > > > "Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message > > news:uV*************@TK2MSFTNGP12.phx.gbl... > > > Lou, > > > Private clipboard formats are registered by their symbolic name > (string). > > > You should know the name of the format (the string) because
there is no > > way > > > to know the numeric value. Since it might vary. > > > > > > In this case I belive it is enough to do > > > > > > Say the clipboard format has been registered as "MyFormat" > > > > private void lstItems_DragDrop(object sender, > > > > System.Windows.Forms.DragEventArgs e) > > > > > > > > { > > > > > > > > // Creates a new data format. > > > > > > > > > > > > > > > > if (e.Data.GetDataPresent(DataFormats.GetFormat("MyFo rmat")) > > > > > > > > { > > > > > > > > Object item = e.Data.GetData("MyFormat"); > > > > > > > > lstItems.Items.Add (item); > > > > > > > > Debug.WriteLine ("Data preesent"); > > > > > > > > } > > > > > > I haven't tested this so, if it doesn't work change the string > "MyFormat" > > > with > > > DataFromats.GetFormat("MyFormat"); > > > > > > To save the calls to that method you can save the returned ID in
a local > > > variable and use that variable instead. > > > > > > int format = DataFormats.GetFormat("MyFormat"); > > > use it like > > > e.Data.GetData(format); > > > > > > HTH > > > B\rgds > > > 100 > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: LG |
last post by:
Just have a question with regards to the clipboard, and how to read what
other applications (Adobe InDesignCS) place in the clipboard.
I am currently in the process of creating a booklet from a...
|
by: TC |
last post by:
Hello,
Here is what I'm trying to do:
-- Make sure both MS Excel and MS Word are running
-- Create an Excel chart
-- Save the Excel file
-- Copy the Excel chart onto the clipboard using Ctrl...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Ed Bitzer |
last post by:
Appreciate some help. Want to continuously check clipboard and if text
present unhide and display in a text. The following code can find nothing
in the clipboard even though I paste information...
|
by: James Russo |
last post by:
Hello,
I have an application which requires an image to be retrived from the
clipboard. So, I am writting a quick C# windows application to take
images from a webcam and store a single frame on...
|
by: Newbie |
last post by:
How do I clear the clipboard in VB.NET 2003?
TIA
Newbie
|
by: serge calderara |
last post by:
Dear all,
I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to...
|
by: Peter Duniho |
last post by:
I'm trying to use .NET and C# to draw a metafile copied to the clipboard by
another application (Word 2003 in this case, but it shouldn't matter).
I naively thought that I'd be able to use the...
|
by: active |
last post by:
Guess I'm looking for someone who likes to work difficult puzzles.
I can't seem to ever retrieve a palette handle from the clipboard.
Below is a simple test program that demonstrates the...
|
by: Joe Duchtel |
last post by:
Hello -
I have the following code to get a bitmap from the clipboard and to
save it to a *.png file ...
Dim lData As IDataObject = Clipboard.GetDataObject()
If...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |