Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

clipboard?

Posted on 1999-01-18
2
Medium Priority
?
1,258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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