Karen
April 19th, 1999, 03:58 PM
So I got a grip over the weekend and eliminated most of my problems, however, one remains. When I try to use the function GetClipboardData, it returns a handle to clipboard object and I am trying to convert that into an char array, but it just puts garbage in the array.
Here is the function - any suggestions would be appreciated.
void From_Clipboard(HWND TextEdit, HWND hwnd2){
char destination[20];
if(OpenClipboard(hwnd2)){
static HGLOBAL clipbuffer;
static char * buffer;
clipbuffer = GlobalAlloc(GMEM_MOVEABLE, strlen(destination)+1);
buffer = (char*)GlobalLock(clipbuffer);
clipbuffer = GetClipboardData(CF_TEXT);
lstrcpy(destination, LPCSTR(buffer));
GlobalUnlock(clipbuffer);
SetWindowText(TextEdit, destination);
}
else{
MessageBox(NULL, "Unable to read from clipboard!", "Error",
MB_OK | MB_ICONINFORMATION);
}
CloseClipboard();
}
Here is the function - any suggestions would be appreciated.
void From_Clipboard(HWND TextEdit, HWND hwnd2){
char destination[20];
if(OpenClipboard(hwnd2)){
static HGLOBAL clipbuffer;
static char * buffer;
clipbuffer = GlobalAlloc(GMEM_MOVEABLE, strlen(destination)+1);
buffer = (char*)GlobalLock(clipbuffer);
clipbuffer = GetClipboardData(CF_TEXT);
lstrcpy(destination, LPCSTR(buffer));
GlobalUnlock(clipbuffer);
SetWindowText(TextEdit, destination);
}
else{
MessageBox(NULL, "Unable to read from clipboard!", "Error",
MB_OK | MB_ICONINFORMATION);
}
CloseClipboard();
}