Way to get Active Window Handle?
BlitzMax Forums/BlitzMax Programming/Way to get Active Window Handle?
| ||
Is there a way to get a Window Handle for the window created with Graphics()? Does the application know the handle of it's own window? It must do somehow. If we could get that, we wouldn't need GetActiveWindow() or the Mac equivalent which may be unreliable if another window has become active. Thx. |
| ||
[edit] Never mind - didn't read all of your post. I'm sure there's a native way of doing it - will have a look. (although - if you call GetActiveWindow immediately after creating the graphics object, there's [virtually] zero chance of it being wrong). |
| ||
http://www.blitzbasic.com/Community/posts.php?topic=58568 This thread says that PrimaryDevice.hWnd returns the window handle. You're in that thread so I guess you forgot. However, the thread is two years old and if that solution ever worked, it doesn't seem to in 1.30. |
| ||
Yeah I think that PrimaryDevice was removed in 1.28 or something along with the other DirectX changes. (although - if you call GetActiveWindow immediately after creating the graphics object, there's [virtually] zero chance of it being wrong). I guess so (which is what I'm doing anyway) but someone said that due to OS delays that's not always the case. Also I know for a fact that my equivalent Mac code definitely fails sometimes! |
| ||
For GL on Windows, the handle is stored in the BBGLContext object. Probably just a case of adding a function somewhere to request the handle. |
| ||
Graphics 800,600 Local my_driver:TD3D7Graphicsdriver=D3D7GraphicsDriver() Local my_graphics:TD3D7Graphics=my_driver.Graphics() Local my_hWnd:Int = my_graphics._hwnd Print my_hwnd I think |
| ||
Yay TonyG, that works! Thanks. So now my question is how to obtain the same info from OpenGL on Windows using Brucey's info and also how to obtain that info on Macs... :-) |
| ||
Hi Does anyone know the answer to my question in the post above? Thx! |
| ||
For OGL the information is kept at C++ level and the glgraphics getsettings method calling bbGLGraphicsGetSettings doesn't return the hwnd. I think you'd have to change the C++ code and the glgraphics module but could be wrong. |
| ||
OK thanks for the info Tony, sounds like a bit of a pain. Having the correct Window Handle is pretty useful you see...Maybe I can ask BRL to add it as a global variable or something. What's the best way to make a request do you think? |
| ||
Think email would be best. |
| ||
OK thanks. Will try. ... DONE. |