Development Samples

From OptiWiki

Jump to: navigation, search

This page lists some development samples (either C++ or C#) for commonly faced programming challenges. Most of these samples are not dependent on one of the Opticon devices.

All samples have been found on the Internet, and remain intellectual property of their respective owners. The samples are provided as is.

Contents

Related pages

Windows Mobile Development
H 16 - H 19 SDK

Enable WLAN, GSM or Bluetooth from source

Description

With the C++ or C# code from the attached forum, it is possible to enable or disable one of the radio devices from source on Windows Mobile 6 devices.

Link/Destination

Forum

Applies to

Windows Mobile 6


Security settings

Description

On Windows Mobile 6, you can turn off security settings, which then will allow you to install and run unsigned applications without questions.
You can alternate these setings by using a CPF file, which is a "compiled XML" file.
The result of this CPF file will be available in the Messaging application of the PDA.

Link/Destination

Security Off CPF sample

Applies to

Windows Mobile 6


Using basic functionalities of Windows Mobile

Description

This sample uses the P/Invoke method to use standard API calls from the CoreDLL.dll. This includes samples to retrieve the battery status, controlling the software keyboard (SIP), preform a soft reset, making phone calls from source, capturing hardware buttons, and much more.

Link/Destination

A full functional sample

Applies to

Windows Mobile 5
Windows Mobile 6


Capturing phonebuttons

Description

To capture phonebuttons, the following code can be used.

    public enum KeysHardware : int
    {
      Answer = 0x72,
      Hangup = 0x73
    }   
 
    public enum KeyModifiers
    {
        None = 0,
        Alt = 1,
        Control = 2,
        Shift = 4,
        Windows = 8,
        Modkeyup = 0x1000,
    }
 
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern bool RegisterHotKey(
    		IntPtr hWnd, // handle to window 
                int id, // hot key identifier 
                KeyModifiers Modifiers, // key-modifier options 
                int key //virtual-key code 
    );
 
    [DllImport("coredll.dll")]
        private static extern uint UnregisterFunc1(KeyModifiers modifiers, int keyID);
 
    public static void RegisterRecordKey(IntPtr hWnd) //handle to MessageWindow
    {
        UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.Answer);
        RegisterHotKey(hWnd, (int)KeysHardware.Answer, KeyModifiers.None, (int)KeysHardware.Answer);
        UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.Hangup);
        RegisterHotKey(hWnd, (int)KeysHardware.Hangup, KeyModifiers.None, (int)KeysHardware.Hangup);
    }
Link/Destination
N/A
Applies to

Windows Mobile 5
Windows Mobile 6


Create a GPRS connection and connect with it

Description

This sample shows how to set-up a GPRS connection from source using C#, and connect to it.

Link/Destination

GPRS sample

Applies to

Windows Mobile 5
Windows Mobile 6


Discover Bluetooth devices from source

Description

Using the Bluetooth discovery sample, you can discover Bluetooth devices from source.
Make sure that the Bluetooth hardware is turned ON before discovering!

Link/Destination

Bluetooth discovery sample

Applies to

Windows Mobile 5
Windows Mobile 6


Signature Capturing

Description

This sample will allow you to capture a customers signature.

Link/Destination

Microsoft Signature Sample

Applies to

Windows Mobile 5
Windows Mobile 6


Integrating GPS

Description

There are 2 ways to integrate GPS in your application.
1. You can open a serial port (serial port info H19), and do the calculations yourself in your application (or use a component like OpenNetCF.IO.Serial to do this)
2. You can use the GPSApi.dll to do this. Microsoft provides a sample application together with the Compact Framework which shows you how to do that. This demo is most likely located in Windows Mobile 6 SDK on your Windowx XP system.
Please note that the "External GPS" utility should be configured, or at least, the Hardware tab of this utility should be configured.

Link/Destination

OpenNetCF.IO.Serial
C:\Program Files\Windows Mobile 6 SDK\Samples\Smartphone\CS\GPS

Applies to

Windows Mobile 5
Windows Mobile 6


Sending an SMS message

Description

An SMS message can be sent from source using the SmsMessage class from Microsoft.
This class can be used in the following way:

  public void SendSMS(string _to, string _msg)
  {
      Microsoft.WindowsMobile.PocketOutlook.SmsMessage _message = new Microsoft.WindowsMobile.PocketOutlook.SmsMessage();        
 
      try    
      {    
          _message.To.Add(new Microsoft.WindowsMobile.PocketOutlook.Recipient(+31612345678);//phone nbr     
          _message.Body = “Your message body“;
          _message.Send();    
      }  
      catch (SmsException) 
      {
          MessageBox.Show("SMS SEND FAILED", "SMS FAIL");
          return;
      } 
      MessageBox.Show("SMS SENT", "SMS SUCCESS");
  }
Link/Destination

SmsMessage class

Applies to

Windows Mobile 5
Windows Mobile 6


Handling connections from source

Description

This should be done using the Connection Manager. This is a standard part of the Windows Mobile OS, and can handle GPRS and WLAN connections according to cost effectiveness.
The Microsoft API can be used with C++, but a C# wrapper is created by OpenNETCF, available in the Connectionmanager.cs file.

Link/Destination

Pages explaining the Connection manager
Smart Device Framework

Applies to

Windows Mobile 5
Windows Mobile 6


GSM signal strength

Description

This can be done using the TAPI of Microsoft. In particular the LINEDEVSTATUS is important.

Link/Destination

TAPI
LINEDEVSTATUS

Applies to

Windows Mobile 5
Windows Mobile 6


Retrieve a Unique ID of the PDA

Description

Please check on the MSDN site for a way to do this on Windows Mobile devices.
You will be able to determine the brand of the device, as well as a unique ID of it. The unique ID is determined by the hardware.

Link/Destination

Unique ID example
Get device ID sample source

Applies to

Windows Mobile 5
Windows Mobile 6


Kiosk mode

Description

Using this sample application, you can see how to create a kiosk mode application of your own application. Everything is hidden, even the start button.
Note that you will need to put your application in a folder, which is executed upon booting yout device.

Link/Destination

Kiosk mode application

Applies to

Windows Mobile 5
Windows Mobile 6
Windows CE 5.0


Retrieving the current installed Compact Framework

Description

Using this source, you can retrieve the currently installed nd used Compact Framework on the PDA running this application.

Link/Destination

Compact Framework Application

Applies to

Windows Mobile 5
Windows Mobile 6
Windows CE 5.0


P/Invoking

Description

Using Visual Studio 2005 or beyond, interthread communication needs to be preformed using delegates.
For example, if you want to put text, retrieved in an eventhandler, in a textbox (2 seperate threads), you will need this.
This example uses the SerialPort class (Compact Framework 2 or beyond) to show this.

Link/Destination

Invoke sample

Applies to

Windows Mobile 5
Windows Mobile 6
Windows CE 5.0


Enable GPRS on a PHL 7000

Description

This sample shows you how to enable the GPRS radio on the PHL 7000

Link/Destination

Enable GPRS on PHL 7000

Applies to

Windows CE 5.0


Capturing function keys on a PHL 7000

Description

This code shows how to capture the Fx keys in source on a PHL 7000.
Note that the function keys should be disabled in Start > Settings > Control Center > Fn-Key Settings.

Link/Destination

F-key retrieving

Applies to

Windows CE 5.0


Views
Personal tools