|
Create Procedure as:
UINT MyThread(LPVOID lParam)<br />
{<br />
SetTimer()<br />
- - - <br />
<br />
return 0;<br />
}<br />
<br />
AfxBeginThread(MyThread,this,thread priority);
Cheers
"Peace of mind through Technology"
|
|
|
|
|
|
There are two approaches:
1. Use multiple threads; or
2. Copy and change between multiple tasks using one thread.
Steve
|
|
|
|
|
i want to develope one pop up blocker and want to run when my site is open.,
it should block unwanted URL popping up...
what to do.. i need sample codings in VC++ MFC or WTL
Ravi Chandran.C
|
|
|
|
|
See:
IHTMLDocument2 Interface.....
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Dear c++ friends,
In VB we have,
Dim MyDouble, MyInt
MyDouble = 2345.5678 ' MyDouble is a Double.
MyInt = CInt(MyDouble) ' MyInt contains 2346.
Is there anything in c++ similar to CInt in VB?
Thanks,
Joy Anne
|
|
|
|
|
Joy Anne wrote: Dim MyDouble, MyInt
MyDouble = 2345.5678 ' MyDouble is a Double.
MyInt = CInt(MyDouble) ' MyInt contains 2346.
double myD = 2345.5678;<br />
int myI = (int)myD;
Maxwell Chen
|
|
|
|
|
This will not round. You need something like this:
double myD = 2345.5678;
int myI = static_cast<int>(myD+0.5);
Also note that I didn't use any C-style casts; they should never be used in C++ code.
Steve
|
|
|
|
|
Which part did my 1-voter not like: The add 0.5 bit or the static_cast lecture? I stand by both of them but I believe that if you're going to down vote something in the programming forums it's good to reply and explain your objection.
Steve
|
|
|
|
|
I voted 5 to balance it...
It used to happen on myself also, when someone doesn't feel like to see the truth.
That's also the reason I posted some reply titled "WTF ?!", remember?!
Maxwell Chen
|
|
|
|
|
Stephen Hewitt wrote: any C-style casts; they should never be used in C++ code.
Personally I guess that the 1-voter doesn't feel comfortable with the sentence above.
Maxwell Chen
|
|
|
|
|
I would guess so - nevertheless they shouldn't be used. Here are some reasons:
- A wrong "bad" can cause havoc yet, if C-style casts are used you can’t “grep” the source code for them.
- There are many distinct reasons to cast. For example, one is to remove const-ness; another is to “down-cast” in a class hierarchy. With C-style casts all casts look the same and so you have to guess at the intent. Function style casts are explicit and self documenting in this respect.
- With C-style casts a simple mistake can change the type of cast and result in unintentional behaviour. For example if your casting to remove const-ness and then you change the type you’re casting it can changes into a “reinterpret” cast. With function style casts the compiler makes sure you can’t cast “more” then you should. i.e. a const_cast can only remove const-ness and not change the type.
- Casting is ugly – a well designed program shouldn’t have any – or at most only a few in the lowest level of a system. Casts should be ugly as design errors should be visible.
I could go on. There are just so many problems it just not funny.
Steve
|
|
|
|
|
Stephen Hewitt wrote: I could go on. There are just so many problems it just not funny.
What did you mean by that?
Maxwell Chen
|
|
|
|
|
Only that I could have made the list of problems with C-style casts longer.
Steve
|
|
|
|
|
So what's happening?! You guys like to vote 1 very much??
Maxwell Chen
|
|
|
|
|
|
I think he is trying to convert a double to int.
Maxwell Chen
|
|
|
|
|
|
Nibu thomas wrote: Faqs are worth a read
Maxwell Chen
|
|
|
|
|
|
Nibu thomas wrote: I can see that question coming!
The diviner ~~~
Maxwell Chen
|
|
|
|
|
hi,
use reinterpret_cast value;
snippet of code.
int x;
double y = 5.66;
now x = reinterpret_cast <int> y; // cast double to int data type.
this is type conversion in c++.
good luck,
uday.
uday kiran
-- modified at 0:57 Wednesday 10th May, 2006
|
|
|
|
|
You don't need to use reinterpret_cast in this case and in fact shouldn’t: casting from double to int is implicit so the following will do the trick:
double d = 3.5;
int i = d;
Is you wanted to make the cast explicit (and there is good reason to do so as it will suppress a warning) static_cast is the right cast for the job. i.e.
double d = 3.5;
int i = static_cast<int>(d);
Part of the point of adding the function style casts was to make your intent specific thus it is important to use the right cast for the job.
Steve
|
|
|
|
|
|
Math.round
public static int round( float a )
Returns the value of the argument rounded to the nearest int value.
--------------------------
just do it like that :
#include <math.h>
:
double MyDouble = 2345.5678 // MyDouble is a Double.
int MyInt = ROUND(MyDouble) // MyInt contains 2346.
:
double MyDouble = 2345.4678 // MyDouble is a Double.
int MyInt = ROUND(MyDouble) // MyInt contains 2345.
|
|
|
|