MFC, Text to clipboard


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. void SetClipboardText( LPCSTR pText )
  2. {
  3. HGLOBAL h;
  4. LPTSTR arr;
  5.  
  6. int size = strlen(pText)+1;
  7.  
  8. h=GlobalAlloc(GMEM_MOVEABLE, size);
  9. arr=(LPTSTR)GlobalLock(h);
  10. strcpy_s((char*)arr, size, pText);
  11. GlobalUnlock(h);
  12.  
  13. ::OpenClipboard (NULL);
  14. EmptyClipboard();
  15. SetClipboardData(CF_TEXT, h);
  16. CloseClipboard();
  17. }

URL: stackoverflow.com/questions/2253476/does-mfc-provide-a-quick-way-to-throw-text-on-the-clipboard

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.