Click here to Skip to main content
6,822,123 members and growing! (17,711 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate

Need a flashlight for your PocketPC?

By MichaelCoder

This is an article on how to make a flashlight out of your PocketPC
C#, WinMobile (PocketPC-2002), .NETCF, .NET, Win2003VS.NET2003, Dev
Posted:18 Apr 2004
Views:52,929
Bookmarked:10 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
27 votes for this article.
Popularity: 3.43 Rating: 2.40 out of 5
17 votes, 63.0%
1
2 votes, 7.4%
2
3 votes, 11.1%
3
4 votes, 14.8%
4
1 vote, 3.7%
5

Introduction

This is one of the simplest applications ever created. It just sets the entire screen to white and you can use it as a flashlight. This application was inspired by my brother's boss. His boss had at one time had a program that turned the screen completely white so that it could be used as a flashlight. I decided that this would be a good starting point for some PocketPC apps.

Background

This implementation was surprisingly tricky. Since the .NET Compact Framework does not have all of the functionality of the full .NET Framework, I had to work around a few things. First, I had planned to draw the images using pictureBox1.CreateGraphics(), but that gave a "not supported" error. So, I just cheated and made a regular windows application and just saved the image to file. Now the application just loads a picture instead of drawing it. Next, I had to figure out how to adjust the backlight. I still have not figured out how to do that. So, once again, I cheated and just set the back color to a grey scale based on where you pressed on the scale. Last, I found that picture boxes had no click event. This is the only one where I didn't cheat. I loaded the images into the picture boxes, but then on the form's graphics control I did (form graphics).DrawImage(pictureBox1.Image, 0, 0). Past that, it was pretty easy to make. I purposely put the close button on the opposite side so that you did not close it on accident. You'll also notice that I have a timer that just runs once. I found that this is the best way that I came up with to configure the controls once the form is viewable.

Using the code

Really, there should be no reason that this code would need to be altered in any way. That doesn't mean that you shouldn't. This has only one class and it was created by Visual Studio. Really, there isn't anything special about it. This does have one special function to truncate the decimal.

private int Trunc(double d) 
 // used to take the int value without the decimal place

{
  string i = d.ToString().Split(((string)(".")).ToCharArray())[0]; 
   // splits the double vaule at the decimal and only takes the first part

  return int.Parse(i); // converts the string to and int

}

To use this you just call it by saying Trunc(3.14159). This function would return 3.

Points of Interest

The main thing I learned from this application is that it is not as easy as you think to capture click events from a picture box. Otherwise, this is just a warm-up application.

History

There is no history for this app. It has one version. The end.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

MichaelCoder


Member

Location: United States United States

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • Windows Mobile, iPhone, Android - Marketplace Comparison
    Detailed comparison between Windows Mobile Marketplace, Apple's iPhone AppStore and Android Market from developer point of view.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 12 of 12 (Total in Forum: 12) (Refresh)FirstPrevNext
Generalbacklight PinmemberEmbex7:03 21 Nov '07  
Generalso there is no way to draw image on picturebox? Pinmemberraybristol7:54 14 Aug '05  
GeneralRe: so there is no way to draw image on picturebox? PinmemberSimon McKenzie13:48 5 Mar '08  
GeneralRe: trunc function ?? PinmemberErik_Egsgard5:09 22 Jun '04  
GeneralAhh at last - a use for the Pocket PC ! PinsussBob100013:57 20 Apr '04  
GeneralIs it serious ? PinmemberBenoitM23:29 19 Apr '04  
GeneralRe: Is it serious ? PinmemberMichaelCoder10:58 20 Apr '04  
Generaltrunc function ?? Pinmembersriramsinga10:01 19 Apr '04  
GeneralRe: trunc function ?? PinmemberMichaelCoder11:01 20 Apr '04  
Generalipaq sdk Pinmembersriramsinga9:57 19 Apr '04  
GeneralRe: ipaq sdk PinmemberMichaelCoder11:02 20 Apr '04  
GeneralRe: ipaq sdk Pinmemberjkutsor2:41 21 Apr '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 18 Apr 2004
Editor: Smitha Vijayan
Copyright 2004 by MichaelCoder
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project