CFileDialog doesn't display the file name correctly
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: CFileDialog doesn't display the file name correctly

  1. #1
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,095

    CFileDialog doesn't display the file name correctly

    I haven't seen this before but on Windows 7 Home Professional and VC 2012 in one particular app, a CFileDialog displays only the rightmost 11 characters plus the extension of the default file name. The rest of the name is there and you can scroll left in the file name edit to display it all, but initially the text is shifted left so it doesn't all display. Hope that makes sense.

    This is the code.
    Code:
    	CFileDialog dlg(TRUE, "csv", strFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, "Comma Seperated Values Files (*.csv)|*.csv|All Files (*.*)|*.*||");
    strFileName can contain anything and it will do it. Even a string literal will do it.

    Any ideas?

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,585

    Re: CFileDialog doesn't display the file name correctly

    11 characters rings a bell for me: It's the length of a legacy "short" file name plus a legacy three-character extension. It would have looked even more logical to me if it were 12 characters rather than 11, accounting for the dot in the assumed legacy file name, still I suspect you're observing some long forgotten legacy code sneaking up from behind, somewhere in the framework/CRT or even Windows itself...

    Of course this is just a shot in the dark, mostly driven by some gut feeling. It may still give you a hint into some direction to research, maybe just to eliminate that potential cause of the issue.

    IOW, just my $.02 so to say...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: CFileDialog doesn't display the file name correctly

    Quite weird, that happens in "Vista-style" file open dialog.
    If change the code...
    Code:
        CFileDialog dlg(TRUE, _T("csv"), strFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, 
            _T("Comma Seperated Values Files (*.csv)|*.csv|All Files (*.*)|*.*||"), this, 0, FALSE);
        // ...
    ...in order to display the "legacy" open file dialog, that not happens anymore.

    Well, if that's a real issue for you, then is time to say: Hey dudes, something is rotten in the state of Denmark!
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: CFileDialog doesn't display the file name correctly

    Quote Originally Posted by GCDEF View Post
    I haven't seen this before but on Windows 7 Home Professional and VC 2012 in one particular app, a CFileDialog displays only the rightmost 11 characters plus the extension of the default file name. The rest of the name is there and you can scroll left in the file name edit to display it all, but initially the text is shifted left so it doesn't all display. Hope that makes sense.
    I've seen this behavior before on my own dialogs where an edit box was the first control on the dialog to receive user input and it was resized dynamically. I think what happened was that the edit box first received input focus, so it selected all the text and set the cursor at the end, scrolling the text left. Then the edit box was resized, but the contents were not scrolled accordingly.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center