顯示具有 WinCE 標籤的文章。 顯示所有文章
顯示具有 WinCE 標籤的文章。 顯示所有文章

2011年10月11日 星期二

.NET CF ListView 不支援 OnClick

.NET CF 中的 ListView 不支援 ItemOnClick, OnClick 等事件,
所以若要取得使用者點選的 ListViewItem 得用 SelectedIndexChanged 來替代,
範例如下:

private void lv_SelectedIndexChanged(object sender, EventArgs e)
{
    if (lv.SelectedIndices.Count > 0)
    {
        ListViewItem lvi = lv.Items[lv.SelectedIndices[0]];
        MessageBox.Show(lvi.SubItems[0].Text);
    }
}

2011年9月25日 星期日

Web Service:無法序列化 DataTable。DataTable 名稱未設定。

使用 .NET Framework 2.0 的 Web Service 傳遞 DataTable 參數,
Runtime 會報錯:無法序列化 DataTable。DataTable 名稱未設定。


只要設定以下屬性即可解決:

dtMyTable.TableName = "MyTableName";

2011年8月19日 星期五

C# get a string from C++ DLL

C++ DLL :



TCHAR g_awcMessage[] = L"Hello中文";
char g_aszMessage[] = "Hello中文";

extern "C" __declspec(dllexport) TCHAR* __stdcall GetHelloL()
{
return g_awcMessage;
}

extern "C" __declspec(dllexport) CHAR* __stdcall GetHello()
{
return g_aszMessage;
}

extern "C" __declspec(dllexport) int __stdcall GetInt()
{
return 100;
}



C# P/Invoke:

[DllImport("gpDll.dll")]
public static extern IntPtr GetHello();

[DllImport("gpDll.dll")]
public static extern IntPtr GetHelloL();

[DllImport("gpDll.dll")]
public static extern int GetInt();


private void button1_Click(object sender, EventArgs e)
{
// Not support in CF
//Marshal.PtrToStringAnsi
//Marshal.PtrToStringAuto

// Multibytes 會變成亂碼
string str = Marshal.PtrToStringUni(GetHello());

// Wide Character 顯示正常
string strL = Marshal.PtrToStringUni(GetHelloL());

int n = GetInt();
}

WinCE/Mobile Control Panel Item List

VC++
BOOL ShowControlPanelApplet(int id)
{
TCHAR szParams[32];
SHELLEXECUTEINFO execinfo = {0};
memset(&execinfo, 0, sizeof(execinfo));
execinfo.cbSize=sizeof(execinfo);
execinfo.lpFile=TEXT(“\\windows\\ctlpnl.exe”);
execinfo.lpVerb=TEXT(“open”);


// Id value determines which control applet will be launched
// For e.g. 23 for bluetooth applet
wsprintf(szParams, L”cplmain.cpl,%d”, id);
execinfo.lpParameters = szParams;
BOOL bRet=ShellExecuteEx(&execinfo);
return bRet;
}

VC#
Process.Start(@"\windows\ctlpnl.exe", "cplmain.cpl,19");

Windows Mobile

1 Password
2 Owner Information
3 Power
4 Memory
5 About
6 Brightness
7 Screen
8 Input
9 Sounds & Notifications
10 Remove Programs
11 Menus
12 Buttons
13 Today
14
15 Beam
16 Clocks & Alarms
17 Configure Network Adapters
18 Regional Settings
19 Connections
20
21
22 Manage Certificates
23 Bluetooth
24 Error Reporting
25 GPS Settings
26
27 USB to PC

Windows CE

1 PC Connection - 35#”ctlpnl.exe” \Windows\cplmain.cpl,0
2 Dialing - 35#”ctlpnl.exe” \Windows\cplmain.cpl,1
3 Keyboard - 35#”ctlpnl.exe” \Windows\cplmain.cpl,2
4 Password - 35#”ctlpnl.exe” \Windows\cplmain.cpl,3
5 Owner - 35#”ctlpnl.exe” \Windows\cplmain.cpl,4
6 Power - 35#”ctlpnl.exe” \Windows\cplmain.cpl,5
7 System - 35#”ctlpnl.exe” \Windows\cplmain.cpl,6
8 Display - 35#”ctlpnl.exe” \Windows\cplmain.cpl,7
9 Mouse - 35#”ctlpnl.exe” \Windows\cplmain.cpl,8
10 Stylus - 35#”ctlpnl.exe” \Windows\cplmain.cpl,9
11 Volume & sounds - 35#”ctlpnl.exe” \Windows\cplmain.cpl,10
12 Input Panel - 35#”ctlpnl.exe” \Windows\cplmain.cpl,11
13 Remove Programs - 35#”ctlpnl.exe” \Windows\cplmain.cpl,12
14 Date/Time - 35#”ctlpnl.exe” \Windows\cplmain.cpl,13
15 Certificates - 35#”ctlpnl.exe” \Windows\cplmain.cpl,14
16 Accessibility - 35#”ctlpnl.exe” \Windows\cplmain.cpl,15

SendKeys for .NETCF

Because System.Windows.Forms SendKeys does not support in .NETCF,
So I have to implement it thru APIs,

here is the solutions: SendInput, keybd_event, PostKeybdMessage and SendMessage



[DllImport("coredll.dll", SetLastError = true)]
//[DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

[DllImport("coredll", SetLastError = true)]
//[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string _ClassName, string _WindowName);

[DllImport("coredll", SetLastError = true)]
//[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);

public static void SendIt()
{
IntPtr ip = FindWindow("notepad", null);


SetForegroundWindow(ip);

const int KEYEVENTF_KEYUP = 0x2;

const int KEYEVENTF_KEYDOWN = 0x0;

byte VK_TAB = 0x0D;

keybd_event(VK_TAB, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
}




Symbolic
constant name
Value
(hexadecimal)
Keyboard (or mouse) equivalent
VK_LBUTTON01Left mouse button
VK_RBUTTON02Right mouse button
VK_CANCEL03Control-break processing
VK_MBUTTON04Middle mouse button (three-button mouse)
VK_BACK08BACKSPACE key
VK_TAB09TAB key
VK_CLEAR0CCLEAR key
VK_RETURN0DENTER key
VK_SHIFT10SHIFT key
VK_CONTROL11CTRL key
VK_MENU12ALT key
VK_PAUSE13PAUSE key
VK_CAPITAL14CAPS LOCK key
VK_ESCAPE1BESC key
VK_SPACE20SPACEBAR
VK_PRIOR21PAGE UP key
VK_NEXT22PAGE DOWN key
VK_END23END key
VK_HOME24HOME key
VK_LEFT25LEFT ARROW key
VK_UP26UP ARROW key
VK_RIGHT27RIGHT ARROW key
VK_DOWN28DOWN ARROW key
VK_SELECT29SELECT key
VK_PRINT2APRINT key
VK_EXECUTE2BEXECUTE key
VK_SNAPSHOT2CPRINT SCREEN key
VK_INSERT2DINS key
VK_DELETE2EDEL key
VK_HELP2FHELP key
300 key
311 key
322 key
333 key
344 key
355 key
366 key
377 key
388 key
399 key
41A key
42B key
43C key
44D key
45E key
46F key
47G key
48H key
49I key
4AJ key
4BK key
4CL key
4DM key
4EN key
4FO key
50P key
51Q key
52R key
53S key
54T key
55U key
56V key
57W key
58X key
59Y key
5AZ key
VK_NUMPAD060Numeric keypad 0 key
VK_NUMPAD161Numeric keypad 1 key
VK_NUMPAD262Numeric keypad 2 key
VK_NUMPAD363Numeric keypad 3 key
VK_NUMPAD464Numeric keypad 4 key
VK_NUMPAD565Numeric keypad 5 key
VK_NUMPAD666Numeric keypad 6 key
VK_NUMPAD767Numeric keypad 7 key
VK_NUMPAD868Numeric keypad 8 key
VK_NUMPAD969Numeric keypad 9 key
VK_SEPARATOR6CSeparator key
VK_SUBTRACT6DSubtract key
VK_DECIMAL6EDecimal key
VK_DIVIDE6FDivide key
VK_F170F1 key
VK_F271F2 key
VK_F372F3 key
VK_F473F4 key
VK_F574F5 key
VK_F675F6 key
VK_F776F7 key
VK_F877F8 key
VK_F978F9 key
VK_F1079F10 key
VK_F117AF11 key
VK_F127BF12 key
VK_F137CF13 key
VK_F147DF14 key
VK_F157EF15 key
VK_F167FF16 key
VK_F1780HF17 key
VK_F1881HF18 key
VK_F1982HF19 key
VK_F2083HF20 key
VK_F2184HF21 key
VK_F2285HF22 key
VK_F2386HF23 key
VK_F2487HF24 key
VK_NUMLOCK90NUM LOCK key
VK_SCROLL91SCROLL LOCK key
VK_LSHIFTA0Left SHIFT key
VK_RSHIFTA1Right SHIFT key
VK_LCONTROLA2Left CONTROL key
VK_RCONTROLA3Right CONTROL key
VK_LMENUA4Left MENU key
VK_RMENUA5Right MENU key
VK_PLAYFAPlay key
VK_ZOOMFBZoom key

Emulate mouse action in .NETCF

There are some ways to do it,



SendMessage API:
//Find topmost window of another application
IntPtr parentWnd = WIN32.Window.FindWindow(null, "Form2");

//Find the button
IntPtr hButton = WIN32.Window.FindWindowEx(parentWnd, IntPtr.Zero, null, "Target");

//Click the target button
WIN32.Window.SendMessage(hButton, Window.WM.WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
WIN32.Window.SendMessage(hButton, Window.WM.WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);


mouse_event API:

[DllImport("coredll.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);

public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
void ClickIt()
{
SetCursorPos(400, 10);
mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);
}

2008年10月7日 星期二

How to increase volume of application sound on pocket pc

Q:
My application plays different sounds in different conditions..all working fine. Only trouble is when incoming call alert is there , sound produced by device (RINGTONE) is loud but sound played by application (parallely to Ringtone) is very low. Does ringtone have a higher priority for the device speaker than our application sound.

A:
Yes in effect the ringtone sound has a higher gain setting than your application audio when an incoming phone call is detected. This is implemented by the concept of "classes".

Further details including details of how you can alter this behaviour can be found in the Windows CE Multimedia Team Blog in an article titled "The WaveDev2 GainClass Implementation" available at
http://blogs.msdn.com/medmedia/archive/2007/01/04/the-wavedev2-gainclass-implementation.aspx

2008年4月18日 星期五

Gold Stock

免費看盤軟體 Gold Stock

只要您擁有智慧型裝置(PDA, SmartPhone),
而且是屬於 WM5.0(含)之後的作業系統,
那麼您就可以免費使用 Gold Stock 看盤軟體。

目前釋出的版本為 v.01,
之後會不斷的更新 GoldStock 的功能,
目前包含的功能有:

1. 觀看大盤走勢
2. 自選股價查詢
3. 個股技術分析

立即下載 Gold Stock
載點暫時移除,原因請參考此討論


版權聲明:Gold Stock 軟體之版權屬於 Gold Project 所有,其軟體運行所使用之網路資源,為該網路資源提供者所有。