Jump to content

Recommended Posts

Posted

I am creating a little countdown timer as my first app, but can't find anywhere how to either sound one of the bult in alarms or at least bring up an alert window.

Basically I need some good way of letting the phone know the alarm has gone off.

Guest Peter Foot
Posted

You can use the PlaySound API function to simply play one of the Alarm*.wav files. Or you can use the built in CE Notification APIs CeSetUserNotification etc to create a timed notification which can be displayed as a standard dialog, sound, led, vibrate or a combination. In the SDK documentation look for CeSetUserNotification or "Notify Functions" which contains this and related API calls.

If you are programming with .NETCF then OpenNETCF has a managed wrapper around these in the OpenNETCF.Win32.Notify namespace

(www.opennetcf.org/sdf/)

Peter

Posted

Peter, any ideas on the easiest way to keep such an alarm program alive in the background as the Smartphone has a habt of closing applications when it needs more memory :?

Posted

OK, I dont understand how to use CeSetUserNotification. I have been looking at it on MSDN and been looking for example around, but can;t really find anything.

Guest Peter Foot
Posted
Peter, any ideas on the easiest way to keep such an alarm program alive in the background as the Smartphone has a habt of closing applications when it needs more memory :?

When windows tries to close your app if it's a .NETCF app it triggers the Closing event for your main form. So all you have to do is handle the closing event and set the Cancel to true e.g.

bool wanttoclose = false;




private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)


{


       if(wanttoclose)


	{


  e.Cancel = true;


	}




}

Then just remember to set wanttoclose to true when you actually want to quit the application.

Peter

Posted

So you're checking if wanttoclose is true and if it is then "e.Cancel = true" stops it closing? Surely we'd want this to happen if wanttoclose was false?

Thanks for this Peter, i've been hunting for something like this for a while!

Posted
private void frmAlarm_Closing(object sender, System.ComponentModel.CancelEventArgs e)  

{  

if(wantToClose)  

{  

 e.Cancel = true;  

}  

}

My form is called frmAlarm.cs, this doesn't seem to work atm :? By running a task amanger I can still close the program and running something memory heavy like BetaPlayer also causes the program to close ^_^

Posted

SO no help here for the struggling developer looking for an example of CeSetUserNotification???

Guest Peter Foot
Posted
So you're checking if wanttoclose is true and if it is then "e.Cancel = true" stops it closing? Surely we'd want this to happen if wanttoclose was false?  

Thanks for this Peter, i've been hunting for something like this for a while!

Oops, yes I typed it straight into the forum while changing the names from a piece of code I've been using, therefore the flag should be "keepalive" or similar.

Guest Peter Foot
Posted
OK, I dont understand how to use CeSetUserNotification.  I have been looking at it on MSDN and been looking for example around, but can;t really find anything.

Take a look at the OpenNETCF.Win32.Notify namespace as this wraps all the notification APIs. It's part of the smart device framework (www.opennetcf.org/sdf/) and you can even view all the source online (C#) - www.opennetcf.org/sourcebrowse/

HTH

Peter

  • 4 weeks later...
Posted

Peter, bac to the closing problem, when i use Binrays' Task Manager Free Memory Program which closes all applications running the Closing method is not hit (I have tested this using breaks which are not hit when the program is closed). Any ideas?

EDIT: The Application.Exit() method does not seem to call the Closing method either, very odd!?

Posted

Problem solved, very odd, just started working!? Thanks Peter!!

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.