Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

Clipboard backup (Visual C++)

4.58/5 (24 votes)
20 Sep 2005CPOL 2   1.6K  
Make a backup copy of clipboard data before your clipboard operation, and when you finish, you can restore clipboard to its original status.

Introduction

This piece of code is to help you backup your clipboard data and restore it after you have finished other clipboard operations.

My experience: while I'm developing Word add-in programs, the icon of the new-added button can only be set through clipboard by "...->PasteFace()". This will empty the clipboard data which is going to be pasted in Word. So, I wrote this class, and it helped me a lot.

Usage:

// the constructor will do backup clipboard operation
CClipboardBackup cbbackup;

// any other clipboard operations
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(......);
::CloseClipboard();
....

// restore
cbbackup.Restore();

Advertisement

By the way, my another article about another topic on another website :) :

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)