Commit c5b27fa9 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: Add Str_SetPtrWtoA analogue to Str_SetPtrAtoW.

parent 195ae60e
...@@ -145,6 +145,7 @@ VOID COMCTL32_RefreshSysColors(void); ...@@ -145,6 +145,7 @@ VOID COMCTL32_RefreshSysColors(void);
void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal); void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal);
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen); INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc); BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc);
#define COMCTL32_VERSION_MINOR 80 #define COMCTL32_VERSION_MINOR 80
#define WINE_FILEVERSION 5, COMCTL32_VERSION_MINOR, 0, 0 #define WINE_FILEVERSION 5, COMCTL32_VERSION_MINOR, 0, 0
......
...@@ -1107,6 +1107,46 @@ BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) ...@@ -1107,6 +1107,46 @@ BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc)
return TRUE; 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 * Notification functions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment