Mercurial > dwindows
comparison win/dw.c @ 1641:cdbf4cc929fc
Fixed issue with dw_mle_import() in Unicode mode.
Need to convert to Unicode before doing buffer manipulation.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 02 Apr 2012 19:44:45 +0000 |
parents | c441c85baa57 |
children | 08da4840dfc3 |
comparison
equal
deleted
inserted
replaced
1640:b8604e5fc85e | 1641:cdbf4cc929fc |
---|---|
7947 * startpoint: Point to start entering text. | 7947 * startpoint: Point to start entering text. |
7948 */ | 7948 */ |
7949 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | 7949 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
7950 { | 7950 { |
7951 int textlen, len = GetWindowTextLength(handle); | 7951 int textlen, len = GetWindowTextLength(handle); |
7952 TCHAR *tmpbuf; | 7952 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer); |
7953 | 7953 |
7954 if(startpoint < 0) | 7954 if(startpoint < 0) |
7955 startpoint = 0; | 7955 startpoint = 0; |
7956 | 7956 |
7957 if(!buffer || (textlen = (int)strlen(buffer)) < 1) | 7957 if(!buffer || (textlen = (int)_tcslen(srcbuf)) < 1) |
7958 return startpoint; | 7958 return startpoint; |
7959 | 7959 |
7960 tmpbuf = calloc(sizeof(TCHAR), len + textlen + startpoint + 2); | 7960 tmpbuf = calloc(sizeof(TCHAR), len + textlen + startpoint + 2); |
7961 | 7961 |
7962 if(len) | 7962 if(len) |
7970 start = &tmpbuf[startpoint]; | 7970 start = &tmpbuf[startpoint]; |
7971 | 7971 |
7972 if(copylen > 0) | 7972 if(copylen > 0) |
7973 memcpy(dest, start, copylen*sizeof(TCHAR)); | 7973 memcpy(dest, start, copylen*sizeof(TCHAR)); |
7974 } | 7974 } |
7975 memcpy(&tmpbuf[startpoint], UTF8toWide(buffer), textlen*sizeof(TCHAR)); | 7975 memcpy(&tmpbuf[startpoint], srcbuf, textlen*sizeof(TCHAR)); |
7976 | 7976 |
7977 SetWindowText(handle, tmpbuf); | 7977 SetWindowText(handle, tmpbuf); |
7978 | 7978 |
7979 free(tmpbuf); | 7979 free(tmpbuf); |
7980 return (startpoint + textlen); | 7980 return (startpoint + textlen); |