Windows CE
Sunday, October 11, 2009
Windows Embedded CE 6.0 R3: Using Silverlight
http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/10/01/silverlight-for-embedded-tutorial.aspx
http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/10/11/silverlight-for-embedded-tutorial-step-2.aspx
http://discovertheexperience.blogspot.com/2009/09/windows-embedded-ce-60-r3-using.html
Sunday, May 10, 2009
Multiple Key detection + PXA27x + Wince 6.0
Recently i had a chance to look into a keypad problem.We are using a development board having PXA270 processor.For a single key press we were getting the proper scan code, but when multiple key were pressed, we were still getting the 1st pressed key scan code.Second Key was getting ignored.
So,I checked the xllp code for keypad.
\WINCE600\PLATFORM\COMMON\SRC\SOC\PXA27X_MS_V1\XLLP\SOURCE\xllp_keypad.c
There i found that in function XllpKeyPadConfigure , IGNORE_MULTIPLE_KEY_PRESS bit was set in keypad control register. I cleared that bit and checked the scan code.Now i was able to get some scan code when the second key was pressed,without lifting the 1st key.It means Multiple key press was not ignored now.
But still the second key scan code was not proper.The scan code we were getting was not what we were expecting.So i checked function ReadScanCodeAutomatically.
There i found a comment for the part of the code when numOfKeysPressed > 1
// these keys are the "minor keys", the ones that needs top right and bottom left of the
// cooresponding 4 keys surrounding them to trigger the correct key. Doing a binary search
// there are 5 keys, the middle key reads 0x8, the first key reads 0x2 and the last reads 0x20.
// this needs to be done for each row. This will be encorporated into a routine for the next
// upgrade of keypad.
I couldn't understand this what does this mean.But one thing was sure that the logic for determining the scan code for multikey press was not according to the PXA27x.
I rewrote the function as follows :
1: XLLP_BOOL_T ReadScanCodeAutomatically(XLLP_KEYPAD_REGS *v_pKeyPadRegs,XLLP_UINT8_T *key)
2: {
3:
4: /**
5: Check for Single Key press
6: **/
7: if(numOfKeysPressed > 1)
8: {
9: c0 = v_pKeyPadRegs->kpAutoScanMultiKeyPress0 & 0xFF;
10: c1 = ((v_pKeyPadRegs->kpAutoScanMultiKeyPress0 >> 16) & 0xFF);
11: c2 = v_pKeyPadRegs->kpAutoScanMultiKeyPress1 & 0xFF;
12: c3 = ((v_pKeyPadRegs->kpAutoScanMultiKeyPress1 >> 16) & 0xFF);
13: c4 = v_pKeyPadRegs->kpAutoScanMultiKeyPress2 & 0xFF;
14: c5 = ((v_pKeyPadRegs->kpAutoScanMultiKeyPress2 >> 16) & 0xFF);
15: c6 = v_pKeyPadRegs->kpAutoScanMultiKeyPress3 & 0xFF;
16: c7 = ((v_pKeyPadRegs->kpAutoScanMultiKeyPress3 >> 16) & 0xFF);
17:
18:
19: if(c0!=0)
20: {
21: ReadMultipleKeyScanCode(c0,0,RowBit,Col);
22: }
23: if(c1!=0)
24: {
25: ReadMultipleKeyScanCode(c1,1,RowBit,Col);
26: }
27: if(c2!=0)
28: {
29: ReadMultipleKeyScanCode(c2,2,RowBit,Col);
30: }
31: if(c3!=0)
32: {
33: ReadMultipleKeyScanCode(c3,3,RowBit,Col);
34: }
35: if(c4!=0)
36: {
37: ReadMultipleKeyScanCode(c4,4,RowBit,Col);
38: }
39: if(c5!=0)
40: {
41: ReadMultipleKeyScanCode(c5,5,RowBit,Col);
42: }
43: if(c6!=0)
44: {
45: ReadMultipleKeyScanCode(c6,6,RowBit,Col);
46: }
47: if(c7!=0)
48: {
49: ReadMultipleKeyScanCode(c7,7,RowBit,Col);
50: }
51:
52: key1 = (unsigned char) (( RowBit[0] <<>53: key2 = (unsigned char) (( RowBit[1] <<>54:
55: if(key1 == PrevKey)56: {
57: *key = key2 ;
58: }
59: else60: *key = key1 ;
61:
62: }
63: else64: *key = NO_KEY;
65:
66: retval = XLLP_TRUE;
67: }
68: NKDbgPrintfW(L"ReadScanCodeAutomatically<\r\n");69: PrevKey = *key ;
70: return(retval);71: }
72:
73: //---------------------------------------------------------------------------------------------------------------74: // Function: ReadMultipleKeyScanCode75: // Purpose: This functions reads the Multiple key pressed scan code from the KeyPad controller triggered by setting of the ASACT bit76: // in the KeyPad Control register. If there is a valid key detected then it returns the scan code.77: // Returns: success/failure.78: //---------------------------------------------------------------------------------------------------------------79: XLLP_BOOL_T ReadMultipleKeyScanCode(XLLP_UINT32_T KPASMKPRegister,XLLP_UINT32_T col, XLLP_UINT32_T RowBit[] ,XLLP_UINT32_T Col[])
80: {
81: int i = 0;82: while (i <>83: {
84: if((KPASMKPRegister & 0x01) == 0x01 )85: {
86: if(RowBit[0] == 0)87: {
88: RowBit[0] = i ;
89: Col[0] = col ;
90: }
91: else92: {
93: RowBit[1] = i ;
94: Col[1] = col ;
95: }
96: NKDbgPrintfW(L"XLLP_NEW:ReadMultipleKeyScanCode bit no %d>\r\n",i);97: }
98:
99: KPASMKPRegister = KPASMKPRegister >> 1 ;
100: i++ ;
101:
102: }
103: return(XLLP_TRUE);104: }
105:
And it worked fine. I was getting the second key scan code properly.
Note : There is a limitation in above code.It can only read two key press properly.More than 2 keys pressed simultaneously cant be recognized, for example Ctrl+Alt+Del ;) But this is not required for our project..
Sunday, April 19, 2009
Use of SHBrowseForFolder() in wince 6.0
1: TCHAR psz_result[MAX_PATH];
2: LPMALLOC p_malloc = 0; 3: LPITEMIDLIST pidl;
4: BROWSEINFO bi; 5:
6: #ifdef UNDER_CE 7: # define SHGetMalloc MySHGetMalloc
8: # define SHBrowseForFolder MySHBrowseForFolder
9: # define SHGetPathFromIDList MySHGetPathFromIDList
10:
11:
12: HMODULE ceshell_dll = LoadLibrary( _T("ceshell") );13: if( !ceshell_dll ) return;
14:
15: HRESULT (WINAPI *SHGetMalloc)(LPMALLOC *) =
16: (HRESULT (WINAPI *)(LPMALLOC *))
17: GetProcAddress( ceshell_dll, _T("SHGetMalloc") );
18: LPITEMIDLIST (WINAPI *SHBrowseForFolder)(LPBROWSEINFO) =
19: (LPITEMIDLIST (WINAPI *)(LPBROWSEINFO))
20: GetProcAddress( ceshell_dll, _T("SHBrowseForFolder") );
21: BOOL (WINAPI *SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
22: (BOOL (WINAPI *)(LPCITEMIDLIST, LPTSTR))
23: GetProcAddress( ceshell_dll, _T("SHGetPathFromIDList") );
24:
25: if( !SHGetMalloc || !SHBrowseForFolder || !SHGetPathFromIDList )
26: {
27: _tprintf( _T( "couldn't load SHBrowseForFolder API") );
28: FreeLibrary( ceshell_dll );
29: return;
30: }
31: #endif
32:
33: if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
34:
35: memset( &bi, 0, sizeof(BROWSEINFO) );36: bi.hwndOwner = NULL;
37: bi.lpszTitle = L"Select Folder to backup.";
38: bi.pszDisplayName = psz_result;
39: bi.ulFlags = BIF_EDITBOX;
40: #ifndef UNDER_CE
41: bi.ulFlags |= BIF_USENEWUI;
42: #endif 43:
44: if( (pidl = SHBrowseForFolder( &bi ) ) )
45: {
46: SHGetPathFromIDList( pidl, psz_result );
47:
48: p_malloc->Free( pidl ); 49: }
50: _tprintf( _T( "%s"),psz_result );
51: error:
52:
53:
54:
55:
56: #ifdef UNDER_CE 57: FreeLibrary( ceshell_dll );
58: #endif
Saturday, April 11, 2009
Minimize / Hide Applications on startup
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
{
dlg.ShowWindow( SW_HIDE );
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.RunModalLoop();
}
And you are done.. Integrating it with previous sample application will result in a Dialog based application starting as a trayicon, Always Minimized and will not appear in System tray. ;))
Adding System Tray Icon in Wince
- hWnd - Handle to the window that receives notification messages associated with an icon in the taskbar status area.
- hIcon - Handle to the icon to be added, modified, or deleted. If the Icon is imported to the project, handle can be obtained by calling LoadIcon API.
- uCallbackMessage - Application-defined message identifier. The system uses this identifier to send notifications to the window identified in hWnd. These notifications are sent when a mouse event occurs in the bounding rectangle of the icon, or when the icon is selected or activated with the keyboard.
2.Open the file for CTrayIconDlg, the trayicondlg.cpp file and add the following at the end of preprocessor directives