copy text to clipboard
Writing a simple program to copy incremental numbers to the clipboard.
1 2 3 4 5 6
|
do 10 times
{
copy x to clipboard
x++
wait for user response
}
|
how do I copy the value of x to the clipboard?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void toClipboard(const std::string &s){
OpenClipboard(0);
EmptyClipboard();
HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size());
if (!hg){
CloseClipboard();
return;
}
memcpy(GlobalLock(hg),s.c_str(),s.size());
GlobalUnlock(hg);
SetClipboardData(CF_TEXT,hg);
CloseClipboard();
GlobalFree(hg);
}
|
Thanks helios for that great reply
Topic archived. No new replies allowed.