API's hWND and Query()'s hWND???

BlitzMax Forums/BlitzMax Beginners Area/API's hWND and Query()'s hWND???

SebHoll(Posted 2005) [#1]
Hi,
I'm writing an app that requires a window to be "always on top". However, I've found that MaxGUI's Query() returns a different hWND to that of Windows API. In some circumstances the Query() one works and in other cases you have to use the Windows API hWND.

wndMain = CreateWindow("Original Text",400,400,400,300,0,15)

Extern "win32"
	Function GetActiveWindow()
	Function SetWindowText(hWND%,strWindowText$) = "SetWindowTextA@8"
	Function SetWindowPos(hWND%,zorder%,xpos%,ypos%,width%,height%,flags%)
End Extern

DebugLog ""
DebugLog "Query(wndMain,1) It: " + Query(wndMain,1)
DebugLog "Windows API It: " + GetActiveWindow()

Rem
If you try the Windows API hWND to change the Window's Text then it messes up.
However, if you try it with Query()'s hWND then it works fine.
End Rem

SetWindowText(Query(wndMain,1),"Changed Window Text")	'Works fine with Query()
'SetWindowText(GetActiveWindow(),"Changed Window Text")	'Doesn't work with API

Rem
However, Query()'s hWND doesn't work if you try to make the window on top,
but instead the Windows API one does?!?!? - Is this really weird?
End Rem

'SetWindowPos(Query(wndMain,1),-1,0,0,0,0,43)	' Doesn't work with Query()
SetWindowPos(GetActiveWindow(),-1,0,0,0,0,43)	' Works fine with API


Repeat

Select WaitEvent()

	Case EVENT_WINDOWCLOSE;End
	
End Select

Forever
Why are the two values different? - Is this a bug with Blitz? Incase this might be an O/S related issue I'm running XP Pro (SP2). Could anyone else try this code and make sense of what's happening?

Cheers

Seb


SebHoll(Posted 2005) [#2]
Also, I've just tried it on a Windows 2000 Pro computer and it is still doing the same thing. (Different hWNDs for the same window which each are used for different function calls.)


Perturbatio(Posted 2005) [#3]
what version BMax are you using?

Query was renamed to QueryGadget in 1.14


SebHoll(Posted 2005) [#4]
I am using 1.12. Is the problem fixed in 1.14? If so, I'll upgrade. However I gave the code to a friend who has 1.14 and he said he has got the same problem with the different hWNDs.

Any ideas?


Mark Tiffany(Posted 2005) [#5]
I am using 1.12. Is the problem fixed in 1.14? If so, I'll upgrade. However I gave the code to a friend who has 1.14 and he said he has got the same problem with the different hWNDs.

I don't think 1.14 changed anything more than the name of this function. However, as it included other fixes, and there have been several more fixes through syncmods in the past 3 weeks, I strongly suggest you do upgrade to check. At the very least, you are more likely to get a BRL response if you are on the latest version.


SebHoll(Posted 2005) [#6]
Thanks Mark. Will do so...