Page 1 of 2

IsWindow_

Posted: Tue Dec 09, 2014 10:11 am
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?

Re: IsWindow_

Posted: Tue Dec 09, 2014 10:35 am
by PureGuy
What do you expect from that code?
It's unlikely that there are windows with handle 20 and 100.

Re: IsWindow_

Posted: Tue Dec 09, 2014 10:37 am
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 

Re: IsWindow_

Posted: Tue Dec 09, 2014 5:40 pm
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?

Re: IsWindow_

Posted: Tue Dec 09, 2014 6:05 pm
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.

Re: IsWindow_

Posted: Tue Dec 09, 2014 11:11 pm
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 :(

Re: IsWindow_

Posted: Tue Dec 09, 2014 11:38 pm
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?

Re: IsWindow_

Posted: Wed Dec 10, 2014 12:20 am
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.

Re: IsWindow_

Posted: Wed Dec 10, 2014 12:45 am
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.

Re: IsWindow_

Posted: Wed Dec 10, 2014 12:53 am
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:

Re: IsWindow_

Posted: Wed Dec 10, 2014 12:55 am
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...

Re: IsWindow_

Posted: Wed Dec 10, 2014 1:00 am
by mestnyi
Me and Mestnyi are safe
:D
there are not only 20 there are many 22, 100, 300 ...

Re: IsWindow_

Posted: Wed Dec 10, 2014 1:51 am
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:

Re: IsWindow_

Posted: Wed Dec 10, 2014 3:39 am
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.

Re: IsWindow_

Posted: Wed Dec 10, 2014 9:46 am
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: