Solved

clipboard?

Posted on 1999-01-18
2
1,233 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 111
Execute multiple curl cmds with sleep and send output to file 10 88
sumHeights  challenge 17 66
Is there a simple front-end menu system. 9 70
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now