Changing style of a subclassed CEdit

Posted on 2004-10-29
Last Modified: 2013-11-20
I'am using a subclassed CEdit in a CComboBox and have a CEdit derived class for that. For the edit control I want to set the ES_NOHIDESEL style.
Unfortunately PreCreateWindow() or OnCreate() are never called by a subclassed control and so I don't know, how to set the style. ModifyStyle() doesn't work with ES_NOHIDSEL.
I also would agree to another solution than subclassing for using an own edit control in a combobox.

Thanx for your help.
Question by:_mb_
    LVL 6

    Expert Comment

    by:Amritpal Singh
    LVL 43

    Expert Comment

    override the virtual function PreSubclassWindow and modify the style there (in your edit class).
    The OnCreate and PreCreate have already been called by the time you perform the subclassing hence you never get them them in your class.
    LVL 3

    Author Comment

    Hi amrit_82,
    I know these article. It doesn't give an answer to my question.

    Hi AndyAinscow,
    to change it in PreSubclassWindows also was my idea, but I don't know how. There is no CREATESTRUCT parameter, that I can modify and ModifyStyle() doesn't work.

    LVL 43

    Accepted Solution

    Excerpt from help

    Edit Control Styles
    To create an edit control using the CreateWindow or CreateWindowEx function, specify the EDIT class, appropriate window style constants, and a combination of the following edit control styles. After the control has been created, these styles cannot be modified, except as noted.

    ES_NOHIDESEL is one that can't be changed after creation.

    As I see it you have two possibilites.
    1) Create the control with the ES_NOHIDESEL style.
    2) Instead of subclassing, get the control styles, ID, position, visibility etc.  Delete edit control. Create your own to replace the one you deleted and set styles, content, visibility ...
    LVL 3

    Author Comment

    AndyAinscow, thanx for your help. I deleted the current control and created a new one.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT Security CISA, CISSP & CISM Certification

    Master the advanced techniques required to protect network resources from external threats with the IT Cyber Security bundle. Built around industry best-practice guidelines, the IT Cyber Security bundle consists of three in-depth courses.

    Suggested Solutions

    Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now