|
Everyone has there own definition of "mean", that seems far meaner than any of the offensive things I post to people!
|
|
|
|
|
new will call malloc, which (eventually) calls HeapAlloc on the module CRT heap.
If you look at the Heap* API function docs you will see that they are thread safe by default (though this feature can be disabled) ... actually, to be precise, malloc will use a CRT lock (critical section) to lock the heap, but the effect is the same.
So yes, new and delete are thread safe.
As to your example; as led mike pointed out, it depends on what you are doing in 'Do some work, details not shown'.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I have an edit control in a CFormview dialog.
The edit control is DDXed to a some special class which is giving hyperlink functionality.
The control is disappearing or its background becomes same as the dialog sometime and when mouse cursor goes on top of it, it appears from then.
It happens mostly when setting text on that control (by function call) and
the control's class calls "RedrawWindow()", "InvalidateRect" & "UpdateWindow()" for the parent dialog(CFormView) of control when setting text on it.
The problem is happening in Win XP system and not in Vista.
The Formview is using "CreateSolidBrush()" and "FillRect()" function inside OnPaint() to change its back color.
Any suggstion would be greatly appreciable..
--
"Programming is an art that fights back!"
modified on Thursday, March 19, 2009 1:14 PM
|
|
|
|
|
Could it be that your edit is overlapped by some other control like a static for example?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Running VS2008, writing an SDI in VC++. Here's the code in a nutshell:
float htmin;
CString value;
value=mslstr.Mid(parse_start, parse_stop-parse_start);
htmin=atof(value);
VS throws the C4244 warning at the htmin=atof(value); line.
Am I missing something stupid here?
|
|
|
|
|
Nothing. atof returns you a double, and you are assigning it to a float. Nothing serious.
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
|
|
|
|
|
Thx, stickler for no warnings. Is only remedy to initialize htmin as double?
|
|
|
|
|
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
|
|
|
|