Hi all,
how do I send a string to the clipboard?
This cannot be terrifically dificult...
Season's Greetings,
Happy New Year,
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
The most irrefutable evidence that there is intelligent life in the Universe is that they haven't contacted us!
[edited by - pentium3id on January 29, 2004 1:22:21 AM]
How to send string to the clipboard
c''mon people, someone has to know this...
It should be very easy for gurus out there
It should be very easy for gurus out there
[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)
look up OpenClipboard() in msdn, theres a good article on codeguru.com about copy and paste functions(very easy to do )
Easy-pleasy,
HNY,
Zeblar Nagrim, Lord of Chaos
char* g_pText;HGLOBAL g_hGlobal;HWND g_hWnd; void CopyText(){ // // Prepare g_hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (lstrlen (g_pText) + 1) * sizeof (char)); g_hGlobal = GlobalLock(g_hGlobal); lstrcpy(g_hGlobal, g_pText); GlobalUnlock(g_hGlobal); // // Send OpenClipboard(g_hWnd); EmptyClipboard(); SetClipboardData(CF_TCHAR, g_hGlobal); CloseClipboard(); }
HNY,
Zeblar Nagrim, Lord of Chaos
Thanx, that was quite helpful !!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"I say we take off and nuke the entire site from orbit. It's the only way to be sure."
[edited by - pentium3id on March 4, 2004 10:55:21 PM]
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"I say we take off and nuke the entire site from orbit. It's the only way to be sure."
[edited by - pentium3id on March 4, 2004 10:55:21 PM]
and in VB it''s something like... Clipboard.setdata ____ or clipboard.getdata, ect..
-eldee
;another space monkey;
-eldee
;another space monkey;
Another, error checked method:
bool CopyTextToClipboard(const string& strBuff, HWND hWndOwner){HGLOBAL hMem;void* pData; // Open Clipboard // if(!OpenClipboard(hWndOwner)) return false; EmptyClipboard(); // Allocate memory // hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,strBuff.length()+1); if(!hMem) { CloseClipboard(); return false; } // Fill Memory // pData = GlobalLock(hMem); if(!pData) { GlobalFree(hMem); CloseClipboard(); return false; } memcpy(pData,strBuff.c_str(),strBuff.length()+1); // Unlock memory, set clipboard data, and cleanup // GlobalUnlock(hMem); SetClipboardData(CF_TEXT,hMem); CloseClipboard(); return true;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement