Clipboard with API 
Author Message
 Clipboard with API

Bonjour!

How can I use the Windows Clipboard? What I tried is

                OpenClipboard(NULL);
                HANDLE test=SetClipboardData(CF_TEXT, "hallo");
                CloseClipboard();

This didn't work, i think because of param 2 needs to be a HANDLE?!

What I want is to set a char* text to the Clipboard.

Robert

-----------------------------------------
Robert Fink

Germany



Tue, 30 Jul 2002 03:00:00 GMT  
 Clipboard with API


Quote:
> Bonjour!

> How can I use the Windows Clipboard? What I tried is

> OpenClipboard(NULL);
> HANDLE test=SetClipboardData(CF_TEXT, "hallo");
> CloseClipboard();

> This didn't work, i think because of param 2 needs to be a HANDLE?!

> What I want is to set a char* text to the Clipboard.

char Msg[] = "hallo";
OpenClipboard(NULL);
EmptyClipboard(); // this is a necessary step
HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
  lstrlen(Msg) + 1);
char *pMem = (char*)GlobalLock(hMem);
lstrcpy(pMem, Msg);
GlobalUnlock(hMem);
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();

With best wishes,
    Igor Tandetnik



Tue, 30 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OLE Clipboard :: Win32 API vs. MFC

2. Clipboard: Catching a paste to clipboard

3. API Monitor: Spy on API Calls with this Free Utility

4. Search Info about SCC API (Source Code Control API)

5. Clipboard

6. Populate ClipBoard from TextField on ASPX Page?

7. Clipboard - Copy & Paste

8. Hmm copy and paste quandry - beyond the Clipboard

9. Finding out whether the ClipBoard is empty or not

10. IDataObject is null copying Clipboard from Excel in C#

11. Handling ambiguous CSV data in clipboard

12. Regarding clipboard

 

 
Powered by phpBB® Forum Software