Edit control template

This is a discussion on Edit control template within the Windows Programming forums, part of the Platform Specific Boards category; I wish to develop a custom edit control that will display a template. For example, a social security number input ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059

    Edit control template

    I wish to develop a custom edit control that will display a template. For example, a social security number input edit control where the input area would only contain the dashes and the user would input the numeric data. i.e 111-22-3333

    Thus, can anybody point me in the right direction on developing this control?

    Thanx

    Bob

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You might want to take a look at window sublclassing:

    Safe subclassing inWin32 (old but still relevant)

    Subclassing controls (newer but largely os specific)

    About Window Procedures (some background information).

    Search this board, too, as there's been lots of discussion about subclassing and I'm fairly certain there's been a few posted examples.

    Alternatively, for something like you describe you might get by with a single-line edit handling EN_CHANGE notifications and moving the cursor to where you need with EM_SETSEL: essentially you'd place relevant user input into a formatted string and SetWindowText it into the control.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Google throws up a few examples but they seem to be mostly MFC based. Catch22 has a tutorial that may get you started on an API solution.

    Often it may be better to let the user enter data in free-form. Discussion here.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    I've used the Catch-22 for another edit control. I think I'll have to modify it to print a dash in the third and sixth position for a social security number input.

    I've also seen MFC examples of what I want to do but I don't understand MFC and really don't want to try to dissect the code to get what I need.

    thanx

    Bob

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change cursor on single edit control
    By Niara in forum Windows Programming
    Replies: 3
    Last Post: 01-11-2009, 08:52 AM
  2. edit control text buffer
    By scurvydog in forum Windows Programming
    Replies: 4
    Last Post: 12-11-2008, 09:13 AM
  3. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21