Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Jan 18th, 2008, 4:02 PM   #1
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
Exclamation 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.
pcbrainbuster is offline   Reply With Quote
Old Jan 18th, 2008, 4:11 PM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
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.
grumpy is offline   Reply With Quote
Old Jan 18th, 2008, 7:31 PM   #3
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 529
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: GetWindowInfo -

Quote:
Originally Posted by pcbrainbuster View Post
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.
Ancient Dragon is offline   Reply With Quote
Old Jan 18th, 2008, 8:36 PM   #4
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 80
Rep Power: 1 null_ptr0 is on a distinguished road
Re: GetWindowInfo -

Wow, Ancient Dragon for Win32 Wiz.
__________________
iload_0 iconst_1 ishl or
iload_0 iconst_2 idiv or
iload_0 iconst_2 iconst_1 imul idiv
[1] & [2] use the smallest stack size
null_ptr0 is offline   Reply With Quote
Old Jan 19th, 2008, 9:31 AM   #5
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
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.
pcbrainbuster is offline   Reply With Quote
Old Jan 19th, 2008, 10:24 AM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,827
Rep Power: 5 Sane will become famous soon enough
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.

Last edited by Sane; Jan 19th, 2008 at 10:50 AM.
Sane is offline   Reply With Quote
Old Jan 19th, 2008, 11:40 AM   #7
pcbrainbuster
Programmer
 
Join Date: Dec 2007
Posts: 93
Rep Power: 1 pcbrainbuster is on a distinguished road
Re: GetWindowInfo -

Ahh, I see.

So something like the following should return true right? -

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

...

}
...

Thanks.
pcbrainbuster is offline   Reply With Quote
Old Jan 19th, 2008, 1:09 PM   #8
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 80
Rep Power: 1 null_ptr0 is on a distinguished road
Re: GetWindowInfo -

yuck.
if (WNDI.dwStyle & WS_OVERLAPPED) {
...
}
is much better, don't do '== true' or '== false', use the more simple alternatives.
__________________
iload_0 iconst_1 ishl or
iload_0 iconst_2 idiv or
iload_0 iconst_2 iconst_1 imul idiv
[1] & [2] use the smallest stack size
null_ptr0 is offline   Reply With Quote
Old Jan 19th, 2008, 1:46 PM   #9
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 529
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: GetWindowInfo -

Quote:
Originally Posted by null_ptr0 View Post
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.
Ancient Dragon is offline   Reply With Quote
Old Jan 19th, 2008, 2:38 PM   #10
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,827
Rep Power: 5 Sane will become famous soon enough
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.
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 4:33 AM.

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