473,473 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 9632
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 currently in the process of creating a booklet from a...
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 on the VB form using GetData() function. In...
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 C# app to copy a DataGrid full of double values...
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 applications (this is the only way), and I would...
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#. The original image size is 2288 x 1712. If I...
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 was easy. But pasting an image from 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). I naively thought that I'd be able to use the...
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 a simple test program that demonstrates the...
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 sender, PrintEventArgs e) { .... vector.Width *...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.