المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Unable to paste clipboard data by sending WM_PASTE message



C++ Programming
02-04-2010, 11:11 PM
Hi All,

I need to pass data from my program to an active notepad ******** I got the handle to notepad and copied the data to clipboard but nothing is getting pasted in notepad window after sending WM_PASTE message to notepad ******** Here is the code

if(!OpenClipboard(hWnd))
errorExit();

HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, extractedTime.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(extractedTime));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);


if(notepadWnd != NULL)
{
SendMessage(notepadWnd, WM_PASTE, 0, 0);
}

CloseClipboard();


I used this article (http://www.codeproject.com/KB/clipboard/clipboard_faq.aspx) as reference. Any pointers what am I doing wrong?

Thanks