Click here to Skip to main content
15,891,607 members
Articles / Programming Languages / C++
Article

Clipboard backup (Visual C++)

Rate me:
Please Sign up or sign in to vote.
4.58/5 (24 votes)
20 Sep 2005CPOL 151K   1.6K   51   27
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)


Written By
Software Developer (Senior)
China China
Begin coding from basic, since 1994. Interested in coding and database and website constructing.
My website: http://www.regexlab.com/ - Regular Expression Laboratory
The easiest regex engine: http://www.regexlab.com/deelx/

Comments and Discussions

 
AnswerRe: How to do it in c# Pin
sswater shi13-Oct-05 16:21
sswater shi13-Oct-05 16:21 
GeneralRe: How to do it in c# Pin
nagarsoft13-Oct-05 20:01
nagarsoft13-Oct-05 20:01 
GeneralRe: How to do it in c# Pin
sswater shi13-Oct-05 20:47
sswater shi13-Oct-05 20:47 
AnswerRe: How to do it in c# Pin
nagarsoft14-Oct-05 6:19
nagarsoft14-Oct-05 6:19 
GeneralVery useful class - thanks a lot! Pin
vkurdukov20-Sep-05 1:43
vkurdukov20-Sep-05 1:43 
GeneralRe: Very useful class - thanks a lot! Pin
sswater shi20-Sep-05 16:45
sswater shi20-Sep-05 16:45 
General#include <afxtempl.h> is needed. Pin
sswater shi23-Aug-05 15:56
sswater shi23-Aug-05 15:56 
GeneralRe: #include <afxtempl.h> is needed. Pin
lxdff23-Aug-05 16:25
lxdff23-Aug-05 16:25 
Very Good!

Attitude is anything

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.