I love this Add-in (SlickEdit Gadgets)

I think SlickEdit's ruler is very nice tool in Visual Studio.
The ruler indicates where your cursor is, and you haven't looking for it. 8)

Here is a screenshot from my IDE:


Of course it is FREE Add-in :) Thanks for the developers! ;)

Download page:
http://www.slickedit.com/content/view/441

WM 6.1 Emulator Images

Where can you download WM 6.1 Emulator Images?
here

New emulator image resolutions:

  • Windows Mobile 6.1 Standard
    DPI: 131 - Resolution: 320 x 320 pixels
    DPI: 131 - Resolution: 400 x 240 pixels
    DPI: 131 - Resolution: 440 x 240 pixels

  • Windows Mobile 6.1 Professional
    DPI: 96 - Resolution: 240 x 400 pixels
    DPI: 192 - Resolution 480 x 800 pixels

A screen capture tool for WM 5

Here is a very simple source code to make a screenshot on your device:

http://www.codeproject.com/KB/mobile/screen_capture_pocketPC.aspx




Remote device control

You must know this application, if you are a WM developer.
MyMobiler is a Freeware application, and I like it! :)

Features:
  • View your mobile screen on your desktop.
  • Control your mobile by using desktop keyboard and mouse.
  • Copy/Cut/Paste text between mobile and desktop.
  • Capture mobile screen.
  • Drag and drop files to your mobile.
  • Support ActiveSync / IP Connection
  • Support Mobile Explorer (File Browse)

Special TextBox Control

When you have a Resco CustomKeyboard in your application, maybe you need a custom TextBox too, which filters the pressed key.
In my sample code, the SpecialTextBox control overrides the TextBox control, and allows only these keys:
Space, 0-9, Enter.



SpecialTextBox overrides these 3 methods:
OnKeyDown, OnKeyUp and OnKeyPress.

Here is a piece of code to see how it works:

protected override void OnKeyUp(KeyEventArgs e)

{

if (e.KeyCode == Keys.Space ||

e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9 ||

e.KeyCode == Keys.Enter)

{

base.OnKeyUp(e);

}

else

{

e.Handled = true;

}

}


When you want to import this control to your project with the source code, don't forget the DesignTimeAttributes.xmta, which allows the designer support for this control:

3 <Class Name="MyControls.SpecialTextBox">

4 <DesktopCompatible>trueDesktopCompatible>

5 <Class>



Sorce Code:
http://www.winmobile.euweb.cz/#Post06


How to: Reset the Device

There is a piece of code written in C# and VB .Net to restart your device:

http://msdn.microsoft.com/en-us/library/ms172519.aspx

Which icon sizes should I use in my application?

I find an article to answer the question: here
Summary of the article:

If you are creating a single .exe that is designed to run on all Windows Mobile devices, use an application icon with these sizes:

  • 16x16
  • 22x22
  • 32x32
  • 44x44
  • 64x64

If your .exe is only designed for "Pocket PC" devices, use an application icon with these sizes:

  • 16x16
  • 32x32
  • 64x64

If your .exe is only designed for "Smartphone" devices, use an application icon with these sizes:

  • 16x16
  • 22x22
  • 32x32
  • 44x44

I advise a FREE icon editor, which can generate all needed sizes from one picture:
http://icofx.ro/


Volume control on devices

Do you want to mute the device, or change the volume in managed code?
Then you can use the following property:

29 public enum Volumes : int

30 {

31 OFF = 0,

32 LOW = 858993459,

33 NORMAL = 1717986918,

34 MEDIUM = -1717986919,

35 HIGH = -858993460,

36 VERY_HIGH = -1

37 }

38

39 [DllImport("coredll.dll", SetLastError = true)]

40 public static extern int waveOutSetVolume(IntPtr device, int volume);

41

42 [DllImport("coredll.dll", SetLastError = true)]

43 public static extern int waveOutGetVolume(IntPtr device, ref int volume);

44

45 public static Volumes Volume

46 {

47 get

48 {

49 int v = (int)0;

50

51 waveOutGetVolume(IntPtr.Zero, ref v);

52

53 switch (v)

54 {

55

56 case (int)Volumes.OFF:

57 return Volumes.OFF;

58

59 case (int)Volumes.LOW:

60 return Volumes.LOW;

61

62 case (int)Volumes.NORMAL:

63 return Volumes.NORMAL;

64

65 case (int)Volumes.MEDIUM:

66 return Volumes.MEDIUM;

67

68 case (int)Volumes.HIGH:

69 return Volumes.HIGH;

70

71 case (int)Volumes.VERY_HIGH:

72 return Volumes.VERY_HIGH;

73

74 default:

75 return Volumes.OFF;

76 }

77 }

78 set { waveOutSetVolume(IntPtr.Zero, (int)value); }

79 }



The change will appear in 3 or 5 seconds.
So it means, it isn't a fast operation. :(

You can download the source code from:
http://www.winmobile.euweb.cz/#Post04



How to get the screen resolution

Sometimes developers need to know the resolution of device, where the application's running.


Here is the code:



using System.Windows.Forms;


int width = Screen.PrimaryScreen.Bounds.Width;

int height = Screen.PrimaryScreen.Bounds.Height;


MessageBox.Show("The device's resolution: Width = " + width + " Height = " + height);


It's very easy ;)


Cut, Copy, Paste features in a TextBox

PocketPC users like these features, and I hope you will add them to your applications.



What you need to add Cut, Copy etc. functionality to your TextBox:
- Add this reference, there is the Clipboard class.

using System.Windows.Forms;

- Add these methods:

private void CopySelectedText(TextBox aTextBox)
{
DataObject m_data = new DataObject();
m_data.SetData(DataFormats.Text, true, aTextBox.SelectedText);
Clipboard.SetDataObject(m_data);
}

private void PasteSelectedText(TextBox aTextBox)
{
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
int start = aTextBox.SelectionStart;

if (aTextBox.SelectionLength == 0)
{
aTextBox.Text = aTextBox.Text.Insert(aTextBox.SelectionStart,
Clipboard.GetDataObject().GetData(DataFormats.Text).
ToString());
}
else
{
aTextBox.Text = aTextBox.Text.Replace(aTextBox.SelectedText,
Clipboard.GetDataObject().GetData(DataFormats.Text).
ToString
());
}

aTextBox.SelectionStart = (aTextBox.Text.Length >= start) ? start : aTextBox.Text.Length;
}
}

private void RemoveSelectedText(TextBox aTextBox)
{
if (aTextBox.SelectionLength > 0)
{
int start = aTextBox.SelectionStart;

//remove selected text
aTextBox.Text = aTextBox.Text.Replace(aTextBox.SelectedText, "");

aTextBox.SelectionStart = (aTextBox.Text.Length >= start) ? start : aTextBox.Text.Length;
}
}


- Then you are ready to handle the menu items:
private void mnuCopy_Click(object sender, EventArgs e)
{
CopySelectedText(this.tbNotes);
}

private void mnuPaste_Click(object sender, EventArgs e)
{
PasteSelectedText(this.tbNotes);
}

private void mnuCut_Click(object sender, EventArgs e)
{
CopySelectedText(this.tbNotes);
RemoveSelectedText(this.tbNotes);
}

I think everybody know how to add the menu items Cut, Copy, Paste etc. into a ContextMenu. :)

You can download the source code from:
http://www.winmobile.euweb.cz/#Post03


How can I add T9 to the TextBox?

T9 input mode is the predictive text input feature on the devices. To add this feature to your TextBox use this code:

public Form1()
{
InitializeComponent();

InputModeEditor.SetInputMode(this.tbNotes, InputMode.AlphaT9);
}

To make this method available, you will need to add this references:
using Microsoft.WindowsCE.Forms;
That's all :)



Source code: http://www.winmobile.euweb.cz/#Post01
Hi Windows Mobile Developers!

Here I will put some interesting Compact Framework tricks, tips and samples.