Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 19th, 2008, 4:01 PM   #11
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Re: GetWindowInfo -

Quote:
Originally Posted by pcbrainbuster View Post
Also could Grumpy please tell me what the abbreviation stands for?
RTFM = Read The Fine Manual

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.
grumpy is offline   Reply With Quote
Old Jan 19th, 2008, 5:44 PM   #12
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
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.
pcbrainbuster is offline   Reply With Quote
Old Jan 19th, 2008, 7:18 PM   #13
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Re: GetWindowInfo -

Quote:
Originally Posted by pcbrainbuster View Post
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.
Actually, the Dragon is Ancient.

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)".
Quote:
Originally Posted by pcbrainbuster View Post
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?
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)".
grumpy is offline   Reply With Quote
Old Jan 20th, 2008, 7:37 AM   #14
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
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!
pcbrainbuster is offline   Reply With Quote
Old Jan 20th, 2008, 8:03 AM   #15
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Re: GetWindowInfo -

Quote:
Originally Posted by pcbrainbuster View Post
1) Are 0, false and NULL the same?
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.
Quote:
Originally Posted by pcbrainbuster View Post
2) Is any number other then 0 the same as true?
(int)true has a value of 1 if that's what you mean.
grumpy is offline   Reply With Quote
Old Jan 20th, 2008, 11:23 AM   #16
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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;
}
Sane is offline   Reply With Quote
Old Jan 20th, 2008, 12:46 PM   #17
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
Re: GetWindowInfo -

Thanks to you all for your great help!

RESOLVED
pcbrainbuster is offline   Reply With Quote
Old Jan 20th, 2008, 5:56 PM   #18
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 261
Rep Power: 4 Cache is on a distinguished road
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);
Cache is offline   Reply With Quote
Old Jan 20th, 2008, 6:12 PM   #19
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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;
}
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC