I have the SHBrowseForFolder to popup and work fine, but I would like to set the Title. I know it has to be a wchar_t* and when I use a const like (wchar_t*)L"My Title" the title is shown correct.
But if I try to use a String value I only get the first letter 'M', it's like the wide string has been converted to new wide string once again, pading each character with a nul.
Winapi::Shlobj::BROWSEINFO bi = {0};
bi.hwndOwner = Handle;
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_BROWSEFORCOMPUTER;
bi.lpszTitle = String("My Title").w_str(); // This only shows the 'M'
//bi.lpszTitle = (wchar_t*)"My Title"; // This shows the full string 'My Title'
LPITEMIDLIST pidl = SHBrowseForFolder((_browseinfoA*)&bi);
if ( pidl != 0 ) {
// free memory used
IMalloc *imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc))) {
imalloc->Free(pidl);
imalloc->Release();
}
}
The documentation for UnicodeString all conversion functions c_str()
,t_str()
and w_str()
all returns a wchar_t*
but the declaration shows WideChar*
.
Any ideas how to make this code work together with a String?