Patch for fixing build issues for Windows Mobile 5.0 for WTL
=============================================================
--- AtlApp.h 2001-10-23 15:26:06.000000000 +0530
+++ AtlApp.h 2007-11-05 12:11:55.812500000 +0530
@@ -28,7 +28,7 @@


#include <limits.h>
-#if !defined(_ATL_MIN_CRT) & defined(_MT)
+#if !defined(_ATL_MIN_CRT) & defined(_MT) && !defined(_WIN32_WCE)
#include <process.h> // for _beginthreadex, _endthreadex
#endif

@@ -37,7 +37,6 @@
#pragma comment(lib, "comctl32.lib")
#endif

-#include <atlres.h>


// WTL version number
@@ -268,7 +267,9 @@
}
else if(!bRet)
{
+#if defined(_ENABLE_ATL_TRACE_ON_SUBCLASS)
ATLTRACE2(atlTraceUI, 0, _T("CMessageLoop::Run - exiting\n"));
+#endif
break; // WM_QUIT, exit message loop
}

@@ -507,7 +508,7 @@
// timed out
if(!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail
{
-#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) & defined(_ATL_FREE_THREADED)
+#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) & defined(_ATL_FREE_THREADED) & (_WIN32_WCE <= 420 )
::CoSuspendClassObjects();
if(!m_bActivity && m_nLockCnt == 0)
#endif
@@ -527,7 +528,7 @@
if(m_hEventShutdown == NULL)
return false;
DWORD dwThreadID;
-#if !defined(_ATL_MIN_CRT) & defined(_MT)
+#if !defined(_ATL_MIN_CRT) & defined(_MT) && !defined(_WIN32_WCE)
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID);
#else
HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
@@ -542,7 +543,7 @@
{
CServerAppModule* p = (CServerAppModule*)pv;
p->MonitorShutdown();
-#if !defined(_ATL_MIN_CRT) & defined(_MT)
+#if !defined(_ATL_MIN_CRT) & defined(_MT) && !defined(_WIN32_WCE)
_endthreadex(0);
#endif
return 0;



--- AtlDlgs.h 2001-10-23 15:26:24.000000000 +0530
+++ AtlDlgs.h 2007-11-05 12:12:42.375000000 +0530
@@ -126,7 +126,11 @@
#endif
m_ofn.lpstrFilter = lpszFilter;
m_ofn.hInstance = _Module.GetResourceInstance();
+#ifndef _WIN32_WCE
m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc;
+#else
+ m_ofn.lpfnHook = NULL;
+#endif
m_ofn.hwndOwner = hWndParent;

// setup initial file name
@@ -141,7 +145,9 @@
INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
{
ATLASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
+#ifndef WINCE
ATLASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook
+#endif //WINCE

ATLASSERT(m_ofn.Flags & OFN_EXPLORER);

@@ -365,8 +371,13 @@
m_bi.pszDisplayName = m_szFolderDisplayName;
m_bi.lpszTitle = lpstrTitle;
#else
+# ifdef _ARM_
m_bi.pszDisplayName = (LPSTR)m_szFolderDisplayName;
m_bi.lpszTitle = (LPSTR)lpstrTitle;
+# else
+ m_bi.pszDisplayName = (LPTSTR)m_szFolderDisplayName;
+ m_bi.lpszTitle = (LPTSTR)lpstrTitle;
+# endif
#endif
m_bi.ulFlags = uFlags;
m_bi.lpfn = BrowseCallbackProc;



--- AtlMisc.h 2001-10-23 15:26:58.000000000 +0530
+++ AtlMisc.h 2007-11-05 12:13:25.562500000 +0530
@@ -3224,7 +3224,8 @@
inline bool _IsDBCSTrailByte(LPCTSTR lpstr, int nChar)
{
#ifndef _UNICODE
- for(int i = nChar; i > 0; i--)
+ int i;
+ for(i = nChar; i > 0; i--)
{
if(!::IsDBCSLeadByte(lpstr[i - 1]))
break;
@@ -3286,7 +3287,8 @@
// handle just ellipsis
if((cchLen < (cchMidEllipsis + cchEndEllipsis)))
{
- for(int i = 0; i < cchLen - 1; i++)
+ int i;
+ for(i = 0; i < cchLen - 1; i++)
lpstrOut[i] = ((i + 1) == cchMidEllipsis) ? chSlash : _T('.');
lpstrOut[i] = 0;
return true;