+ Reply to Thread
Results 1 to 2 of 2

Thread: Reading text data from clipboard.

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    29

    Reading text data from clipboard.

    I am developing a MFC application and developing a text editor. I want to know how can I read the data that is currently in the clipboard. I want to read text data. How to achieve this?

  2. #2
    Use following function.

    Code:
    CString ReadClipboardData()
    {
    	CString strClipboardData ;
    	
    	if (::OpenClipboard(NULL))
    	{
    		HANDLE hClipboardData = ::GetClipboardData(CF_TEXT) ;
    		if (NULL != hClipboardData)
    		{
    			char* pClipboardData = (char *) ::GlobalLock(hClipboardData) ;
    			strClipboardData = pClipboardData ;
    			::GlobalUnlock(pClipboardData) ;
    		}
    		::CloseClipboard() ;
    	}
    
    	return strClipboardData ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts