472,345 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,345 software developers and data experts.

How to get clipboard data size?

yxq
Hello
I want to get Windows clipboard data size, seem to use the function
"GetClipboardDataSize".

Could anyone please tell how to do using vb.net?

Thanks
Nov 20 '05 #1
2 9492
Cor
Hi

Nice link about all from clipboard, dragging, I fin it very complete

http://msdn.microsoft.com/library/en...ardSupport.asp

I hope this helps,

Cor
Nov 20 '05 #2
yxq
Thanks

But i dont know how to get the size.

I found the vb6 code to get text and image size, but how to get all data
size?

'***
Private Declare Function OpenClipboard Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function GetClipboardData Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" _
(ByVal lpString As Long) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" _
(ByVal hObject As Long, ByVal nCount As Long, _
ByRef lpObject As Any) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32" _
(ByRef Destination As Any, ByRef Source As Any, _
ByVal Length As Long)

Private Type Bitmap ' 24 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type

Private Const CF_TEXT As Long = &H1
Private Const CF_BITMAP As Long = &H2

Private Sub Form_Load()
Dim TextPtr As Long
Dim DataPtr As Long
Dim ClipboardText As String
Dim hDIB As Long
Dim BMInfo As Bitmap
Dim DIBSize As Long
' Try and open the clipboard
If (OpenClipboard(Me.hwnd)) Then
If (IsClipboardFormatAvailable(CF_TEXT)) Then
TextPtr = GetClipboardData(CF_TEXT)

' De-reference the pointer
Call RtlMoveMemory(DataPtr, ByVal TextPtr, &H4)

Debug.Print "CF_TEXT size: " & BytesToDisplay(lstrlen(DataPtr))
Else
Debug.Print "No text in clipboard buffer"
End If

If (IsClipboardFormatAvailable(CF_BITMAP)) Then
hDIB = GetClipboardData(CF_BITMAP)

If (GetObject(hDIB, Len(BMInfo), BMInfo)) Then
' Get data and BMIH size
DIBSize = (BMInfo.bmWidthBytes * BMInfo.bmHeight) + 40

' Append palette size if required
If ((BMInfo.bmBitsPixel <= 8) And (BMInfo.bmBitsPixel > 0))
Then _
DIBSize = DIBSize + (2 ^ BMInfo.bmBitsPixel) * 4

Debug.Print "CF_BITMAP size: " & BytesToDisplay(DIBSize)
Else
Debug.Print "Error getting Bitmap information..."
End If
Else
Debug.Print "No DIB in clipboard buffer"
End If

' Make sure we close the clipboard before quitting
Call CloseClipboard
End If
End Sub

Private Function BytesToDisplay(ByVal inSize As Variant, _
Optional ByVal inShowBytes As Boolean = False) As String
Dim CheckSize As Variant, LastSize As Variant ' Coerced into decimal
Dim LoopSize As Long

CheckSize = CDec(1)
For LoopSize = 0 To 8
LastSize = CheckSize
CheckSize = (2 ^ 10) ^ LoopSize
If (CheckSize > inSize) Then Exit For
Next LoopSize

' Byte, KiloB., MegaB., GigaB., TeraB., PetaB., ExaB., ZettaB., YottaB.
BytesToDisplay = Format(inSize / IIf(LoopSize < 9, LastSize, CheckSize),
IIf(LoopSize > 1, "0.00", "0")) & " " & Choose(LoopSize, _
"bytes", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb")

If (inShowBytes And (LoopSize > 1)) Then _
BytesToDisplay = BytesToDisplay & (" (" & _
Format(inSize, "#,###,###,###,###,###,###,###,###") & " bytes)")
End Function
'***

"Cor" <no*@non.com> дÈëÓʼþ news:uQ**************@tk2msftngp13.phx.gbl...
Hi

Nice link about all from clipboard, dragging, I fin it very complete

http://msdn.microsoft.com/library/en...ardSupport.asp
I hope this helps,

Cor

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
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...
1
by: VB User | last post by:
Earlier in VB6, the image was copied onto the clipboard from the Image Processing Program . This image would then be loaded onto the image control...
0
by: Christopher | last post by:
Hello, First, I appologize for the length but I want to get all the facts down so as not to waste any time :) I'm trying to allow the user of my...
2
by: Mészáros Tamás | last post by:
Hi! Can I save and restore the content of the clipboard without dealing with the format it stores? I use the clipboard for data exchange between...
0
by: P N | last post by:
Hi all, I have question about copying picture from MS-Word into the Clipboard and then copy from the Clipboard into the bitmap variable within C#. ...
7
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...
15
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). ...
8
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...
2
by: Alexander Gorbylev | last post by:
Hi! Let the size of vector is e.g. 3.5". I render the same vector on a printer & a screen on the same procedure: printDoc_BeginPrint(object...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.