Name: Anonymous 2012-03-20 12:40
Greetings,
I'm looking to print/export text to the clipboard in a C++ program and this way works just fine for 1 or more lines or text:
HGLOBAL hText;
char *pText;
hText = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 100);
pText = (char*)GlobalLock(hText);
strcpy(pText, "Example text line 1\r\nExample text line 2);
GlobalUnlock(hText);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_TEXT, hText);
CloseClipboard();
The problem is I've got some variables, and despite a lot of effort I cannot figure out how to print the text script + the variables inside it.
TL;DR: How do I into text + variables to clipboard in C++?
I'm looking to print/export text to the clipboard in a C++ program and this way works just fine for 1 or more lines or text:
HGLOBAL hText;
char *pText;
hText = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 100);
pText = (char*)GlobalLock(hText);
strcpy(pText, "Example text line 1\r\nExample text line 2);
GlobalUnlock(hText);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_TEXT, hText);
CloseClipboard();
The problem is I've got some variables, and despite a lot of effort I cannot figure out how to print the text script + the variables inside it.
TL;DR: How do I into text + variables to clipboard in C++?