Retrieving Locale data from the clipboard

  • Thread starter Thread starter active
  • Start date Start date
A

active

I'm trying to retrieve Locale data from the clipboard.

I'm not sure if I should use Stream to MemoryStream. I tried both and the
most I could obtain was 4 bytes from the clipboard.

Anyone know how to retrieve Locale data using managed code?

I been trying things like the following:


Dim iData2 As IDataObject = Clipboard.GetDataObject()
If iData2.GetDataPresent(DataFormats.Locale) Then
Dim obj As Object = iData2.GetData(DataFormats.Locale)
If TypeOf obj Is MemoryStream Then
Dim lBuffer(16) As Byte
Dim lCount As Integer
Dim lStream As MemoryStream = CType(obj, MemoryStream)
Dim r As New BinaryReader(lStream)
While (lCount = lStream.Read(lBuffer, 0, 16)) > 0
Dim str As String = ConvertToString( lBuffer, lCount)
RichEditControl1.TxtSelectedText = str & vbCrLf
End While
End If
End If

Even if it does not solve the entire problem if anyone has any sugestions
that I could try I'd appreciate learning about them.


Thanks
 
Hi active,

The memorystream has nothing to do with copy cut and paste, it gives a
methode to avoid writing to a disk and back if you need to process streaming
data.

I placed beneath a sample for a copy and paste of text.

Also a link

http://msdn.microsoft.com/library/en-us/vbcon/html/vbconDragDropClipboardSupport.asp
Here is everything nice described.

I hope this was what you needed?

Cor

Copy
\\\
Me.textbox1.SelectAll()
Clipboard.SetDataObject(me.textbox1.SelectedText)
///
Paste
\\\
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.Text) Then
Me.textbox2.Text = CType(iData.GetData(DataFormats.Text), String)
Else
Me.textbox2.Text = ""
End If
///
 
Thanks I got it worked out. I was expecting the locale data from the
clipboard but all that's on it is the LCID which is why I could only find 4
bytes on the clipboard.

Dim objLocale As Object = iData2.GetData(DataFormats.Locale)

returns a stream which I not too familiar with which is why the question.



Thanks

Cal
 
Back
Top