PocketMatrix forums

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

game crashing after battery alerts & appointment pop-ups

My in-development game crashes when windows notifications like battery low happen.

I have seen some brief mention of this problem in this board but not a solution as such.
Do I need to pick up on some event & handle it within my game to stop the game going belly up?

ps: It's a PocketFrog application but I assume the problem is relevant to any GAPI based game.
angedelamort · 25 Apr 2003, 14:38 UTC
Maybe you can try to just pause your app when it loose focus. It should work.
Conan · 25 Apr 2003, 15:56 UTC — lose focus???
I would if I knew how to tell if an all loses focus. I will search on that topic.

Thanks
There's a message for battery notification...and you can intercept it...I just can't seem to find it in the f'ing documentation...

I've done this already, but I can't remember why or when. When I find it I will let you know.
GapiDraw supports all this + more.. Download + check out the code in GapiDrawApplication.cpp... The code has been tested on some tens of thousand PDAs.
I think the message you want is WM_LOSTFOCUS.
I don't know about anyone else, but I won't go with GapiDraw no matter how good it is because I don't like the idea of having to get their permission to use it (I am thinking of the right library, am I not?).

It's just my 2 cents, probably worth considerably less anyway, but to me you either say the library is open and do what you want with it (ala PocketFrog) or you say you have to purchase a license to use it and the fees are x, y and z depending on the project (like other libraries out there). I don't know, something in the middle just seems ambiguous to me and I don't like ambiguity.

Off-topic post ends now...
agreed...plus the fact that it took me a WHOLE 2 weeks to make a drawing library on GAPI that supports everything it does and more...so...pthhh!

yeah...

Oh, and WM_LOSTFOCUS doesn't work. There's a kb article out there somewhere on this subject...and I've been looking all over for it...but I can't seem to find it. I'd swear you have to register the app to recieve the message and then check for it...it may be in the SH_ world...but I can't FIND IT.
it's ok Frank, SBL isn't saying 'use gapidraw' he's just pointing out that we can see how it's done by studying the source.

I will download latest gapidraw & explore.

ps: anyone who is reading this, gapidraw is a superb application, just so happens that Frank & I find PocketFrog easier to use.
warmi · 26 Apr 2003, 00:17 UTC — warmi
GapiDraw is now also faster than PocketFrog.

To MeumSimulacrum:

Generally it does make sense to use code that has been tested on multiple devices by thousands of people ...
Sometimes you learn the hard way …
Just to avoid a one library vs. the other possibility here, let me make clear that I'm not hammering GapiDraw at all. I played with it a bit and it seems like a fine piece of work. I was just commenting on the "license", so to speak, that I personally don't care for.

Anyway... I'm interested in the question of battery warnings as well, since the same problem seems to occur in my current game. I haven't looked into it one bit yet, but I am interested to see if you come up with an answer either way.
Kzinti · 26 Apr 2003, 02:44 UTC — warmi
warmi wrote:
GapiDraw is now also faster than PocketFrog.


What's so cool with GapiDraw is that not only is it faster then anyone other library available. It's using state-of-the-art and optimized algorithms. What's even more cool is that GapiDraw regularly gets improvements in speed on the order of 40-100%!

Soon GapiDraw will run faster then your PPC can!
I don't want to start a pissing contest here, that would take away from Conan's issue...however, as zammetti said...it's the cost vs. usefulness thing that concerns me. I'd rather use my own source for free than use a library for $ or only with permission unless the cost benifit was there...which in my case it is not. I have been CTO of a software company for 7 years, I think I can manage the analysis.

Also, for the record, I've heard very good things about GapiDraw from programmers I respect, so I am not ripping on it at all.
---------------------------------------------------

As to Conan's issue, I fall in the category of people who want to hear the answer, so please do post it if you find it...erm...WHEN you find it. :)
fzammetti:
I know it's a bit out of topic, but the license works like this:
(1) You send me an email asking for permission
(2) I reply and tell you that you have our permission as long as you notify me before you release any games depending on GapiDraw to function.
This is how it has been done on the 50+ or so games released so far, and this is also the way it will be done in the future. I have not yet received an email from you, but if you send one you will get a reply instantly. This is only so I know where GapiDraw is used.

MeumSimulacrum:
Please have a look at GapiDraw 2.0. You can "pthhh" as much as you want, and I will simply not even try to comment on this. I consider myself a decent coder (perhaps beaten by experts such as Thierry and warmi), and it is simply not possible to implement even 1 tenth of what's in GapiDraw in two weeks.
WM_LOSTFOCUS is not what you want, you want to capture the WM_ACTIVATE event. Please have a look at CGapiApplication to see how it should be done.

Conan:
Much have happened since the first releases of GapiDraw. If you have some questions, please feel free to contact me directly at johan.sanneblad@home.se. Currently GapiDraw is much faster than PocketFrog, and development is flourishing. I am not saying to not keep using PocketFrog, but you could for example use CGapiApplication and bridge it to PocketFrog (since it is a much more complete application wrapper than the ATL wrapper in PocketFrog). With version 2.0 it is also single threaded.

Thierry:
Actually, it is much faster than PocketFrog thanks to input from warmi. 32-bit blits, color keyed blits and alpha blends improved performance significantly on the PocketPC. Right now it is actually up to 100% faster than PocketFrog (color keyed blit with opacity). And performance does matter in the long run. On stationary PCs the performance is much more significant with the support of video surfaces.
I think the message you want is WM_LOSTFOCUS.

Wait, how do you handle messages when you're in a PF program?
sbl...relax...you are taking it to personally...no one said GapiDraw sucked or anything...I'm sure it's spiffy...and pardon my hyperbole...it happens from time to time.
Damian wrote:
I think the message you want is WM_LOSTFOCUS.

Wait, how do you handle messages when you're in a PF program?


Just like you would in any other program. If you are using the ATL framework, just add your handlers to the message map.
Conan...try WM_HIBERNATE...

Everything I can find suggests WM_ACTIVATE, but I don't think that'll cut it (which I alread said).

*continues search*
MeumSimulacrum wrote:
sbl...relax...you are taking it to personally...no one said GapiDraw sucked or anything...I'm sure it's spiffy...and pardon my hyperbole...it happens from time to time.


Indeed Johan, you are doing a great job and I didn't mean to be rude. Sorry if you misinterpreted that.

GapiDraw is definitely faster then PocketFrog right now, and I am happy to see that you find ways to make it even faster.
MeumSimulacrum:
Yeah, I guess I do take it too personal from time to time.. But don't we all... :roll: No offence meant...

Thierry:
I guess you have a point.. Perhaps I should say that the time to perform certain functions have decreased by 50% instead of stating improvements by 100%. I guess I simply have too easy to become aroused by optimizations... :D I do however need competition to push improvement to my library, and I can't give enough credits to warmi for integrating his ASM routines in the MFC demo to give me something to work for... Hopefully the improvements to GapiDraw may lead to improvements in PocketFrog as well.
Birdiestyle · 26 Apr 2003, 03:22 UTC
Wasnt the solution something to the effect of calling

SetForegroundWindow( hWnd );

on your application's window handle, when you recieve a WM_ACTIVATE event....
*group hug*

SO DO WE HAVE AN ANSWER FOR POOR CONAN OR WHAT???

I can't frickin' find it and it's now driving ME nuts...
MeumSimulacrum: If possible, can you download GapiDraw and give it a try? It only uses WM_ACTIVATE and it should work very well on both Pocket PCs and Smartphones. If it does not work on your device I would be very interested to know that so I can fix it in the current 2.0 release.
It ain't me havin' the problem. I think it was only Conan that saw a *bomb* when the battery notification popped up. Sorry to say that I have never experienced it and would only assume that my app will do the same.
MeumSimulacrum wrote:
Conan...try WM_HIBERNATE...

Everything I can find suggests WM_ACTIVATE, but I don't think that'll cut it (which I alread said).

*continues search*


It's definitely not WM_HIBERNATE. That is used to tell apps to free up all possible resources because the system is running low on memory. In practice the OS just closes apps - I don't think WM_HIBERNATE has actually been used since CE 1.0 (when devices had 4 MB total flash).

WM_ACTIVATE with WA_INACTIVE param is the normal way to determine if you lose activation. However some have reported that it doesn't work properly for all types of popups.

Your app loosing activation shouldn't cause it to crash. Any game using GAPI for direct screen access is running lower than the OS. So anything the OS does (ie move windows in front of yours, etc) is inconsequential. Sometimes they may be visible, other times your app will write over them. My hunch is that one of your handlers for a window message is causing the crash, or your game loop is getting a long frame time that it can't handle.

Dan East
yeah...I was gonna delete that post...thanks for pointing it out though...I feel so small.
sbl wrote:
Hopefully the improvements to GapiDraw may lead to improvements in PocketFrog as well.


Unlikely, as I have stopped working on PocketFrog 2-3 months ago and don't have the intention of resuming it.
I've been nominated, by virtue of no one else wanting the job, to further develop PocketFrog. This is only relevant with regard to the comment about GapiDraw improvements helping PF. I certainly intend to use whatever resources I can to improve the library, and learning something from other libraries is certainly included. I'm hoping others contribute expertise since I'm frankly not the best one floating around these parts, I think others could do a better job than I, and if I can serve as more of a point of release and integration of improvements, that would work well I think.

But this is off topic, I just thought it was worth saying in light of Therry and others' comments.
I feel like we should start a new thread...

(sbl is gonna slap me) actually, the library I wrote is more like a direct x lite ver of GAPI. I have some pretty slick code for doing alpha and chroma-key blts. Don't know what Frog looks like, but if you want any help let me know.
Just like direct x eh? GapiDraw is allready set up like direct x and is optimised for many of the popular devices.

As for the license, heck I think its entirely fair. No contracts, no money, just a simple "hey Im using your lib". If I ever create a library, it would be very fun to see what people make with it, and I believe this is why SBL has the license.
Dill, I dig it man...really...I think I came off like I was bashing GapiDraw...and I really don't want to get a rep for that at all.

I have a great deal of respect for people who actually FINISH a product and put it out there for people to see.

I don't doubt at all that GapiDraw is phat with a capital P, and I think I may very well take up sbl's invite to check it out.

In the end, I guess I was trying to say this:
I write code on the PPC for the intellectual fun of it. In general I trust my own code over anyone else's, 'cause I like to know EXACTLY what is going on...I'm just like that. But, then, I do use DirectX on the PC, so I guess there is no small hypocracy in what I said.

I wrote my code really just to see if I could do it well, and now that I have it I am inclined to use it. But, if I were going to do a 3D app, I think I'd go with something from, say, Dan East than to try to recreate the wheel from scratch.
Yeh, I understand MeumSimulacrum.

I used to think the same way, I had started creating my own sort of library similar to direct X's functions for the pocket pc, but then I saw GapiDraw. Honestly I would have never had the time to impliment everything he has. Ive come to realize more and more that you just can't do everything on your own, but sometimes it is worth the learning experience.
I think if I was really doing a game for the PPC that I was relying on for income, and I had it all scoped out, and it wasn't a hobby, I'd have to look seriously at one of the major libraries to do it. Then again, when I started off with the PPC, GAPI didn't even exist yet.

Hey, did we ever get an answer on the battery thing?
Conan · 27 Apr 2003, 08:17 UTC — GapiDraw License
SBL wrote
(1) You send me an email asking for permission
(2) I reply and tell you that you have our permission as long as you notify me before you release any games depending on GapiDraw to function.


I think it's clear that it's not possible for a programmer to develop a GapiDraw game and then find that it cannot be released because permission is withheld. This was my concern a long time ago. I could not afford to gamble on getting permission but as I understand it now I would not be refused so long as I give the appropriate notification.

A question, has permission ever been refused for a title based on GapiDraw?
All requests to use GapiDraw have been granted. I really like DillRye's description as a "Hey, I'm using your lib"-license. :) This is exactly how it was meant, and how I somewhat failed to describe it in the EULA. But hey, I'm a researcher not a lawyer (!).