How can I copy a textbuffer (eg. TextBuffer db 'hello world',0) to the clipboard?
I have tried all examples on the board, but I can't get them to work. I'm currently using a temporary solution by creating an off-screen edit box that I put the text in using SetDlgItemText and then copying the text by sending the WM_COPY message to it. This however feels very dirty and I really would like to know a proper way of doing it.
Thanks.
I have tried all examples on the board, but I can't get them to work. I'm currently using a temporary solution by creating an off-screen edit box that I put the text in using SetDlgItemText and then copying the text by sending the WM_COPY message to it. This however feels very dirty and I really would like to know a proper way of doing it.
Thanks.
try
invoke SetClipboardData,CF_TEXT,addr TextBuffer
I tried this
invoke CloseClipboard
invoke OpenClipboard,hWin
invoke EmptyClipboard
invoke SetClipboardData,CF_TEXT,offset Buffer
invoke CloseClipboard
But it crashed :(
invoke CloseClipboard
invoke OpenClipboard,hWin
invoke EmptyClipboard
invoke SetClipboardData,CF_TEXT,offset Buffer
invoke CloseClipboard
But it crashed :(
Sorry....
OpenClipboard at first
OpenClipboard at first
VC's CODE:
if(openClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, dource.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
Strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
===========================
invoke openClipBoard
.if eax!=0
invoke EmptyClipboard
invoke SetClipboardData,CF_TEXT,buffer
invoke CloseClipboard
.endif
I think it will work...
Let me try later.
if(openClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, dource.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
Strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
===========================
invoke openClipBoard
.if eax!=0
invoke EmptyClipboard
invoke SetClipboardData,CF_TEXT,buffer
invoke CloseClipboard
.endif
I think it will work...
Let me try later.
http://www.codeguru.com/clipboard/text_tofrom_clipboard.shtml
sorry.
I am knew such few of hMem.
:stupid:
sorry.
I am knew such few of hMem.
:stupid:
i used this i found on the board in the app im working on
.data?
nLen dd ?
hMem dd ?
pMem dd ?
invoke lstrlen, addr yourtexthere
inc eax
mov nLen, eax
invoke OpenClipboard, 0
invoke GlobalAlloc, GHND, nLen
mov hMem, eax
invoke GlobalLock, eax
mov pMem, eax
lea esi,yourtexthere
mov edi, eax
mov ecx, nLen
rep movsb
invoke EmptyClipboard
invoke GlobalUnlock, hMem
invoke SetClipboardData, CF_TEXT, hMem
invoke CloseClipboard
.data?
nLen dd ?
hMem dd ?
pMem dd ?
invoke lstrlen, addr yourtexthere
inc eax
mov nLen, eax
invoke OpenClipboard, 0
invoke GlobalAlloc, GHND, nLen
mov hMem, eax
invoke GlobalLock, eax
mov pMem, eax
lea esi,yourtexthere
mov edi, eax
mov ecx, nLen
rep movsb
invoke EmptyClipboard
invoke GlobalUnlock, hMem
invoke SetClipboardData, CF_TEXT, hMem
invoke CloseClipboard
illwill, that code works perfectly. Thanks!