There is no decent GUI interface for writing 3D programs, but it won't work. Recently, I have nothing to do with cegui. It is really a good stuff, it is very convenient to use, the new version has supported dx10, that is, the support for Chinese is still so "not active ". 1. The Chinese text shows that solutions can be found everywhere. Load a font that supports Chinese display, and select Correct utf8 encoding. Some say it is saved as "utf8 with signature", but it is correct only when I save it as "utf8 without signature. 2. Chinese input. This does not seem so complicated. You only need to directly call "injectchar" when responding to the wm_char message. (Cegui: UTF32) wparam) "(some say they want to merge the" wparam "in Chinese, some say they want to convert it into wide characters, while I am in dxut The Framework's msgproc calls injectchar and passes in directly ). Note that injectkeydown and injectkeyup The input parameter is a Keyboard Scan code. If it is a character, use mapvirtualkey to convert it. 3. Let editbox respond to the copy and paste events of Ctrl + C Ctrl + v. After a long time, I finally got it done. The main difference is that the string that comes with cegui is inconsistent with the Chinese encoding of the standard string and must be converted to each other. The first is to submit a function that responds to the "window: eventcharacterkey" event, and then judge whether the input is Ctrl + C, CTRL + V, and then perform corresponding clipboard processing. For the corresponding processing code and code conversion code, see: Cegui: String ceguirender: encode (const char * C) { Static cegui: String STR; Wchar E; Str. Clear (); Int I = 0; While (C [I]) { If (unsigned char (C [I])> = 161) { Multibytetowidechar (0, 0, C + I, 2, & E, 1 ); Str. append (1, E ); I + = 2; } Else { Str. append (1, C [I]); I ++; } } Return STR; } STD: String ceguirender: Decode (const cegui: string & Str) { Const char * chtemp = Str. c_str (); Wchar * stra; Int I = multibytetowidechar (cp_utf8, 0, (char *) chtemp,-1, null, 0 ); Stra = new wchar [I]; Multibytetowidechar (cp_utf8, 0, (char *) chtemp,-1, stra, I ); I = widechartomultibyte (cp_acp, 0, stra,-1, null, 0, null, null ); Char * strb = new char [I]; Widechartomultibyte (cp_acp, 0, stra,-1, strb, I, null, null ); STD: String strreturn = STD: string (strb ); Delete stra; Delete strb; Return strreturn; } Bool ceguirender: oneditboxkeydown (const cegui: eventargs & E) { Cegui: keyeventargs * kevent = (cegui: keyeventargs *) & E; Window * wbox = kevent-> window; Hglobal clipbuffer; Char * buffer; STD: String strtemp; Cegui: String guistr; Cegui: String guistrtemp; Int istart, ilen; // Winlog ("% d", kevent-> codepoint ); Guistr = wbox-> gettext (); Istart = (editbox *) wbox)-> getselectionstartindex (); Ilen = (editbox *) wbox)-> getselectionlength (); Switch (kevent-> codepoint) { Case 3: // Ctrl + C copy selected text to clipboard If (ilen = 0) break; Guistr = guistr. substr (istart, ilen ); Strtemp = decode (guistr ); If (openclipboard (0 )) { Emptyclipboard (); Clipbuffer = globalalloc (gmem_ddeshare, strtemp. Length () + 1 ); Buffer = (char *) globallock (clipbuffer ); Strcpy (buffer, strtemp. c_str ()); Globalunlock (clipbuffer ); Setclipboarddata (cf_text, clipbuffer ); Closeclipboard (); } Break; Case 24: // Ctrl + x cut the selected text to clipboard If (ilen = 0) break; Wbox-> settext (guistr. substr (0, istart) + guistr. substr (istart + ilen, guistr. Length ()-(istart + ilen ))); (Editbox *) wbox)-> setcaratindex (istart ); Guistr = guistr. substr (istart, ilen ); Strtemp = decode (guistr );
If (openclipboard (0 )) { Emptyclipboard (); Clipbuffer = globalalloc (gmem_ddeshare, strtemp. Length () + 1 ); Buffer = (char *) globallock (clipbuffer ); Strcpy (buffer, strtemp. c_str ()); Globalunlock (clipbuffer ); Setclipboarddata (cf_text, clipbuffer ); Closeclipboard (); } Break; Case 22: // Ctrl + V Insert the Clipboard data If (! Isclipboardformatavailable (cf_text) break; If (! Openclipboard (0) break; Hglobal hmem = getclipboarddata (cf_text ); If (hmem! = NULL) { Lptstr lpstr = (lptstr) globallock (hmem ); If (lpstr! = NULL) { Strtemp = STD: string (char *) lpstr ); Globalunlock (hmem ); } Else strtemp = ""; } Else strtemp = ""; Closeclipboard (); If (strtemp. Length () = 0) break; Guistrtemp = encode (strtemp. c_str ()); Wbox-> settext (guistr. substr (0, istart) + guistrtemp + guistr. substr (istart + ilen, guistr. Length ()-(istart + ilen ))); (Editbox *) wbox)-> setcaratindex (istart + guistrtemp. Length ()); Break; } Return true; } |