-
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
-
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.
-
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.
-
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