Characters in a NumericUpDown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Didn't find much documentation on value formatting on a NumericUpDown
control. is it possible to separate numbers by a special character.

For example, If I wanted to display an option to change a person's height in
a NumericUpDown, I would not want them to see 62, I'd want them to see 6'2"
(6-Foot-Two).

Is this even possible?

Thankyou,
 
ReMEn said:
Didn't find much documentation on value formatting on a NumericUpDown
control. is it possible to separate numbers by a special character.

For example, If I wanted to display an option to change a person's height in
a NumericUpDown, I would not want them to see 62, I'd want them to see 6'2"
(6-Foot-Two).

I think the UpDown control only understands integer values ala
Get/SetDlgItemInt. The communication with its 'buddy' is done via WM_GETTEXT
and WM_SETTEXT, so presumably a subclass of the buddy window could
handle/intercept/forward these messages as needed to perform the back and
forth translations.
 
ReMEn said:
Didn't find much documentation on value formatting on a NumericUpDown
control. is it possible to separate numbers by a special character.

For example, If I wanted to display an option to change a person's height in
a NumericUpDown, I would not want them to see 62, I'd want them to see 6'2"
(6-Foot-Two).

Is this even possible?

Thankyou,

You can make a hiden link.

I mean, you have for example IDC_ED_FEET and IDC_SPIN_FEET linked now,
put one more editbox IDC_ED_FEETINT hidden (unvisible) in the window,
and make a link with IDC_SPIN_FEET. By pussing updown button, it will
actually change the content of IDC_ED_FEETINT, from 61 to 62, then
you capture the EN_CHANGE an update your IDC_ED_FEET to 6'2".
When user edited the string 6'2" to something else, you react to
EN_CHANGE and parse the new value and set the IDC_ED_FEETINT.
I don't know what to do if user edited to be "foobaa" instead of valid
height, then you may change the value to be 0.

Don't forget to make a semafor flag to distinguish user's input or
program code which changed the editbox, to avoid recursive EN_CHANGE events...


muchan
 
Back
Top