![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: GetWindowInfo -
Quote:
If you want to learn, it is better to put some time into reading readily available documentation (eg on MSDN in your case) and putting in effort to understand it, rather than asking others to provide you with canned answers. In practice, some people attach different words to one or two letters of the RTFM abbreviation to more strongly emphasise the message. I'll leave it to you to find out examples of that for yourself. Last edited by grumpy; Jan 19th, 2008 at 4:14 PM. |
|
|
|
|
|
|
#12 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: GetWindowInfo -
I'm currently feeling the direct opposite of Sane right now
I'm even more confused then I was before.Questions - 1) American Dragon mensioned that 'it' doesn't even return true or false. Well, if that is the case, then isn't it like saying that the statement is always true(I know that this has no chance of being true(what I said) though)? Please expand on this. 2) This is a optional question; It never really hit me but I've seen people do something like "if(hWnd) ...", what does this check or compare exactly? Sorry for all the questions , thanks. |
|
|
|
|
|
#13 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: GetWindowInfo -
Quote:
Roughly speaking, the construct "if (x)" tests if x is non-zero. Any non-zero value will be detected as true, and only zero tests as false. So the test "if (x)" is equivalent to "if (x != 0)". It tests if hWnd is non-zero. Since window handles are implemented as pointers, and there is an incidental rule that setting a pointer to zero has the same effect as setting it to NULL, the test "if (hWnd)" is shorthand for "if (hWnd != NULL)". |
|
|
|
|
|
|
#14 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: GetWindowInfo -
Lol, I got him confused with one of the cartoons in this country
![]() Here are a couple more questions : 1) Are 0, false and NULL the same? 2) Is any number other then 0 the same as true? Thanks! |
|
|
|
|
|
#15 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: GetWindowInfo -
No; if you look they are typed differently.
0 is an integer value of zero. false is a keyword. NULL is an implementation-defined null pointer value. They can be converted to each other in some contexts. For example, (int)false yields a value of 0. (int)true has a value of 1 if that's what you mean. |
|
|
|
|
|
#16 |
|
Programming Guru
![]() |
Re: GetWindowInfo -
Sometimes the best way to understand something is to try and see for yourself...
For example, try running this. Look at the output. Notice how all if statements evaluate as True, except for those with == true. Only an integer of 1, as Grumpy pointed out, will be equal to true.#include <iostream>
using namespace std;
void eval(bool x) {
if(x) cout << "Is True\n";
else cout << "Is False\n";
}
void experiment(int x, int y) {
cout << (x) << " & " << (y) << " = " << (x & y) << "\n\n";
eval(x);
eval(y);
eval(x & y);
eval(x & y == y);
eval(x & y != 0);
eval(x & y != false);
eval(x == true);
eval(y == true);
eval(x & y == true);
}
int main() {
// 13 is 00001101
// 4 is 00000100
experiment(13, 4);
return 0;
} |
|
|
|
|
|
#17 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: GetWindowInfo -
Thanks to you all for your great help!
RESOLVED |
|
|
|
|
|
#18 |
|
Hobbyist
Join Date: Sep 2005
Posts: 261
Rep Power: 4
![]() |
Re: GetWindowInfo -
Sane, the code below is broken. Due to the higher precedence of operator == over operator & your code actually evaluates to (x & (y == y)). I think your intention was ((x & y) == y). This goes for the other operators you used too.
eval(x & y == y); |
|
|
|
|
|
#19 |
|
Programming Guru
![]() |
Re: GetWindowInfo -
Oh shoot. Thank-you for the correction. Conveniently, the output is no different.
#include <iostream>
using namespace std;
void eval(bool x) {
if(x) cout << "Is True\n";
else cout << "Is False\n";
}
void experiment(int x, int y) {
cout << (x) << " & " << (y) << " = " << (x & y) << "\n\n";
eval(x);
eval(y);
eval(x & y);
eval((x & y) == y);
eval((x & y) != 0);
eval((x & y) != false);
eval(x == true);
eval(y == true);
eval((x & y) == true);
}
int main() {
// 13 is 00001101
// 4 is 00000100
experiment(13, 4);
return 0;
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|