IntroductionNow the PDA and other mobile gadgets are probably already in every tenth. That is, many. And since there is a PDA, it means that we also need programs for them). It is also very often a situation that the necessary program for the handheld is, but it is paid). And it may also be that you yourself want to add some features for your favorite device. This will help you a little review. We will write in C # in the popularly beloved Visual Studio 2005. You will see that writing such applications is a snap and the process is not very different from writing programs for regular x86 computers.
Emulator Pocket PC.First of all, it’s clear that our applications will be written for the Windows Mobile platform. To make the life of a developer easier and more enjoyable, we included a Microsoft mobile brainchild emulator in VS2005). With it, the development of applications for mobile platforms is almost the same as for conventional x86-computers. Visual Studio 2005 includes the Windows Mobile 2003 emulator, so our applications will be written for it. Windows Mobile versions 5.0 and 6.0 have already been released, so there may be slight differences when programming for modern PDAs.
In general, we proceed). This is what the Pocket PC emulator window looks like:
Create an application for PDAs.')
Launch Visual Studio and create a new application.
An application form will appear before us. Because in Windows Mobile there is no possibility to arbitrarily set the window size, the form of the application occupies the entire screen of the PDA.
Place the components on the form:
- 2 Label'a
- 2 TextBox
- 1 MainMenu
- 1 PictureBox
We give them new names, and in the end we get this form:
Now add some functions to our application. What is interesting, you can do the handling of pressing all the keys). And they will all work inside the application). If you do not process any keys, they will simply have default values. To change the function of the keys, simply click on one of the buttons on the PDA on the form, and you can immediately write your own keystroke processing code.
Here is an example of code for programming buttons on a PDA:
private void Form1_KeyDown ( object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
// Rocker Up
// Up
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
// Rocker Down
// Down
}
if ((e.KeyCode == System.Windows.Forms.Keys.Left))
{
// Left
}
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
// Right
}
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
// Enter
}
} * This source code was highlighted with Source Code Highlighter .
On the button “Enter” you can register a type code like this:
// Handle the event by pressing the "Enter" key
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
MessageBox.Show ( "This is the message text" , "Message!" );
} * This source code was highlighted with Source Code Highlighter .
Next, let's compile the application by pressing the F5 key. When you press the Enter button, we will see a message.
Now use the previously added buttons. Double clicking on the form on the PushMe! Button, let's start writing a handler for it:
private void button1_Click ( object sender, EventArgs e)
{
// If the correct data is entered in the field, then we will display a message about it
if (LoginTb.Text == "Login" && PasswordTb.Text == "Password" )
{
MessageBox.Show ( “You are successfully authorized!” , “Information” );
}
// Otherwise
else
{
MessageBox.Show ( “Wrong login / password !!!” , “Information” );
}
}
* This source code was highlighted with Source Code Highlighter .Compile the program again and look at the results. Now, if we enter into the Login and Password columns the very words “Login” and “Password” (both words with a capital letter), we will receive the message “You are successfully logged in.” After compilation, an exe file appears in the Debug folder.
ConclusionAs you have seen, programming applications for ordinary computers and for PDAs is no different. In the case of PDAs, it may even be easier because the requirements for such applications are less serious than for applications for “regular” Windows. In general, it is worth a try, especially if you have your handheld :). Then you can write any application, how much imagination and strength you have enough :)
Enjoy!Source:
downloadOriginal article - http://coderszone.info/305-programmirovanie-dlja-mobilnykh.html