Alright, I am creating a high-speed, lightweight, object-oriented windowing library in C++ and am working on a control that looks and acts like the "NumericUpDown" in VB.NET. I have most of it up, but have run into a problem. I store the value in a float variable, but you cannot directly plop a float value into an edit control. The thing is, the user is allowed to specify three types of display. One is currency, which will display a dollar sign and the value including two decimal-places. The other is a straight integer-style which is just the number without any decimal places, and the final is a float value with one to eight decimal places.
That said, how could I go about putting the float value into an array of wchar_t type variables without looping and what-not? I know the old ANSI method of using sprintf(), but since this is a UNICODE, C++ project, I thought that maybe there would be a more efficient way of doing things. Thanks for the help!
Here is what I am thinking, but am not sure whether or not it will work. The "bCurrency" flag indicates whether or not the value being stored is money.
//Format the number properly
wsprintf(pFormat, L"$%8.2f ");
wsprintf(pFormat, L"%8.%df ", this->Decimals);
//Now generate the actual display buffer
wsprintf(pBuffer, pFormat, this->fValue);
Is that doable, or a bad practice? The buffer is wchar_t and the format is wchar_t.