Ariane Soft PPL2 Pocket Programming DataMite
  #1  
Old 08-24-2010, 09:16 AM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default WM6 bringing program back to live

Hi again, maybe NickNack is reading my post in this quite forum Other help is welcome.

I have written a program using the game api skeletton which starts other mobile programs like the callendar or the claculator. Everything works fine.

However on my PDA it is not possible to bring back my application after I closed the external application (windows mobile 6). Even within the taskmanager it is not possible to bring back my ppl.program to life.

Here is the basic game skelleton. I have added some code from this forum to bring it back. However it does not work

Can someone help to bring back the focus.

Many thanks in advance. I know this is a beginners problem.

Here is the basic code:

************************************************** ******

// Simple Game API demo written by Alain Deschenes (c) 2004

#include "GameAPI.ppl"

#declareapi GetDesktopWindow apidll GetDesktopWindow 0 1

func mainproc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;

case (Msg$)

WM_CLOSE: // Window is closed
ShutGameAPI(hWnd$);

WM_KEYDOWN:
g_KeyEvent(wParam$, True);

WM_KEYUP:
g_KeyEvent(wParam$, False);

end;

return (ok$);

end;

func GameProc(hWnd$, Msg$, wParam$, lParam$)
case (Msg$)
WM_PAINT:
g_clear(0);
RenderSprites;

WM_TIMER:
if (g_key.vkA$)
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;

if (g_key.vkUp$)
minMate$ = GetDesktopWindow();
SetForegroundWindow(minMate$);
end;

end;
return (true);
end;

func WinMain
last_hwnd$=FindWindow({GAPIClass},"SCLPP");
if (last_hwnd$ <> NULL)
SetForegroundWindow( last_hwnd$ );
return (false);
end;

// Create new form needed for the GameAPI.
h$ = newform({GAPI}, {GAPIClass}, &mainproc);
// Show the form on screen.
ShowWindow(h$, SW_SHOW);

// Activate FPS counter at the bottom of the screen.
ShowFPS(true, G_RGB(255, 255, 255));
// Initialize the GameAPI in form h$ with no DrawProc.
InitGameAPIEx(h$, &GameProc, 240, 400, false, 5, 60);

return (true);
end;

*******************************************
Reply With Quote
  #2  
Old 08-24-2010, 03:26 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

hi,
minimized windows don't get wm_keydown messages, because they don't have the focus (kinda logic ). you must use functions like getasynckeystate to get key strokes even with a minimized program. now we need a way to call it regulary: settimer comes into place.
here is a complete example, hope it is what you are looking for:
PHP Code:
#include "GameAPI.ppl"

func mainproc(hWnd$, Msg$, wParam$, lParam$)
  
ok$ = true;

  case (
Msg$)

    
WM_CLOSE:
        
Killtimer(h$,999);
      
ShutGameAPI(hWnd$);

    
WM_KEYDOWN:
      
g_KeyEvent(wParam$, True);

    
WM_KEYUP:
      
g_KeyEvent(wParam$, False);

    if(
wparam$==keys.vkDown$)
        
ShowWindow(h$, SW_MINIMIZE);
        
settimer(h$,999,20,null);
    
end;

    
WM_TIMER:
        if(
wparam$==999)
            if(
getasynckeystate(keys.vkUp$))
                
ShowWindow(h$, SW_SHOW);
                
Killtimer(h$,999);
            
end;
        
end;

  
end;
  return (
ok$);
end;

func GameProc(hWnd$, Msg$, wParam$, lParam$)
  case (
Msg$)
    
WM_PAINT:
      
g_clear(0);
      
RenderSprites;
      
    
WM_TIMER:
      if (
g_key.vkA$)
        
PostMessage(hWnd$, WM_CLOSE00);
      
end;
    
  
end;
  return (
true);
end;

func WinMain
    
global(h$,k$);
  
h$ = newform({GAPI}, {GAPIClass}, &mainproc);

  
ShowFPS(trueG_RGB(255255255));
  
InitGameAPIEx(h$, &GameProc240320false560);
 
showwindow(h$,SW_SHOW);

  return (
true);
end
beware the double presence of wm_timer, one is for our window (in mainproc) and the other for the gameapi (gameproc).
Reply With Quote
  #3  
Old 08-24-2010, 07:30 PM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default

Thanks Nicknack,

I appreciate your support within this forum.

I tried your code on my HTC HD2 PDA but nothing really changed. If I start an other program and try to bring back this PPL program via Task Manager nothing happens. The PPL program is still running but could not be brought to front. As far as I remember this was not a problem in WM5.

I developed a launcher which worked fine on WM5 but this program is worthless if it could not be reactivated after closing an other program.

Bests

Michael
Reply With Quote
  #4  
Old 08-25-2010, 05:27 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

have you already tried the other functions like g_suspend/g_resume or showwindow? occurs this strange behavior only with ppl or with other progs/games too?
Reply With Quote
  #5  
Old 08-25-2010, 06:45 PM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default

Thanks Nicknack,

I don't know whether this is a strange behavior. This happens only with programs using the gapi skelleton.

Does anyone have a simple gapi code example which works fine under windows mobile version 6?

There must be a way of bringing PPL.programs back to screen after a call cames in or an other win mobile program was terminated. With the above described code example the program is still there, however does not update the screen. The only way stoping it is to kill it in the task manager.

Thanks

Michael-
Reply With Quote
  #6  
Old 08-26-2010, 06:19 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

my code runs fine here on winmo 6 classic. how do you execute the code, with editor or as standalone executable? have you tried g_resume already?
Reply With Quote
  #7  
Old 08-27-2010, 07:47 AM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Talking

I start the program with the stand alone executable. I can't believe that you can bring it back to screen and properly working after you have started for example the calculator. If I do so by doubble clicking on the gapi program in the task manager nothing happens. It seems that gapi has the focus again, however it does not update the screen. The task manager is still visible. Thats the problem. The only chance to get out of this is to restart the task manager and kill the program.

I have not tried g_resume so far. Don't blame me but I don't know where to insert it in the above shown example. Can you give me a hint please? (I am a stupid beginner, you know. But I become better and better each day ).

Cheers Michael
Reply With Quote
  #8  
Old 08-28-2010, 08:57 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

PHP Code:
#include "GameAPI.ppl"

#declare getdesktopwindow apidll getdesktopwindow 0 1

func mainproc(hWnd$, Msg$, wParam$, lParam$)
  
ok$ = true;

  case (
Msg$)

    
WM_CLOSE:
    
Killtimer(h$,999);
      
ShutGameAPI(hWnd$);

    
WM_KEYDOWN:
      
g_KeyEvent(wParam$, True);

    
WM_KEYUP:
      
g_KeyEvent(wParam$, False);
  if(
wparam$==keys.vkDown$)
    
g_suspend;
    
ShowWindow(h$, SW_MINIMIZE);
    
//setforegroundwindow(getdesktopwindow);
    
settimer(h$,999,20,null);
  
end;

  
WM_TIMER:
    if(
wparam$==999)
      if(
getasynckeystate(keys.vkUp$))
        
ShowWindow(h$, SW_SHOW);
        
//setforegroundwindow(h$);
        
g_resume;
        
Killtimer(h$,999);
      
end;
    
end;

  
end;
  return (
ok$);
end;

func GameProc(hWnd$, Msg$, wParam$, lParam$)
  case (
Msg$)
    
WM_PAINT:
      
g_clear(g_rgb(random(255),random(255),random(255)));
      
RenderSprites;

    
WM_TIMER:
      if (
g_key.vkA$)
        
PostMessage(hWnd$, WM_CLOSE00);
      
end;

  
end;
  return (
true);
end;

func WinMain
  
global(h$,k$);
  
h$ = newform({GAPI}, {GAPIClass}, &mainproc);


  
ShowFPS(trueG_RGB(255255255));
  
InitGameAPIEx(h$, &GameProc240320false560);
  
showwindow(h$,SW_SHOW);
  
//setforegroundwindow(h$);

  
return (true);
end
does it work on pc? press down to minimize and up to get the window back
I have included a color flashing so you can see if gapi is running and some commented alternatives you can test out.
Reply With Quote
  #9  
Old 08-30-2010, 01:02 PM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default

Thanks Nicknack,

tried your code and nothing really helped. Changing to an other WM application hangs the program. Maybe this is only an issue of WM 6.5 of my HTC HD2.

Thanks so far

Michael
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd