Previous projects I have developed using gapidraw were partly based on the samples that come with the SDK and were using MFC based classes to create the main application window. In an attempt to make things somehow cleaner in my latest project I decided to ditch the mfc classes like CMainFrame and such and create my own window manually using plain CreateWindowEx. However, now when my application exits, the right lower part of the today screen isn't properly restored. You have to manually click on the button that is on the right of the lower bar of the today screen to have it redrawn correctly again. So I guess I'm doing something wrong when exiting my app, but I'm not sure what. What I'm doing when exiting the app is this:
first, delete the CGapiDisplay object
then, call SHFullScreen(m_hWndMain , SHFS_SHOWSTARTICON |SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON);
then, call DestroyWindow (m_hWndMain)
So, what am I missing here?
What exactly do you have on your Today screen, and what isn't being redrawn? Are you talking about the command bar across the bottom, or is it some Today plug-in, or are you using one of the Today replacements? I often have trouble with the Today bar redisplaying itself correctly, even when exiting from non-GAPI apps. I think that a lot of plug-ins have redrawing issues.
One option would be to, before exiting your app, find the current window and force it to redraw by sending a WM_PAINT message targeted at the entire surface--it's possible that the system isn't doing that for some reason.
-Ionitor
I have nothing special on my today screen, just the standard stuff that is there on an Ipaq running Windows CE 2002. It is part of the commandbar that isn't being redrawn properly. I'm not sure what you call it but is the button with which you can make the keyboard appear on the display to enter text that isn't being restored properly.
Well, that is the SIPButton, as in SHFS_SHOWSIPBUTTON. I can't get the problem to duplicate on my EM-500, even when I rewrite my code to make it as similar as possible to what you describe. The only other possibility I can think of at the moment is that your code has a buffer overflow or something else that is changing the memory of the button image. If you haven't already done so, strip your code down to the most basic number of lines you can that will still produce the problem you're having. Also, try the code on another device, to see if it's a particular issue with your device or all of them.
-Ionitor
I had draw corruption happening to the top of the screen when I laid out my message pump a certain way. This may be the same issue you're having.
Basically, to fix it I wrote the message pump to run through my render routines/game loop before it process any messages. So like:
- Code:
while( TRUE )
{
//Process Game Loop
if( !g_bHibernate )
{
//Process Render Loop
//Draw to Screen
if( PeekMessage(&msg;, NULL, 0, 0, PM_REMOVE) )
{
if( msg.message == WM_QUIT )
{
break;
}
TranslateMessage(&msg;);
DispatchMessage(&msg;);
}
}
I think what's happening is a message is getting through in the wrong sequence to your render loop.
Hosed,
I realize that your code snippet is editted to make your point clear, but I thought I would point out to others that might use it as a sample that PeekMessage should generally be put in an inner loop to make sure that all messages are processed. That way, especially if your frame rate is particularly low, you'll process multiple button/stylus presses that occur during a single frame.
Also, your idea makes sense and brings up a good point--you should always ensure that no additional game code is run after a window is destroyed.
-Ionitor