I'm just messing around with thread hooks. I've got one now that displays the clipboard, if it is in CF_TEXT format, whenever the user pastes in my application. The problem I've run into is that it can get the clipboard data fine if I've copied it from another application, but if I copy it from my own, it pastes just fine on the screen, but when I retrieve the clipboard data, its garbled. Heres the code.
Code:
int msg = PCWPSTRUCT(lParam)->message;
	HGLOBAL hglb;
	LPTSTR lptstr;
	
	if (msg == WM_PASTE)
	{
		char * buffer;
		if(OpenClipboard(GetForegroundWindow()))
		{
			buffer = (char*)GetClipboardData(CF_TEXT);
			MessageBox(NULL, buffer, "Success!",MB_ICONEXCLAMATION | MB_OK);
		}
		CloseClipboard();
	}
If I copied from another file, it pastes just fine, and the Message Box shows what I pasted, but if I copy from the edit box within my app, it still pastes fine, but the Message Box reads gibberish. Any ideas?? Thanks in advance for the help.