Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transferring clipboard data to file and vice-versa?

Status
Not open for further replies.

rpk2006

Technical User
Apr 24, 2002
225
IN
I want to transfer clipboard text to a file, and when the file processing is finished, again transfer the file data back to clipboard.

I actually want to do this to compress the text and then re-transfer back the compressed data.
 
Code:
BOOL CMyEdit::GetClipboardBuffer(CString& cBuffer)
{
	BOOL bPresent = FALSE;
	HGLOBAL hglb;
	LPTSTR lptstr;

	if ( OpenClipboard() )
	{
		hglb = GetClipboardData(CF_TEXT);
		if (hglb != NULL)
		{
			lptstr = (LPTSTR)GlobalLock(hglb);
			if ( lptstr != NULL )
			{
				cBuffer = lptstr;
				bPresent = TRUE;
				GlobalUnlock(hglb);
			}
		}
		CloseClipboard();
	}
	return bPresent;
}
Now use CStdioFile object and write cBuffer in a file.
Next, read the file in the cBuffer and place it calling SetClipboardData();
-obislavu-
 
Thanks a lot. I would appreciate if you illustrate the other part also, since I am entirely new to VC++.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top