PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GD window mode questions

I've been working with GD on the desktop PC and found out that I needed the ff. features. I hope someone can shed some light on this. :)

1. Is there a way I can always have my GD window app centered on the the desktop PC's screen everytime it is launched/run? If so, how do I do this? I presume I need to add something in the config? I'm using the GapiApplication framework.

2. If I set "config.bRegainLostFocus = true;", my GD app will not minimize if the focus was lost. However, I want my app to detect if the focus was lost, how do I do this using GapiApplication? Is there a way I can add an "OnLostFocus" event along with "OnMinimize" and "OnRestore"?

Thanks in advance! :)
In general, I would recommend against windowed mode games in the first place (except for debugging). With users running different desktop shells, skins etc it will increase support issues by a magnitude. But to answer your questions:

(1) Try changing the left/top position by modifying the lines:
RECT rect;
::GetWindowRect(m_hWnd, &rect);
::MoveWindow(m_hWnd, rect.left, rect.top, 0, 0, TRUE);

in GapiApplication.cpp. Change rect.left and rect.top to be centerX - (width>>1), and centerY - (height>>1) respectively.

As for (2) I guess you would have to dig into CGapiApplication and see what you can find out. Unfortunately I don't have an easy solution to this one...
InexorableTash · 15 Aug 2004, 04:27 UTC
For (2) you want to add a case for WM_KILLFOCUS into CGapiApplication::WindowProc. Look it up on MSDN to make sure you handle it properly; look carefully at the Remarks section - changing window states can deadlock the app.
Thanks for the tips guys! :)