This site is no longer active and is available for archival purposes only. Registration and login is disabled.

screen coordinate problem in EasyCE


screen coordinate problem in EasyCE

Postby sillycat » Dec 6, 2001 @ 3:05am

i have a little difficulty here, hope you can give me some idea to overcome it.<br> <br>i created a fullscreen game, when playing, if there are some background application trying to pop up a message (eg: the low battery status, or some poutlook reminder), the fullscreen game will start flickering (seems like it is drawing those popup windows at background). and the worst part came in, the clickypos() will be shifted by around 60 pixels down. that means, if i point at (0,60) it will be returning as (0,120). <br> <br>was wondering if anyone facing the similiar problem, and if you could provide some hints to overcome this :)<br>
sillycat
 


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 11, 2001 @ 9:16pm

Capture WM_ACTIVATE messages, and check LOWORD(wParam) to see if you are gaining or losing focus. <br><br>If losing focus:<br>Release the screen buffer if you have it, and don't draw to the display until you regain activation.<br>Go into a "pause" type state, making sure you Sleep to give plenty of processing time to the app that is now active. Process Windows messages while in that paused loop, so you can handle the WM_ACTIVATE you get when you regain activation. Stay in the loop until your "paused" flag is not set.<br><br>If gaining focus:<br>Call SHFullScreen to hide the taskbar, then resize your main window to the dimensions of the display. Clear the paused flag.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 11, 2001 @ 9:19pm

After posting I noticed that in the subject you state you are using EasyCE. The problem could lie within Jacco's library. I don't know if it is supposed to handle those type of messages or not. My guess is that after regaining activation you are not sizing your window to take over the whole display, which would throw off your mouse coordinates because your window would no longer cover the taskbar at the top and app bar at the bottom.<br><br>dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 11, 2001 @ 10:52pm

here's what happened in EasyCE when trapping the messages:<br>      case WM_ENABLE:<br>      case WM_ACTIVATE:<br>      case WM_CREATE:<br>      case WM_SETTINGCHANGE:<br>            taskbar( false );<br>            break;<br><br>with your explanation, i guess we can tweak it as<br><br>      case WM_ENABLE:<br>      case WM_ACTIVATE:<br>            if (lParam) {<br>                  // set pause flag;<br>                  break;<br>            }<br>      case WM_CREATE:<br>      case WM_SETTINGCHANGE:<br>            taskbar( false );<br>            break;<br><br>what do you think of this?<br>
sillycat
 


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 11, 2001 @ 11:15pm

The problem with that first example is that WM_ACTIVATE is used for both activation / deactivation. Unlike WM_SETFOCUS and WM_KILLFOCUS, where the two events are broken into two different messages, MS lumped activation into one. So something like this would be a step in the right direction:<br>[fixed]<br>case WM_ACTIVATE: <br>  if ( LOWORD( wParam ) !=WM_INACTIVE ) { <br>    // clear pause flag<br>    bPaused=false;<br>    // hide taskbar<br>    taskbar( false ); <br>  } else {<br>    // set pause flag<br>    bPaused=true;<br>    // show taskbar<br>    taskbar ( true );<br>  }<br>  break;<br>case WM_ENABLE: <br>case WM_CREATE: <br>case WM_SETTINGCHANGE: <br>  taskbar( false ); <br>  break; <br>[/fixed]<br><br>Now I don't know what all is done in taskbar(), but it needs to call SHFullScreen, and size the main window to the display size.<br>In your main game loop you would check each cycle for bPaused. While bPaused, you do a message pump and sleep.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 11, 2001 @ 11:20pm

here's what happened in EasyCE when trapping the messages:<br>      case WM_ENABLE:<br>      case WM_ACTIVATE:<br>      case WM_CREATE:<br>      case WM_SETTINGCHANGE:<br>            taskbar( false );<br>            break;<br><br>with your explanation, i guess we can tweak it as<br><br>      case WM_ENABLE:<br>      case WM_ACTIVATE:<br>            if (LOWORD(wParam) == INACTIVE ) {<br>                  // set pause flag;<br>                  break;<br>            }<br>            if (LOWORD(wParam) == ACTIVE )<br>                  // clear pause flag;<br><br>      case WM_CREATE:<br>      case WM_SETTINGCHANGE:<br>            taskbar( false );<br>            break;<br><br>is this going to work? :)<br>
sillycat
 


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 11, 2001 @ 11:21pm

sorry i made some mistake in the previous reply and i reposted this.
sillycat
 


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 11, 2001 @ 11:25pm

Close. See my example. Your WM_ENABLE case is falling through to WM_ACTIVATE, so the same code is being executed for both. Then don't forget to break before WM_CREATE, because taskbar( false ) is being executed for all cases as well.<br><br>BTW, you ought to register to these boards. You can then edit and delete your posts, and the board notifies you when threads and forums have new posts that you haven't read yet.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 11, 2001 @ 11:29pm

i've just got myself registered. :)
i'm a cat, i type on four feet.
sillycat
pm Member
 
Posts: 14
Joined: Dec 11, 2001 @ 11:29pm


i can't get back control to the game

Postby sillycat » Dec 12, 2001 @ 9:06pm

now that i've added in the code, the screen no longer flashes in and out while something popup in the background. but a new problem appear :p i can't get back control to the game... <br><br>i added a pause flag as suggested, and in my update() code i just check if it  is paused then perform a sleep(100) and return without drawing the game screen.<br><br>what else could be the problem??
i'm a cat, i type on four feet.
sillycat
pm Member
 
Posts: 14
Joined: Dec 11, 2001 @ 11:29pm


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 13, 2001 @ 12:53am

You have to pump Windows messages somewhere along the way. I don't know where EasyCE does this, but you may be bypassing it. You can just do a loop as follows in your update code:<br><br>[fixed]<br>while ( paused ) {<br>  MSG msg;<br>  while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE ) ) {<br>     TranslateMessage ( &msg );<br>     DispatchMessage ( &msg );<br>  }<br>  Sleep( 100 );<br>}<br>[/fixed]<br><br>Dan East<br><br>Last modification: Dan East - 12/12/01 at 21:53:18
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 13, 2001 @ 4:07am

i see, so the PeekMessage will be able to capture messages sent to the program and invoke WndProc ?
i'm a cat, i type on four feet.
sillycat
pm Member
 
Posts: 14
Joined: Dec 11, 2001 @ 11:29pm


Re: screen coordinate problem in EasyCE

Postby Phantom » Dec 13, 2001 @ 5:45am

I've added the modifications that Dan suggested to EasyCE. I hope to release 1.6 soon, it will have the faster line code (fixed point, works like a charm), the 3800 code, faster rotation code for the iPaq framebuffer, and of course this message stuff (I REALLY suck at windows coding).
Give me some good data and
I will give you the world
User avatar
Phantom
pm Insider
 
Posts: 913
Joined: Feb 21, 2001 @ 8:14am
Location: Houten, Netherlands


Re: screen coordinate problem in EasyCE

Postby Dan East » Dec 13, 2001 @ 9:18am

sillycat, PeekMessage checks to see if there are any messages pending. TranslateMessage converts keyboard accelerator codes to their true commands (which is seldom useful for CE, probably never for games). The DispatchMessage does the real work, and eventually calls your WndProc. I use PeekMessage is used instead of GetMessage so we only stay in that inner loop as long as messages are pending. Windows messages usually come in bursts, so you're better off processing all that are available at once, then sleep or do whatever else (your game processing, for example). GetMessage is like PeekMessage, but it will block and wait until a message arrives.<br><br>Jacco, Windows programming is a pain, because you have to do things the way MS wants you to. :( <br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: screen coordinate problem in EasyCE

Postby sillycat » Dec 13, 2001 @ 10:32am

great, it works now. windows return control to my game. but again, new problem arise :p again, pls help me... :D<br><br>now that the mouse coordinate is correct, and windows do return control to my game, but i found that if there's a popup window at the background when i click on the game screen it will be clicking the popup! that's terrible :p it freezes the lower half of my game screen. when i tap on that part of the screen the background popup will flicker, then upon game screen update it is covered.<br><br>seems like me sucks even more at windows programming  :p<br>
i'm a cat, i type on four feet.
sillycat
pm Member
 
Posts: 14
Joined: Dec 11, 2001 @ 11:29pm


Next

Return to Phantom's Forum


Sort


Forum Description

Discuss any of Phantom's projects here (Operation Nutcracker, etc.)

Moderators:

sponge, RICoder, Phantom

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum