Board index » cppbuilder » wcout to AnsiString Question

wcout to AnsiString Question


2005-07-11 01:15:34 AM
cppbuilder61
How do I convert this wcout line to an equivilent AnsiString line:
AnsiString Pixels = "Monitor Pixels = ";
hr = pclsObj->Get(L"PixelsPerXLogicalInch", 0, &vtProp, 0, 0);
wcout << " Monitor : " << vtProp.uintVal <<endl;
I want to put the value of vtProp which is a VARIANT as a single line in
String Pixels instead of using wcout.
Thanks.
 
 

Re:wcout to AnsiString Question

Maurice Anderson wrote:
Quote
How do I convert this wcout line to an equivilent AnsiString line:

AnsiString Pixels = "Monitor Pixels = ";
hr = pclsObj->Get(L"PixelsPerXLogicalInch", 0, &vtProp, 0, 0);
wcout << " Monitor : " << vtProp.uintVal <<endl;

I want to put the value of vtProp which is a VARIANT as a single line in
String Pixels instead of using wcout.
you do not need wcout. uintVal is just unsigned integer. You can convert
it using various methods. In this case the easiest is to use sprintf
method of AnsiString class like this:
AnsiString Pixels;
hr = pclsObj->Get(L"PixelsPerXLogicalInch", 0, &vtProp, 0, 0);
Pixels.sprintf("Monitor Pixels = %u",vtProp.uintVal);
Take a look in help for more information on AnsiString class.
BTW this question is for VCL group not cpp.
Darko