|
If you can get a window handle, you can get use getdlgitemid....
Iain.
|
|
|
|
|
This is not reliable. For example what about windowess controls. Also even if the control has a HWND is may not be a child of the dialog - when ATL hosting code is used this be the case for example.
Steve
|
|
|
|
|
Sir,
I want to create a new option called password on right click at file and folder in the Window explorer programically using VC++ 6.0.
please help.
Thanks
|
|
|
|
|
|
See here[^] maybe its some helpful for you
|
|
|
|
|
Hello,
I have a floating point variable:
float fMyFloat;
How do I round it too a desired number of decimal places?
Thanks,
BP
-- modified at 14:38 Saturday 30th September, 2006
|
|
|
|
|
u use %.2f format specifier in place of %f
float fMyFloat;
printf("%.2f",fMyFloat);
|
|
|
|
|
Sir,
I want to do the sane thing in vc++ I mean i don't want to use printf .I mean i have to round a float variable .Can i know a function that do this functionality.
Thanks
|
|
|
|
|
|
First you have to decide what kind of rounding you’re after. There are four common ways rounding can be performed:
- Towards +ve infinity.
- Towards -ve infinity.
- Towards 0.
- Away from 0.
Towards +ve infinity:
In this mode we choose the closest number that’s higher. For example, if rounding to the nearest integer:
1.6 -> 2
-1.6 -> -1
Towards -ve infinity:
In this mode we choose the closest number that’s lower. For example, if rounding to the nearest integer:
1.6 -> 1
-1.6 -> -2
Towards 0:
In this mode we chose the closet number in the direction of zero. For example, if rounding to the nearest integer:
1.6 -> 1
-1.6 -> -1
Towards 0:
In this mode we chose the closet number in the direction away from zero. For example, if rounding to the nearest integer:
1.6 -> 2
-1.6 -> -2
For simplicity I’ll only consider the “Towards +ve infinity” mode. If you want to round a double or float to the closest integer code like this will do it:
int n = double_val+0.5;
To a double to the nearest tenth:
double n = floor(double_val*10.0+0.5)/10.0;
To a double to the nearest hundredth:
double n = floor(double_val*100.0+0.5)/100.0;
Steve
|
|
|
|
|
|
use floor and ceil
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
First, thank you all for your answers, they are proving very helpful.
Now, however, I've encountered a different issue:
I get the right results from the floor function. However, when I do the final division (I'm getting this information from stepping through the code in the VC++ .NET Debugger):
//m_fAmount is a float
m_fAmount = 30679.000
iDivisor = 1000.0000
m_fAmount / iDivisor yields: 30.679001
I am really puzzled as I'd like to think that the compiler can do simple arithmatic However, in all seriousness, what's causing this, I'm really puzzled.
Any and all help is greatly appreicated.
Thanks,
BP
|
|
|
|
|
It's caused by round-off errors in decimal->binary->decimal conversion.
|
|
|
|
|
Do you know where I can find some information on that error and how to compensate?
Thanks,
BP
|
|
|
|
|
Just say we're working in decimal with 4 places after the decimal point. Using this scheme we can represent the following numbers exactly:
1.0000
3.0000
But it we try to divide them:
1.0000/3.0000 = 0.3333
This answer is wrong already, the correct answer us 0.333333.... (the 3 recurs forever).
So now consider this sum:
(1.0000/3.0000)*3.0000 = 0.9999
This sort of things happens in all floating or fixed point numbering systems. The computer uses base 2 and not base 10 however.
Try using double instead of float ; there is seldom a good reason to prefer a float over a double
Steve
|
|
|
|
|
|
Greetings Colleagues,
I have a quick question. How do you return an object by value?
The following code:
<br />
MyObject MyClass::operator+(const MyClass & mcRhs)<br />
{<br />
MyClass mcNewObject();<br />
return mcNewObject;<br />
}<br />
results in the following error: c++ error C2664: No constructor could take the source type, or constructor overload resolution was ambiguous
It says it can't convert it. Ironically, when I leave the parentheses off of the instantiation of mcNewObject, it works!? Can someone please explain.
Thanks a million.
Sincerely,
BP
|
|
|
|
|
Can you post the definitions of the two classes?
Or... what line was the error on?
Mike
|
|
|
|
|
Thanks for replying,
This is the actual function
<br />
CNumber CNumber::operator+(const CNumber & cnThisNumber)<br />
{<br />
if((m_bIsBlank) || (cnThisNumber.ReturnIsBlank()))<br />
{<br />
CNumber cnBlankNumber();<br />
return cnBlankNumber;<br />
}<br />
else<br />
{<br />
float fReturnAmount;<br />
cnThisNumber.GetAmount(fReturnAmount);<br />
fReturnAmount = m_fAmount - fReturnAmount;<br />
CNumber cnNewAmount(fReturnAmount);<br />
return cnNewAmount;<br />
}<br />
}<br />
This is the copy constructor I have defined...
<br />
CNumber::CNumber(const CNumber & cnThisNumber) : m_iMaxDecimals(10)<br />
{<br />
cnThisNumber.GetAmount(m_fAmount);<br />
cnThisNumber.GetOriginalAmount(m_fOriginalAmount);<br />
m_bFormatChange = cnThisNumber.ReturnFormatChange();<br />
m_bIsZero = cnThisNumber.ReturnIsZero();<br />
m_strStringAmount = cnThisNumber.ReturnStringAmount();<br />
m_bIsBlank = cnThisNumber.ReturnIsBlank();<br />
}<br />
If I change "CNumber cnBlankNumber()" in the operator overload to "CNumber cnBlankNumber" it works. I just don't get it.
|
|
|
|
|
I don't get the () thing, but try doing return CNumber; or return CNumber(); .
Also - do you have a default constructor defined?
Mike
|
|
|
|
|
I will try that, and yes I do have a default constructor defined.
Thanks,
BP
|
|
|
|
|
BlitzPackage wrote: It says it can't convert it. Ironically, when I leave the parentheses off of the instantiation of mcNewObject, it works!? Can someone please explain.
Because C++ is not C# or Java. Look up how you define an object in C++ using the default ctor.
|
|
|
|
|
MyClass mcNewObject();
is a function declaration I think (Mike Dunn pointed that out to me via this forum when I did a similar thing a while back when trying to test constructor behavior a while back. Silly me )
|
|
|
|
|
This is a 'Ping' Message just to Ensure my ID
LateNightsInNewry
|
|
|
|