Window Position...

Blitz3D Forums/Blitz3D Programming/Window Position...

BMA(Posted 2006) [#1]
Hi,

how can I found out the x/y position of my windowed B3D application on the desktop. I couldn't find any commands in the help files...

Thanks.


jfk EO-11110(Posted 2006) [#2]
these things are done using the windows api, you may find a complete description about windows, windowing etc. that is part of user32.dll at microsoft developer network: www.msdn.com . To use those functions in Blitz, you need to reference them in userlibs (*.decsl files), so better become familar with bitz userlibs (some examples are in the code archives).


jfk EO-11110(Posted 2006) [#3]
Ok, maybe it was a bit tuff to leave you alone with the entire win api. Here's some detailed info:
you need to create a file in the "userlibs" folder (located inside your Blitz3D installation folder). Yo may create the file using "New Textfile", then edit it with Notepad and finally rename it to "user32.decls".

The file should then contain the following lines:

.lib "user32.dll"
GetWindowRect%(hwnd%,buff*)

If you already have that user32.decls, you probably only need to add the GetWindowRect Line.

Now in Blitz you need to do the following:

graphics 640,480,32,2
setbuffer backbuffer()

bank=createbank(4*4) ; windows will use this for its answer
my_hwnd=systemproperty$("AppHWND") ; get your apps window handle
GetWindowRect(my_hwnd,bank) ; call the external Api function
x1=peekint(bank,0)
y1=peekint(bank,4)
x2=peekint(bank,8)
y2=peekint(bank,12)

Now you've got the upper left corner and the lower right corner position of your window on the desktop, including the borders.

There are many many more Api functions, so it's a good idea to check out the userlib stuff and some of the windows Api.


BMA(Posted 2006) [#4]
jfk, thank you very much for your answers :-)

I'll check it out immediately!