comctl32: Add Str_SetPtrWtoA analogue to Str_SetPtrAtoW.

This commit is contained in:
Mikołaj Zalewski 2006-04-19 14:34:14 +02:00 committed by Alexandre Julliard
parent 195ae60e97
commit c5b27fa97b
2 changed files with 41 additions and 0 deletions

View File

@ -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

View File

@ -1107,6 +1107,46 @@ BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc)
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