I need an EDITTEXT control that only allows a single character to be
entered. (To specify a macro hot-key.) This turns out to be more
difficult than I was expecting. It is easy enough to retreive only
the first entered char with GetDlgItemText, but I'd like the control
to only allow entry of one char.
I suppose one crude way would be to force a fixed-width font and use a
small control window, but this doesn't work with proportional fonts.
(A control wide enough for a 'W' will allow more than one 'i', for
example.)
A kludgey way is to force the focus away from the control as soon as
any change is detected. This appears to work perfectly, until you go
back to change the entered char: The control sets the I-beam cursor
*after* the initial char. I assume this can be fixed by manipulating
the cursor position, but I wonder if there is a better way.
I assume this is a fairly common problem that someone has put some
thought into and come up with a solid, debugged solution. No sense in
me re-inventing the wheel, especially since my first few efforts seem
to have had a few wobbles! Anyone?
Thanks, and best regards,
Bob Masta
DAQARTA v3.50
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, FREE Signal Generator
Science with your sound card!