Click here to Skip to main content
Licence CPOL
First Posted 15 Jan 2000
Views 107,599
Bookmarked 24 times

Static text to display long filenames with ellipses

By | 15 Jan 2000 | Article
Lightweight class for displaying long filespecs that may need to be truncated
  • Download demo project - 14 Kb
  • Download source files - 3 Kb
  • Sample Image - cstatic_filespec.gif

    The CStaticFilespec control is a lightweight class suitable for displaying long filespecs that may need to be truncated or compressed, in order to fit the size of the display. The image presents an example of what the control looks like when used in a dialog box.

    By default, CStaticFilespec supports 2 drawing styles: DT_END_ELLIPSIS and DT_PATH_ELLIPSIS. The former displays a truncated filespec with trailing ellipses while the latter adds embedded ellipses to a compressed filespec.

    Using CStaticFilespec in a dialog is quite simple:

    Include CStaticFilespec.h in your dialog class' header file.

    Add member variables of type CStaticFilespec for every static text control you want to subclass.

    Subclass the static text controls in your dialog's OnInitDialog() method and set the controls' style.

      m_wndStaticFileEnd.SubclassDlgItem (IDC_FILE_END, this);<br>
      m_wndStaticFilePath.SubclassDlgItem (IDC_FILE_PATH, this);<br>
      m_wndStaticFilePath.SetPath (TRUE);
    

    You can also use any other DT_ drawing style you like. For example, to draw right justified text that is vertically centered and has trailing ellipses, do:

      m_wndStaticText.SubclassDlgItem (IDC_STATIC_TEXT, this);
      m_wndStaticText.SetFormat (DT_RIGHT | DT_VCENTER);
      m_wndStaticText.SetWindowText ("d:\\There\\Is\\Always\\One\\More\\Bug.cpp");
    

    License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    About the Author

    Ravi Bhavnani



    Canada Canada

    Member

    Ravi Bhavnani is an ardent fan of Microsoft technologies who loves building Windows apps, especially PIMs, system utilities, and things that go bump on the Internet. During his career, Ravi has developed expert systems, desktop imaging apps, marketing automation software, EDA tools, a platform to help people find, analyze and understand information, trading software for institutional investors and advanced data visualization solutions. He currently works for a company that provides enterprise workforce management solutions to large clients.
     
    His interests include the .NET framework, reasoning systems, financial analysis and algorithmic trading, NLP, CHI and UI design. Ravi holds a BS in Physics and Math and an MS in Computer Science and was a Microsoft MVP (C++ and C# in 2006 and 2007). He is also the co-inventor of 2 patents on software security and generating data visualization dashboards. His claim to fame is that he crafted CodeProject's "joke" forum post icon.
     
    Ravi's biggest fear is that one day he might actually get a life, although the chances of that happening seem extremely remote.

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralMy vote of 5 PinmemberCIDev5:08 24 Sep '10  
    GeneralError Compiling in VS2005 Pinmemberldsdbomber0:02 12 Jan '09  
    AnswerRe: Error Compiling in VS2005 PinmemberRavi Bhavnani2:50 12 Jan '09  
    GeneralRe: Error Compiling in VS2005 Pinmemberldsdbomber0:49 28 Jan '09  
    GeneralRe: Error Compiling in VS2005 Pinmemberldsdbomber0:52 28 Jan '09  
    GeneralRe: Error Compiling in VS2005 Pinmemberldsdbomber0:54 28 Jan '09  
    GeneralRe: Error Compiling in VS2005 PinmemberRavi Bhavnani1:38 28 Jan '09  
    Questiona simple program on EMP Pinmembersireeshakolluri21:52 7 Apr '08  
    GeneralRe: a simple program on EMP PinmemberRavi Bhavnani2:55 8 Apr '08  
    GeneralFlickering Pinmemberrrrado1:29 11 Jun '03  
    GeneralRe: Flickering PinmemberRavi Bhavnani1:38 11 Jun '03  
    Questionhave a bug, how to do? Pinmemberuse_id1:36 8 Aug '02  
    AnswerRe: have a bug, how to do? PinmemberRavi Bhavnani2:24 8 Aug '02  
    GeneralShowing MDI Child window Maximized PinmemberKonrad Rotuski3:30 30 Apr '02  
    GeneralAPI Functions PinmemberArmen Hakobyan22:22 29 Apr '02  
    GeneralRe: API Functions PinmemberRavi Bhavnani3:16 30 Apr '02  
    GeneralRe: API Functions PinmemberDavidCrow8:55 1 Dec '04  
    GeneralRe: API Functions PinmemberRavi Bhavnani16:37 1 Dec '04  
    GeneralBugFix: Disabled text incorrectly shown as enabled PinmemberRavi Bhavnani17:37 10 Dec '01  
    GeneralAPI Function PinmemberAnonymous14:13 8 Feb '01  
    GeneralRe: API Function PinmemberBalkrishna Talele23:49 13 Apr '04  
    GeneralI can't get this up a running my way... Pinsusswebguy9:48 6 Jul '00  
    GeneralRe: I can't get this up a running my way... PinsussRavi Bhavnani10:26 6 Jul '00  
    GeneralRe: I can't get this up a running my way... Pinsusswebguy15:51 7 Jul '00  
    GeneralThere is an api function PinsussHåkan2:21 16 Feb '00  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Mobile
    Web02 | 2.5.120517.1 | Last Updated 16 Jan 2000
    Article Copyright 2000 by Ravi Bhavnani
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid