From: Giovanni Dicanio on 8 Jun 2010 07:24 On 08/06/2010 09:36, milonass wrote: One more thing: considering that you are setting the item attributes (like the text), I think that you don't need to set the item.cchTextMax field (I would clear it to 0): > itemstruc->item.cchTextMax = 3; Giovanni
From: milonass on 8 Jun 2010 08:40 Forgot to answer your last question: When I put a space after the ":" the result is wrong. But if I put a normal character after the ":" the result is correct. Thanks and regards, Thomas "Giovanni Dicanio" wrote: > On 08/06/2010 11:51, milonass wrote: > > > The > > strange thing is, that the problem only occurs, when a special character at > > the end of the string occurs. > > Using the debugger, have you checked that the string stored in the > CString instance is well formed? > > Also, I would be curious to know what happens if you put a space ' ' > after the "special character"... > > Giovanni > . >
From: milonass on 8 Jun 2010 08:40 Hi Giovanni, Thank you for your answers. I put the "text" (CString) into a message box and the result is correct. I also now set itemstruc->item.cchTextMax = 0; Always the same result. Best regards, Thomas "Giovanni Dicanio" wrote: > On 08/06/2010 09:36, milonass wrote: > > One more thing: considering that you are setting the item attributes > (like the text), I think that you don't need to set the item.cchTextMax > field (I would clear it to 0): > > > itemstruc->item.cchTextMax = 3; > > > Giovanni > . >
From: Giovanni Dicanio on 8 Jun 2010 11:01 On 08/06/2010 14:40, milonass wrote: > Thank you for your answers. You are welcome. I put the "text" (CString) into a message box > and the result is correct. I also now set itemstruc->item.cchTextMax = 0; > > Always the same result. In addition, you may want to try to increase the size of 'd' variable: wchar_t d[100]; Moreover, why do you use the explicit 'W' version of data structures? e.g.: LPTVINSERTSTRUCTW itemstruc = NULL; ... itemstruc = new TVINSERTSTRUCTW; I would suggest you to just build the project in Unicode mode, and use "normal" names like TVINSERTSTRUCT (without the ending 'W'). Giovanni
From: Joseph M. Newcomer on 8 Jun 2010 11:47 See below... On Tue, 8 Jun 2010 00:36:32 -0700, milonass <milonass(a)discussions.microsoft.com> wrote: >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; **** CFileSystem? I cannot find this in the documentation anywhere. If you are using classes from someplace else, you need to give us a pointer to where you found them **** > 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); **** Since we have no idea what CFileSystem is or does, showing us a line of code that invokes an undefined method of an undefined class seems rather pointless. Note also that this is obviously a class designed by a beginner, because it does not require passing the _countof(d) in as a parameter. Therefore, it is not really trustworthy. How do you expect us to analyze code that uses unknown and unfindable classes? I found at least three completely different classes called "CFileSystem" using google, at which point I gave up, because you are obviously expecting us to know, possibly by ethereal vibrations, exactly which of these you are using. And your question can be pretty much answered by the explanation "GetDriveByNumber is written incorrectly, fix it", so what do you expect us to do about this? **** > text = CString(d); > if(fs.IsDriveActive(d)==TRUE){ > itemstruc = new TVINSERTSTRUCTW; **** Why do you have this odd mix of Unicode-aware coding (CString, not CStringW) and Unicode-only code (wchar_t, TVINSERTSTRUCTW, WCHAR *)? Or were you relying on Intellinonsense to "help" you write code? And why, for goodness sake, are you doing a 'new' here? Have you considered just declaring the structure on the stack? Using a 'new' here is completely silly! **** > 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; **** On a SetItemState, you do not need to provide the text length, since the string is NUL-terminated **** > itemstruc->item.iImage = 3; **** I have no idea what "3" means. Have you ever heard of #define or const int to define symbolic names? **** > itemstruc->item.iSelectedImage = 3; **** Ditto *** > HTREEITEM item = InsertItem(itemstruc); **** You probably used 'new' because the specification of InsertItem wants a pointer-to-TVINSERTSTRUCT. Have you ever heard of the "&" operator? TVINSERTSTRUCT itemstruc; ... fill in values HTREEITEM Item = InsertItem(&itemstruc); **** > SetItemState(item,TVIS_BOLD,TVIS_BOLD); > //SetItemState(item,TVIS_SELECTED,TVIS_SELECTED); > delete itemstruc; > } > } > >Any ideas are really appreciated. **** Single-stepping the GetDriveByNumber code and seeing where it is wrong would be a really good start. If you want help, you have to give us enough information to help you. joe **** > >Thomas > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Regression - Instruction Next: Visual 2010 compilation errors |