PocketMatrix forums

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

Minimize on Smartphone and CGapiApplicationMT

I have just configured my Smartphone app to use the multithreaded version of CGapiApplication. This seems to have given me a small performance increase, but it also has caused one problem.

I have the app configured so that the user can minimize the application by pressing the '9' button. This is useful if people want to check a contact or something while they're playing without quiting the game.
In order to do this I just call the public function Minimize() when the key is pressed. When this happens my app becomes minimized as expected. The problem occurs when I try to restore the app (on the Smartphone this is done using the back key). It seems the phone tries to restore the game but it immediately loses focus again - the onscreen effect is basically that the game flashes up and then the phone returns to the home screen.

I assume that this is something to do with the fact that the threads for ProcessNextFrame and key press handling are different. Just to confuse me even more, when I receive an incoming call and the game minimizes for that I can restore simply by pressing the back key.

Is there something I'm missing? I have also tried setting a flag when the key is pressed and then calling Minimize() from the processnextframe method if the flag is true. This doesn't work either.

Any pointers would be great. Thanks in advance.
Thanks for the report, I'll check this out immediately...

The minimize/restore code is not shared between the two CGapiApplication classes so I might have missed something in the MT class...

//Johan
gevans2000: Just to make sure, you are using an actual phone and not the emulator, right?
Johan,

I'm using an Orange SPV. One other thing that could be important is that I'm also using Hekkus Sound System. I don't see why that should make a difference but I thought I'd better let you know.

It's certainly possible that I'm doing something wrong - but I did read that the behaviour of the multithreaded CGapiApp should be the same, which with this problem it doesn't seem to be.

Thanks.
One last thing - I'm using GD 2.03 - That could make a difference. I know I should move up to 2.05, I will for my next project :)
gevans2000: I tried this with 2.05, and it seems that the smartphone os sends some other event when the "back" button is used. I got the "back" button to work in some cases, but not in all cases. Relaunching the application using the menu (and not the back button) works everytime, which leads me to think that this issue is related to the smartphone os. IMHO it's not a big deal however, and if possible please try the non-multithreaded CGapiApplication to see if it works ok with that. The performance difference between the two of them should be minimal.
the back button on Smartphones is more typically used to exit programs, not to restart them

to restart them you typically reselect the shortcut (or the most recent used apps if you are using that homepage) and as Johan says, the app should restore
Pejo Software - Per · 21 Nov 2003, 07:56 UTC
You could try to use:
SetForegroundWindow(GetDesktopWindow());
instead of Minimize().
If you use this approach Please don't forget to set m_config.bMinimizeOnLostFocus to true.