Bring the application window in front...
BlitzMax Forums/BlitzMax Beginners Area/Bring the application window in front...
| ||
Hello, I would like to ask , if is it possible when the game start , to bring the game application window in top most of all windows. But not set it as top most forever only to bring it in front. Changing the window z order. :) |
| ||
It's not clear whether you're facing this problem right now, or if you're interested in preventing it from happening at some point in the future. When you run your BlitzMax application, the operating system will bring its window to the front automatically. It may still be behind some 'persistent' top-most applications like the Task Manager on Windows, for example, but it will definitely go in front of other common applications. As it is, you shouldn't have to do anything about it, it already works this way. |
| ||
When my game starts , I drop a splash screen and then I close the splash screen and then the game starts. The new window which opens opens behind or have lost its focus. I tried one trick , sometimes works and some time doesn't. After entering in graphics mode I use this Global hwnd:Int 'Window proccedure Graphics(640, 480, 0, 100) hwnd = GetActiveWindow() The game starts. After loading and other stuff I use this code. SetActiveWindow(hwnd) Some times this works. If I use exclusive screen resolution it works. In window mode , some times the application window comes in front and other times stays back. If I have the Blitzmax IDE open or the browser open. |
| ||
You get the hWnd value of whatever is the active window. How do you know that it's the window of your game? It's not guaranteed that it is, even if it's obtained right after creating your window. This all happens so fast that you might be activating the BlitzMax IDE or your browser. First create your window with Graphics(), then retrieve its hWnd with FindWindow (blank class name, just with the title text of your window), then activate it. This is weakly related: http://www.blitzbasic.com/Community/posts.php?topic=103930 |
| ||
then retrieve its hWnd with FindWindow Or even easier and more accurate... You can extract the hWnd handle from a windows TGraphics object... Strict Local g:TGraphics = Graphics(800,600) Local d3d9g:TD3D9Graphics = TD3D9Graphics(TMax2DGraphics(g)._graphics) Local hWnd = d3d9g._hwnd SetActiveWindow(hWnd) |
| ||
I wouldn't say it's more accurate, as FindWindow works fine if you have a unique window title, but it's a great idea. We should find if there's such a way when we're using the OpenGL driver on Windows. I don't think the driver object stores that handle. |
| ||
FindWindow works fine if you have a unique window title Uh huh, as long as that IS the case, hence my little 'more accurate' mention :^) Heres a little code for all 3 drivers on windows... Strict SetGraphicsDriver GLMax2DDriver() Local g:TGraphics = Graphics(800,600) Local hWnd Select True Case TD3D7Graphics(TMax2DGraphics(g)._graphics) <> Null hWnd = TD3D7Graphics(TMax2DGraphics(g)._graphics)._hwnd Case TD3D9Graphics(TMax2DGraphics(g)._graphics) <> Null hWnd = TD3D9Graphics(TMax2DGraphics(g)._graphics)._hwnd Case TGLGraphics(TMax2DGraphics(g)._graphics) <> Null hWnd = Int Ptr (TGLGraphics(TMax2DGraphics(g)._graphics)._context)[8] EndSelect Print hWnd |
| ||
All of your code examples above seems to work perfectly. Thank you very much. |