Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   GetWindowInfo - (http://www.programmingforums.org/showthread.php?t=14974)

pcbrainbuster Jan 18th, 2008 5:02 PM

GetWindowInfo -
 
Sup guys,

When you do retrieve a window's information using GetWindowInfo, how do you check to see if a window has the style WS_OVERLAPPED?

Thanks.

grumpy Jan 18th, 2008 5:11 PM

Re: GetWindowInfo -
 
Your first step to find an answer is to think for yourself rather than trying to get other people to do the thinking for you. Your second step is RTFM.

Ancient Dragon Jan 18th, 2008 8:31 PM

Re: GetWindowInfo -
 
Quote:

Originally Posted by pcbrainbuster (Post 139848)
Sup guys,

When you do retrieve a window's information using GetWindowInfo, how do you check to see if a window has the style WS_OVERLAPPED?

Thanks.

You have to pass a pointer to a WINDOWINFO object to GetWidowInfo(). Then just and the dwStyle member with WS_OVERLAPPED to see if it is present as one of the styles.

null_ptr0 Jan 18th, 2008 9:36 PM

Re: GetWindowInfo -
 
Wow, Ancient Dragon for Win32 Wiz.

pcbrainbuster Jan 19th, 2008 10:31 AM

Re: GetWindowInfo -
 
Thanks for your posts! Could someone please explain how the operator & works? Also could Grumpy please tell me what the abbreviation stands for?

Thanks.

Sane Jan 19th, 2008 11:24 AM

Re: GetWindowInfo -
 
PcBrain, I hate to say it like this, but a lot of these questions you could be finding answers to more quickly by doing your own research. The & operator is called the bitwise 'and' operator, and it evaluates the 'and' of each bit.

:

  00110101
& 01010011
= 00010001


This can be used to quickly determine whether or not a bit is set.

For instance, if x can contain any integer value, and we want to see if the third bit in x is set:

:

x = 13    // 13 is 00001101
y = x & 4  // 4  is 00000100

y is 1 (True)


So in the context of window styles... I believe each style is represented by a different bit, and you can use a constants to isolate the bit for the style that the constant represents.

pcbrainbuster Jan 19th, 2008 12:40 PM

Re: GetWindowInfo -
 
Ahh, I see.

So something like the following should return true right? -

:

...
GetWindowInfo(hwnd, &WNDI);
...
if((WNDI.dwStyle & WS_OVERLAPPED) == true)
{

...

}
...


Thanks.

null_ptr0 Jan 19th, 2008 2:09 PM

Re: GetWindowInfo -
 
yuck.
:

if (WNDI.dwStyle & WS_OVERLAPPED) {
...
}

is much better, don't do '== true' or '== false', use the more simple alternatives.

Ancient Dragon Jan 19th, 2008 2:46 PM

Re: GetWindowInfo -
 
Quote:

Originally Posted by null_ptr0 (Post 139897)
yuck.
:

if (WNDI.dwStyle & WS_OVERLAPPED) {
...
}

is much better, don't do '== true' or '== false', use the more simple alternatives.

I agree -- the & operator doesn't return true or false, but either 0 if WS_OVERLAPPED is not in the flags or some non-zero value if it does.

Sane Jan 19th, 2008 3:38 PM

Re: GetWindowInfo -
 
My mistake, I probably threw off the op when I said:

y is 1 (True)

(It was supposed to be y is 4 (True) as well...)

In my example, the only reason I said 'True' is because it gives some meaning to the arbitrary value of 4. In a coding scenario, I agree that it's more readable to neglect the '== true'. Sorry about the confusion.


All times are GMT -5. The time now is 3:49 AM.

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