Leading 0s in an up/down control

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

Guest

I have a numeric up/down control with it's Hexadecimal property set to true.
I would like to use it to represent 32-bit hex values and would like it to
always display all 8 digits even if they're 0s. Is there a reasonable way
to do this? Thanks!
 
I have a numeric up/down control with it's Hexadecimal property set to
true. I would like to use it to represent 32-bit hex values and would
like it
to always display all 8 digits even if they're 0s. Is there a
reasonable way to do this? Thanks!

Define "reasonable". :)

For sure, you could inherit the class and override the OnPaint() method to
use your own format for drawing the text. I suspect this will lead to
issues related to subtle differences in how you implement the drawing and
how the base control does; it might not look exactly the same. But this
might sufficient for your needs.

Alternatively, you *might* be able to get away with overriding, but
instead of drawing the text yourself, just temporarily changing the text
to what you want it to look like. My only concern there is that changing
the text might cause invalidation of the control, which might cause an
endless loop redrawing the control. However, normally at the end of a
paint event, all invalidated regions are discarded (under the assumption
that the whole control has been repainted) and so it's possible this
wouldn't come up.

I would be surprised if you get a reply from someone who has actually done
what you're trying to do, but if you do, their advice would obviously be
the best to follow. :)

Pete
 
Back
Top