|
penny black wrote: Is only remedy to initialize htmin as double?
An explicit cast will do the trick
htmin = static_cast<float>(atof(value));
BTW atof is just an axample of misnamed function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Thursday, March 19, 2009 2:46 PM
|
|
|
|
|
another way to eat the warning
std::istringstream b("100.003133");
float f1;
b >> f1;
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
very good, indeed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
static_cast gave me syntax error.
|
|
|
|
|
It shouldn't (I made a test).
What is exactly your code (and waht is the error message)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Here is, what I think, the pertinent part of code:
CString value;
value=mslstr.Mid(parse_start, parse_stop-parse_start);
float htmin;
htmin=static_cast(atof(value));
Here is the error:
.\sruleDoc.cpp(1072) : error C2059: syntax error : '('
Line 1072 is htmin=static_cast(atof(value));
|
|
|
|
|
Should be
htmin=static_cast<float>(atof(value));
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
lol he mentioned a sample.. to be precise,
static_cast<float>(atof(value))
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
CPallini wrote: It shouldn't (I made a test).
But you probably forgot that the < and > characters are removed from your post
|
|
|
|
|
Oh, my bad . Thank you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry, I made a typo in my example. Fixed now. Sorry again.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
penny black wrote: Is only remedy to initialize htmin as double?
Or better would be to ignore it?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I'd love to. I just migrated some code from VC++6.0 to VS2008 and I'm getting hundreds of C4244 warnings.
|
|
|
|
|
There is, in general, no reason to use float rather than double. 4 bytes memory saved? Big deal. Performance? The math co-processor in Intel apps uses double internally - doubles are actually quicker.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for all the info. Looks like I've got two workable solutions.
|
|
|
|
|
Hi,
I know MFC has specfic message map macros e.g. ON_WM_CLOSE coreesponding to the
overridable onclose method
However is'nt ON_MESSAGE a catchall
Where I can code the SDK message e.g WM_CLOSE as the first parm and my method to handle this as the second ???
Or if I were handling response from a control (e.g clicking the OK button)
I could code ON_MESSAGE(ID_OK,my_ok_response) to process this message
thnakx
|
|
|
|
|
ForNow wrote: I could code ON_MESSAGE(ID_OK,my_ok_response) to process this message
Did it work?
|
|
|
|
|
ForNow wrote: I could code ON_MESSAGE(ID_OK,my_ok_response) to process this message
No you couldn't - should use ON_COMMAND(ID_OK, my_ok_response) to process that.
ForNow wrote: Where I can code the SDK message e.g WM_CLOSE as the first parm and my method to handle this as the second ???
use ON_MESSAGE(WM_CLOSE, myCustomCloser) where myCustomCloser has the signature
LRESULT myCustomCloser(WPARAM, LPARAM);
in your window class.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
So ON_MESSAGE is for Windows system messages whereas ON_COMMAND is for anyhting thats WM_USER + .....
thankx
|
|
|
|
|
ForNow wrote: So ON_MESSAGE is for Windows system messages
Yes
ForNow wrote: ON_COMMAND is for anyhting thats WM_USER + .....
No - if you look at the definition of the ON_COMMAND macro, you'll see this:
#define ON_COMMAND(id, memberFxn) \
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSigCmd_v, \
static_cast<AFX_PMSG> (memberFxn) },
What this means is that ON_COMMAND handles the WM_COMMAND[^] message, which (to quote that page) is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Hi,
Please give me a sample to use RegQueryValueEx()..and i want to store the value in a CString..Please help me out.. as im a beginner..
|
|
|
|
|
You may find sample code in the RegQueryValueEx documentation page [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes, there's a useful sample on that page, if you're interested in getting a data object with an unknown size. But if you want to read a C string and convert that string to a CString, you are probably better off with this:
<br />
BOOL ReadStringFromMysterioiusOSSource(char* destination, int maxChar);<br />
<br />
<br />
CString myValue;<br />
char buf[438];<br />
ReadStringFromMysterioiusOSSource(buf, 438);<br />
myValue = buf;<br />
(If you really need to use a OS function, just use the CString's assignment operator)
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|