473,793 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ 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
"GetClipboardDa taSize".

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

Thanks
Nov 20 '05 #1
2 9651
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 IsClipboardForm atAvailable Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function GetClipboardDat a 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 (IsClipboardFor matAvailable(CF _TEXT)) Then
TextPtr = GetClipboardDat a(CF_TEXT)

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

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

If (IsClipboardFor matAvailable(CF _BITMAP)) Then
hDIB = GetClipboardDat a(CF_BITMAP)

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

' Append palette size if required
If ((BMInfo.bmBits Pixel <= 8) And (BMInfo.bmBitsP ixel > 0))
Then _
DIBSize = DIBSize + (2 ^ BMInfo.bmBitsPi xel) * 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******** ******@tk2msftn gp13.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
11478
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 database, and I need the data to be laid out in a tabular format, and set out in a specific way. At the current point in time, I am copy/pasting the raw text from the database into a table layout in InDesign. What I was thinking is that if I could...
1
1990
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 VB.NET there is no image control for one and I get a type cast error while trying to save the contents of the clipboard using GetData() as an image Any help on this? VBUser
0
2006
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 to the clipboard (via ctrl-C, edit->copy, etc). They can then paste these values wherever (but in particular, excel). I've searched the web fairly exhaustively and cannot find an answer to this. Every time someone asks, somone answers with the...
2
4312
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 like to keep the previous content of the clipboard. Any examples I've found build on the format of the data, but I can't now in advance, what type of data on the clipboard will be. I can't even save and restore a part of simple formatted text...
0
3255
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 were to copy the image from Ms- Word and "Paste as New Image" in Photo Editor, I got the resolution 2288 x 1712. If I used the code below, I got the image size of 720 x 538 stored in PreviewBitmap variable. Why is the size of the picture...
7
11641
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
15
12305
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 Clipboard class to get an EnhancedMetafile or MetafilePict object from the Clipboard, use that to create a new Metafile object, and then draw that Metafile object using Graphics.DrawImage. It doesn't seem to be that simple.
8
2505
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 problem. The program uses windows api to get a handle to a palette from the clipboard. The palette needs to be put there by another program - maybe Photoshop.
2
2551
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 * g.DpiX ....
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.