Solved

clipboard?

Posted on 1999-01-18
2
1,241 Views
Last Modified: 2013-11-20
hi everybody, now I use vc++5
I have some question about clipboard.
Can  I copy  data  in same clipboard format
( such as , CF_DIB with CF_DIB ) to  clipboard at same time and after copy Can I paste all data to use again.?

please suggest me  
thank you
0
Comment
Question by:eakkung
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1327875
1. Set the clipboard data (copy)

AfxGetMainWnd()->OpenClipboard() ;
EmptyClipboard()
SetClipboardData( CF_DIB, hDIB ) ;
CloseClipboard() ;

In the SetClipboardData call the first param says the type of data (CF_DIB for a DIB, CF_BITMAP for a DDB, CF_TEXT for text, etc.).  The second parameter is the handle to the data - e.g. a HANDLE to block of memory (from GlobalAlloc) for CF_DIB and CF_TEXT, or an HBITMAP for CF_BITMAP.

Multiple SetClipboardData calls can be used, if you want to place more than one format on the clipboard at the same time (e.g. a graphic in bitmap and metafile format).


2. To paste, check the clipboard contains a format you understand

BOOL bOK = IsClipboardFormatAvailable( CF_DIB ) ;

bOK is TRUE if the clipboard has the specified format, FALSE if not.  You might want to use this kind of code when deciding whether to gray/ungray the paste menu for example.


3. To actually do the paste

AfxGetMainWnd()->OpenClipboard() ;
HANDLE h = GetClipboardData( CF_DIB ) ;
CloseClipboard() ;

The handle that comes back is the clipboard data in the specified format (assuming the clipboard has it - see step #2)


4. The clipboard has a couple of concepts you should be aware of
(a) contains only 1 item (possibly in different formats) - when you add new stuff to the clipboard you should empty the clipboard of the old contents - my sample in step #1 does this
(b) When you give a handle to the clipboard - step #1 -  the clipboard now owns it, so you must no longer work with it.  If you still need your data, give the clipboard a copy of your real data.


5. If you are new to Visual C, and are less than 100% sure about bitmaps, I suggest you use CF_BITMAP rather than CF_DIB.  CF_BITMAP needs HBITMAPs which are easier to construct (e.g. LoadBitmap).  CF_DIB needs DIB which you construct by poking around in memory, which is harder unless you know what you're doing.  There are some good bitmap/DIB samples at www.codeguru.com
0
 

Author Comment

by:eakkung
ID: 1327876
Hi answer2000
      Thank you for your suggest but you didn't understand my
purpose. I would like to know how to copy several data
with same clipboard format at same time  (e.g. I have 2-3
picture(e.g. bmp)  and I would like to copy all of it at same time
 to clipboard.)
Now each I copy to clipboard I can copy one  picture. and
when I paste it same copy  too.  
Please suggest me again how to do follow my purpose
thank you

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 69
withoutTen challenge 14 132
changeXy challenge 13 89
Excel file not created as expected 7 79
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question