Hi!

A week ago I rewrite my text editor. I change only version of the library: from Riched32.dll to Riched20.dll... Now program works too. But sometimes it works not properly. There are no problems when I works with the text written on one language (only english or only german or only russian or only turkish). Otherwise when there are in the text two words (e.g. english word and it's foreign translation) this API

INVOKE SendMessage, hREdit, EM_GETSELTEXT, 0, addr szFind

can't get all letters. If keyboard is now EN then there are in the buffer only english lettters, when TR - only turkish, when RU - only russian etc. So I can't find any multilanguage phrase or recode the text. May be somebody know why?

You can work with the any known editors such as TabEdit or WordEdit - result will be the same.

Mike
Posted on 2004-05-21 05:35:44 by Mike
...

UINT uFormat;
char buf[1024];

SendMessage(hwndRichEdit, WM_COPY, 0, 0);

if (0 != OpenClipboard(hwnd))
{
if (0 != IsClipboardFormatAvailable((CF_UNICODETEXT)))
uFormat = CF_UNICODETEXT;
else if(0 != IsClipboardFormatAvailable((CF_TEXT)))
uFormat = CF_TEXT;
else
uFormat = 0;

if (CF_TEXT == uFormat || CF_UNICODETEXT == uFormat)
{
HGLOBAL hcbd = NULL;
LPBYTE psz = NULL;

if (NULL != (hcbd = GetClipboardData(CF_TEXT == uFormat ? CF_TEXT : CF_UNICODETEXT)))
{
if (NULL != (psz = (LPBYTE) GlobalLock(hcbd)))
{
if (CF_TEXT == uFormat)
lstrcpy(buf, (LPSTR) psz);
else
WideCharToMultiByte(CP_ACP, 0, (LPWSTR) psz, -1, buf, 1024, 0, 0);

MessageBox(hwnd, buf, ":-)", MB_OK);

GlobalUnlock(hcbd);
}
GlobalFree(hcbd);
}
}
CloseClipboard();
}
...
Posted on 2004-05-23 22:21:28 by P2M
Thank you!

I've tried this method. It works but there are a lot of problems because
sometimes I must work with clipboard and text in the same moment. In this
case I use those two procedures.

Mike

SaveClipboard proc
LOCAL hClip:DWORD, hPtr:DWORD

invoke OpenClipboard, hREdit
invoke GetClipboardData, CF_TEXT
mov hClip, eax
invoke GlobalLock, eax
mov hPtr, eax
invoke lstrlen, eax
.if eax < 2000000
.if xlatBuf==0
invoke GlobalAlloc, GMEM_FIXED OR GMEM_ZEROINIT, 2200000
mov xlatBuf, eax
.else
invoke RtlZeroMemory, xlatBuf, 1999999
.endif
invoke lstrcpy, xlatBuf, hPtr
.endif
invoke GlobalUnlock, hClip
invoke CloseClipboard

ret
SaveClipboard endp

invoke SendMessage, hREdit, WM_COPY, 0, 0

RestClipboard proc
LOCAL hClip:DWORD, hPtr:DWORD

invoke OpenClipboard, hREdit
invoke GetClipboardData, CF_TEXT
mov hClip, eax
invoke GlobalLock, eax
mov hPtr, eax
invoke lstrcpy, offset szFind, hPtr
invoke EmptyClipboard
invoke lstrcpy, hPtr, xlatBuf
invoke SetClipboardData, CF_TEXT, hClip

invoke GlobalUnlock, hClip
invoke CloseClipboard

ret
RestClipboard endp
Posted on 2004-05-25 03:27:47 by Mike