Solved

clipboard?

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

12 Experts available now in Live!

Get 1:1 Help Now