Special charaters are displayed in inverted order by CTreeCtrl
I build a file browser like tree with CTreeCtrl. Now, if the control has to
display a drive like "C:", it instead displays ":C". The same happens with
"Program Files (x86)" which is displayed as ")Program Files (x86". So, it
seems that if the the last character is a special character, it becomes the
first character in display name.
Is this a unicode problem? Anyway, very strange.
Here is my coding:
CFileSystem fs;
wchar_t d[3];
LPTVINSERTSTRUCTW itemstruc = NULL;
CString text;
//Load static images
m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(0,0,0));
//Set image list
this->SetImageList(&m_FileViewImages, TVSIL_NORMAL);
//Set 24 bit bitmaps for static images
this->ChangeVisualStyle( );
int num = fs.GetNumberDrives( );
for(int j = 1; j<num+1; j++){
//Get drive name
fs.GetDriveByNumber(j,d);
text = CString(d);
if(fs.IsDriveActive(d)==TRUE){
itemstruc = new TVINSERTSTRUCTW;
itemstruc->hParent = NULL;
//Set item mask
itemstruc->item.mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|
TVIF_STATE|TVIF_TEXT|TVIF_SELECTEDIMAGE;
//Set state mask
itemstruc->item.stateMask = TVIS_BOLD|TVIS_OVERLAYMASK|TVIS_SELECTED;
itemstruc->item.cChildren = 1;
itemstruc->item.pszText = (WCHAR*)text.GetBuffer( );
itemstruc->item.cchTextMax = 3;
itemstruc->item.iImage = 3;
itemstruc->item.iSelectedImage = 3;
HTREEITEM item = InsertItem(itemstruc);
SetItemState(item,TVIS_BOLD,TVIS_BOLD);
//SetItemState(item,TVIS_SELECTED,TVIS_SELECTED);
delete itemstruc;
}
}
Any ideas are really appreciated.
Thomas