CEditEx and CStaticEx - Classes that extend the functionality of the CEdit and CStatic | CodeGuru

CEditEx and CStaticEx – Classes that extend the functionality of the CEdit and CStatic

Description: Both CEditEx and CStaticEx allow for easy customization of text, background, and font attributes. Using these classes: See example code provided. Attributes: &nbsp&nbsp&nbsp 1. COLORREF bkColor( COLORREF crColor ) &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp COLORREF bkColor() const &nbsp&nbsp&nbsp 2. COLORREF textColor( COLORREF crColor ) &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp COLORREF textColor() const &nbsp&nbsp&nbsp 3. (CEdit Only) void setCustomMask( CEditMask* editMask = 0 […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 1, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Description:
Both CEditEx and CStaticEx allow for easy customization of text, background, and font attributes.

Using these classes:
See example code provided.

Attributes:
    1. COLORREF bkColor( COLORREF crColor )
       COLORREF bkColor() const

    2. COLORREF textColor( COLORREF crColor )
       COLORREF textColor() const

    3. (CEdit Only) void setCustomMask( CEditMask* editMask = 0 /* null == default */ ) - note I have tried using this feature yet.

    4. (CEdit Only) void definePopupMenu( UINT uResourceID  = 0 /* null == default */ ) - Overide default context menu with new menu resource.

    5. void setFont( const LOGFONT* lpLogFont ); - NOTE: See CLogFont included in the CEditEx headers and CStaticEx headers
       void setFont( LONG fontHeight = -8,
                     LONG fontWeight = FW_NORMAL,
                     UCHAR pitchAndFamily = DEFAULT_PITCH | FF_DONTCARE,
                     LPCSTR faceName = _T("MS Sans Serif" );

    6. (CStaticEx Only) The following idea came from Paul DiLascia in the December 1997 issue of MSJ.
        void onClickDoShellCommand( const CString& linkName ) - Use control as a link to open a link or exe
        COLORREF setLinkColorVisited( COLORREF crColor ) - Sets the visit color, returns previous setting
        COLORREF setLinkColorUnvisited( COLORREF crColor ) - Sets the unvisited color, returns previous setting
        BOOL doCustomCursor( bool custom = true ) - show a custom cursor over the control


Download source code and demo project – 23 KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.