(1)非全屏窗口
A) this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(235, 152);
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(3, 80);
this.MinimizeBox = false;
B) using OpenNETCF.Win32;
IntPtr hWnd = Win32Window.FindWindow(null, this.Text);
int style = Win32Window.GetWindowLong(hWnd, GWL.STYLE);
style |= (int)(WS.BORDER & WS.CAPTION & WS.MINIMIZEBOX & WS.GROUP);
Win32Window.SetWindowLong(hWnd, GWL.STYLE, style);
Win32Window.SetWindowPos(hWnd, HWND.TOP, 25, 60, this.Width - 100, this.Height - 100, SWP.SHOWWINDOW);
(2)发短信
使用OpenNetCF这个工具包 可以到这里下载 http://www.opennetcf.org ,目前版本1.4
安装后,引用OpenNETCF.Phone
然后代码如下:
....
using OpenNETCF.Phone;
using OpenNETCF.Phone.Sms;
private void menuItem2_Click(object sender, System.EventArgs e)
{
if((textBox1.Text.Trim().Length>0) &&(textBox1.Text.Trim().Length>0))
{
Sms mySMS=new Sms(SmsMode.Send);
SmsAddress myAddr=new SmsAddress();
myAddr.Address="+86"+textBox1.Text;
myAddr.Type=AddressType.International;
int smsHandle=mySMS.SendMessage(myAddr,textBox2.Text);
}
}
要特别注意的是,当你的系统中有Framework 1.1以及FrameWork 2.0时,加载dll会有问题,解决方法如下
将/Program Files/Microsoft Visual Studio .NET 2003/CompactFrameworkSDK/v1.0.5000/Windows CE/中的OpenNETCF.Phone.dll拷贝到项目目录中,并在项目中包含此dll文件即可。
(3)改变输入法:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace SmartPhone
{
/// <summary>
///InputModeEditor的摘要说明。
/// </summary>
public class InputModeEditor
{
public InputModeEditor()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[DllImport("coredll.dll", EntryPoint="GetCapture")]
private static extern IntPtr GetCapture();
[DllImport("coredll.dll", EntryPoint="GetWindow")]
private static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
[DllImport("coredll.dll", EntryPoint="SendMessage")]
private static extern uint SendMessage(IntPtr hWnd, uint msg, uint wParam, uint lParam);
const uint EM_SETINPUTMODE = 0x00DE;
const int GW_CHILD = 5;
const uint LB_SETCURSEL = 0x0186;
public static void SetInputMode(Control ctrl, InputMode mode)
{
ctrl.Capture = true;
IntPtr h = GetCapture();
ctrl.Capture = false;
IntPtr hEditbox = GetWindow(h, GW_CHILD);
SendMessage(hEditbox, EM_SETINPUTMODE, 0, (uint)mode);
}
public enum InputMode
{
EIM_SPELL = 0,//英文
EIM_AMBIG = 1,//拼音
EIM_NUMBERS = 2,//数字
EIM_TEXT = 3,//拼音
}
}
}
(4)arcgis mobile坐标变换
double lat = 40.123456;
double lon = 116.123456;
ESRI.ArcGIS.Mobile.Geometries.Coordinate coordinate = this.map1.MapCache.SpatialReference.Wgs84ToMobileGeometry(lon, lat);
//定位
this.map.CenterAt(coordinate);
(5)点C1到C2的距离
int intDist = c1.Distance(c2);
double distance = mapCache1.SpatialReference.MobileToServerDistance(intDist, EsriSpatialUnits.Meters); MessageBox.Show("Distance between features is " + distance + " meters.")