Mikołaj Zalewski : comctl32: Add Str_SetPtrWtoA analogue to Str_SetPtrAtoW.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 19 13:15:09 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: c5b27fa97b4e9412f8a0483ff3b16e25b606f437
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=c5b27fa97b4e9412f8a0483ff3b16e25b606f437
Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date: Wed Apr 19 14:34:14 2006 +0200
comctl32: Add Str_SetPtrWtoA analogue to Str_SetPtrAtoW.
---
dlls/comctl32/comctl32.h | 1 +
dlls/comctl32/comctl32undoc.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h
index 8053acc..005089d 100644
--- a/dlls/comctl32/comctl32.h
+++ b/dlls/comctl32/comctl32.h
@@ -145,6 +145,7 @@ VOID COMCTL32_RefreshSysColors(void);
void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal);
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
+BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc);
#define COMCTL32_VERSION_MINOR 80
#define WINE_FILEVERSION 5, COMCTL32_VERSION_MINOR, 0, 0
diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c
index 2812e34..e678cad 100644
--- a/dlls/comctl32/comctl32undoc.c
+++ b/dlls/comctl32/comctl32undoc.c
@@ -1107,6 +1107,46 @@ BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LP
return TRUE;
}
+/**************************************************************************
+ * Str_SetPtrWtoA [internal]
+ *
+ * Converts a unicode string to a multi byte string.
+ * If the pointer to the destination buffer is NULL a buffer is allocated.
+ * If the destination buffer is too small to keep the converted wide
+ * string the destination buffer is reallocated. If the source pointer is
+ * NULL, the destination buffer is freed.
+ *
+ * PARAMS
+ * lppDest [I/O] pointer to a pointer to the destination buffer
+ * lpSrc [I] pointer to a wide string
+ *
+ * RETURNS
+ * TRUE: conversion successful
+ * FALSE: error
+ */
+BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc)
+{
+ TRACE("(%p %s)\n", lppDest, debugstr_w(lpSrc));
+
+ if (lpSrc) {
+ INT len = WideCharToMultiByte(CP_ACP,0,lpSrc,-1,NULL,0,NULL,FALSE);
+ LPSTR ptr = ReAlloc (*lppDest, len*sizeof(CHAR));
+
+ if (!ptr)
+ return FALSE;
+ WideCharToMultiByte(CP_ACP,0,lpSrc,-1,ptr,len,NULL,FALSE);
+ *lppDest = ptr;
+ }
+ else {
+ if (*lppDest) {
+ Free (*lppDest);
+ *lppDest = NULL;
+ }
+ }
+
+ return TRUE;
+}
+
/**************************************************************************
* Notification functions
More information about the wine-cvs
mailing list