以下是引用sych在2025-9-6 11:11:27的发言:
另外如果用字符串,可以用消息传递
Declare INTEGER SendMessage in WIN32API as sendmessage_c2 INTEGER hwnd , INTEGER wMsg , INTEGER wParam , string lParam
#defi EM_REPLACESEL 0xC2
SendMessage_c2(this.edit.hwnd, EM_REPLACESEL, 1, 0hefbbbf+0hc58b) &&这里要带上标记
另外如果用字符串,可以用消息传递
Declare INTEGER SendMessage in WIN32API as sendmessage_c2 INTEGER hwnd , INTEGER wMsg , INTEGER wParam , string lParam
#defi EM_REPLACESEL 0xC2
SendMessage_c2(this.edit.hwnd, EM_REPLACESEL, 1, 0hefbbbf+0hc58b) &&这里要带上标记
UTF-8字串输入在C测试正常,偷点懒贴代码,很简单的。
vfp测试代码:
SetTextUtf8(this.edit.hWnd, STRCONV(0h0D0A+"abc字字123"+0h0D0A+"si",9)+0hC58B)
C代码:

//输入UTF-8字串 DLLIMPORT_C void SetTextUtf8(HWND hRichEdit, LPVOID* pTextUtf8) { SETTEXTEX stx; //SETTEXTEX {DWORD flags; UINT codepage} stx.flags = ST_SELECTION; //#define ST_SELECTION 2 stx.codepage = CP_UTF8; //#define CP_UTF8 65001 SendMessage(hRichEdit, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)pTextUtf8); //#define EM_SETTEXTEX 0x0461 }