IsWindow_

Windows specific forum
mestnyi
Addict
Addict
Posts: 1105
Joined: Mon Nov 25, 2013 6:41 am

IsWindow_

Post by mestnyi »

Code: Select all

hWnd=OpenWindow(10, 0, 0, 300, 200, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)

hWnd = 20
If IsWindow_(hWnd)
  Debug hWnd
EndIf
  
hWnd = 100
If IsWindow_(hWnd)
  Debug hWnd
EndIf
  
While WaitWindowEvent()!#PB_Event_CloseWindow :Wend
Why this behavior?
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: IsWindow_

Post by PureGuy »

What do you expect from that code?
It's unlikely that there are windows with handle 20 and 100.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: IsWindow_

Post by ts-soft »

The result of openwindow (if not using #PB_Any), is hwnd!

Code: Select all

hWnd=OpenWindow(10, 0, 0, 300, 200, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)

;hWnd = 20
If IsWindow_(hWnd)
  Debug hWnd
EndIf
 
;hWnd = 100
If IsWindow_(hWnd)
  Debug hWnd
EndIf
 
While WaitWindowEvent()!#PB_Event_CloseWindow :Wend 
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
mestnyi
Addict
Addict
Posts: 1105
Joined: Mon Nov 25, 2013 6:41 am

Re: IsWindow_

Post by mestnyi »

What do you expect from that code?
I want to receive true if is the handle
It's unlikely that there are windows with handle 20 and 100.
That's exactly why the condition?
Little John
Addict
Addict
Posts: 4807
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IsWindow_

Post by Little John »

mestnyi wrote:
What do you expect from that code?
I want to receive true if is the handle
Why do you think just 20 or 100 would be a handle?
Why don't you test 21, 47, 188, ... as well?
mestnyi wrote:

Code: Select all

hWnd=OpenWindow(10, 0, 0, 300, 200, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
There you already have a window handle. What's wrong with it?
And after you have got that handle, you are overwriting the value of that variable with 20 and 100, respectively. That does not make any sense.

I think you should explain more in detail, what you actually want to achieve.
mestnyi
Addict
Addict
Posts: 1105
Joined: Mon Nov 25, 2013 6:41 am

Re: IsWindow_

Post by mestnyi »

What are you stuck on 20 100, this is an example that these conditions did not have to work because these numbers are not the handle

Code: Select all

hWnd=OpenWindow(10, 0, 0, 300, 200, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)

If IsWindow_(hWnd)
  Debug "Is WindowHandle "+hWnd
EndIf
  
hWnd = 19
If Not IsWindow_(hWnd)
  Debug "Is Not WindowHandle "+hWnd 
EndIf

hWnd = 20
If IsWindow_(hWnd)
  Debug "Is WindowHandle "+hWnd ;is not handle why work???
EndIf
  
While WaitWindowEvent()!#PB_Event_CloseWindow :Wend
If, and now it is not clear, I do not know how to explain it :(
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: IsWindow_

Post by PureGuy »

It doesn't work here, so on your system there is a windows that has a handle with value 20.
There 100 or better say thousand of windows on your current desktop most of these are hidden.

Why shouldn't you have luck that one has a hwnd of 20?
Fred
Administrator
Administrator
Posts: 18361
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: IsWindow_

Post by Fred »

IsWindow_() test all window in the whole OS, not just the window in your pogram, so it's possible you have a window handle of 20.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: IsWindow_

Post by netmaestro »

20 is a valid hwnd on my system as well. GetClassname returns #32774, which is 'tooltip'. No idea for what but it could be a bug in the OS as I don't believe it's legitimate. A combination of EnumWindows and EnumChildWindows returns a list of hwnds the smallest of which is 65560. Yet IsWindow_(20) returns true and GetClassname works for it. Puzzling.
BERESHEIT
mestnyi
Addict
Addict
Posts: 1105
Joined: Mon Nov 25, 2013 6:41 am

Re: IsWindow_

Post by mestnyi »

IsWindow_() test all window in the whole OS
This explains a lot, :( how to be? how to distinguish between the handle on the number? better yet how to distinguish a gadget from the statement handle window handle.
I probably bored you, :) but with this I have a problem. :cry:
Last edited by mestnyi on Wed Dec 10, 2014 12:56 am, edited 1 time in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: IsWindow_

Post by netmaestro »

One possibility is that 20 is the handle for a reward tooltip that MS gives out to users who never ever look at porn on their computer. Me and Mestnyi are safe, but I don't know what that says about the rest of you guys...
BERESHEIT
mestnyi
Addict
Addict
Posts: 1105
Joined: Mon Nov 25, 2013 6:41 am

Re: IsWindow_

Post by mestnyi »

Me and Mestnyi are safe
:D
there are not only 20 there are many 22, 100, 300 ...
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: IsWindow_

Post by electrochrisso »

netmaestro wrote:One possibility is that 20 is the handle for a reward tooltip that MS gives out to users who never ever look at porn on their computer. Me and Mestnyi are safe, but I don't know what that says about the rest of you guys...
Hey! Maybe thats the reason I never get a 20, and I am also going blind. :lol:
PureBasic! Purely the best 8)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: IsWindow_

Post by RASHAD »

MSDN
Remarks
A thread should not use IsWindow for a window that it did not create because the window could be destroyed after this function was called. Further, because window handles are recycled the handle could even point to a different window.
Egypt my love
Little John
Addict
Addict
Posts: 4807
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IsWindow_

Post by Little John »

Aaaahhh ... Now I see what the actual question was. :shock:
netmaestro wrote:One possibility is that 20 is the handle for a reward tooltip that MS gives out to users who never ever look at porn on their computer. Me and Mestnyi are safe, but I don't know what that says about the rest of you guys...
:lol:
Post Reply