Improve company productivity with a Business Account.Sign Up

x
?
Solved

clipboard?

Posted on 1999-01-18
2
Medium Priority
?
1,264 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 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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Go through the video which explain the procedure to export Amazon WorkMail single or multiple mailboxes to Outlook with Kernel Export Amazon WorkMail to PST tool. User can see the simple steps to export. It has salient features like filters (Include…

579 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