Return to Snippet

Revision: 44286
at April 9, 2011 02:19 by jimfred


Initial Code
void SetClipboardText( LPCSTR pText )
{
    HGLOBAL h;
    LPTSTR arr;

    int size = strlen(pText)+1;

    h=GlobalAlloc(GMEM_MOVEABLE, size);
    arr=(LPTSTR)GlobalLock(h);
    strcpy_s((char*)arr, size, pText);
    GlobalUnlock(h);

    ::OpenClipboard (NULL);
    EmptyClipboard();
    SetClipboardData(CF_TEXT, h);
    CloseClipboard();
}

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

Initial Description

                                

Initial Title
MFC, Text to clipboard

Initial Tags

                                

Initial Language
C++