From d5ddbba31a89e454ed2bd0318c92624b729ea284 Mon Sep 17 00:00:00 2001 From: "dougt%meer.net" Date: Wed, 25 May 2005 16:03:27 +0000 Subject: [PATCH] Cleans up EnumChildWindows implementation. Implements IsIconic correctly. Breaks EnumThreadWindows. I stubbed out printf all together. I think that there is a bug in EVC's varargs which crash us. Fixes up ExtTextOut to correctly calculate length. Not part of normal build --- build/wince/shunt/include/mozce_defs.h | 15 ++- build/wince/shunt/include/mozce_shunt.h | 3 + build/wince/shunt/stdio.cpp | 26 +---- build/wince/shunt/win32.cpp | 127 ++++-------------------- build/wince/shunt/win32A.cpp | 6 +- 5 files changed, 41 insertions(+), 136 deletions(-) diff --git a/build/wince/shunt/include/mozce_defs.h b/build/wince/shunt/include/mozce_defs.h index 7fcfeee33492..65b3b2367f8c 100755 --- a/build/wince/shunt/include/mozce_defs.h +++ b/build/wince/shunt/include/mozce_defs.h @@ -37,7 +37,7 @@ #ifndef MOZCE_DEFS #define MOZCE_DEFS -#define USE_NC_LOGGING 1 +//#define USE_NC_LOGGING 1 #define NOMINMAX @@ -284,4 +284,17 @@ typedef struct _BLENDFUNCTION #define AC_SRC_OVER 0 + +#ifndef SM_CYVTHUMB +#define SM_CYVTHUMB 9 +#endif + +#ifndef SM_CXHTHUMB +#define SM_CXHTHUMB 10 +#endif + +#ifndef DFCS_SCROLLSIZEGRIP +#define DFCS_SCROLLSIZEGRIP 0x0008 +#endif + #endif diff --git a/build/wince/shunt/include/mozce_shunt.h b/build/wince/shunt/include/mozce_shunt.h index a907b3d70114..d931f9a2dcc0 100755 --- a/build/wince/shunt/include/mozce_shunt.h +++ b/build/wince/shunt/include/mozce_shunt.h @@ -689,6 +689,9 @@ // We use a method named CreateEvent. We do not want to map // CreateEvent to CreateEventA +#ifdef CreateEvent +#undef CreateEvent +#endif #define CreateEvent CreateEvent #ifdef CreateEventA diff --git a/build/wince/shunt/stdio.cpp b/build/wince/shunt/stdio.cpp index 7febdaf760dc..542339a616f6 100755 --- a/build/wince/shunt/stdio.cpp +++ b/build/wince/shunt/stdio.cpp @@ -144,31 +144,7 @@ MOZCE_SHUNT_API char* mozce_getcwd(char* buff, size_t size) MOZCE_SHUNT_API int mozce_printf(const char * format, ...) { - // DONT CALL IN PRINTF MOZCE_PRECHECK - - va_list argp; - va_start(argp, format); - - char buffer[1024]; - int result = _snprintf(buffer, 1023, format, argp); - - if (result<=0) - return result; - -#ifdef USE_NC_LOGGING - nclograw(buffer, strlen(buffer)); -#endif - - unsigned short wBuffer[1024]; - - if(0 != a2w_buffer(buffer, -1, wBuffer, sizeof(wBuffer) / sizeof(unsigned short))) - { - OutputDebugString(wBuffer); - } - - va_end(argp); - - return result; + return 0; } diff --git a/build/wince/shunt/win32.cpp b/build/wince/shunt/win32.cpp index 7308a90c8566..3a836866df2b 100755 --- a/build/wince/shunt/win32.cpp +++ b/build/wince/shunt/win32.cpp @@ -529,48 +529,23 @@ MOZCE_SHUNT_API BOOL mozce_FlashWindow(HWND inWnd, BOOL inInvert) } -#define ECW_SIZEBY 0x100 -typedef struct __struct_ECWWindows +typedef struct ECWWindows { - DWORD mCount; - DWORD mCapacity; - HWND* mArray; -} -ECWWindows; + LPARAM params; + WNDENUMPROC func; + HWND parent; +} ECWWindows; -static BOOL ECWHelper(HWND inParent, ECWWindows* inChildren, BOOL inRecurse) +static BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam) { - BOOL retval = TRUE; + ECWWindows *myParams = (ECWWindows*) lParam; - HWND child = GetWindow(inParent, GW_CHILD); - while(NULL != child && FALSE != retval) + if (IsChild(myParams->parent, hwnd)) { - if(inChildren->mCount >= inChildren->mCapacity) - { - void* moved = realloc(inChildren->mArray, sizeof(HWND) * (ECW_SIZEBY + inChildren->mCapacity)); - if(NULL != moved) - { - inChildren->mCapacity += ECW_SIZEBY; - inChildren->mArray = (HWND*)moved; - } - else - { - retval = FALSE; - break; - } - } - - inChildren->mArray[inChildren->mCount] = child; - inChildren->mCount++; - if(FALSE != inRecurse) - { - retval = ECWHelper(child, inChildren, inRecurse); - } - - child = GetWindow(child, GW_HWNDNEXT); + return myParams->func(hwnd, myParams->params); } - return retval; + return TRUE; } MOZCE_SHUNT_API BOOL mozce_EnumChildWindows(HWND inParent, WNDENUMPROC inFunc, LPARAM inParam) @@ -581,43 +556,12 @@ MOZCE_SHUNT_API BOOL mozce_EnumChildWindows(HWND inParent, WNDENUMPROC inFunc, L mozce_printf("mozce_EnumChildWindows called\n"); #endif - BOOL retval = FALSE; + ECWWindows myParams; + myParams.params = inParam; + myParams.func = inFunc; + myParams.parent = inParent; - if(NULL != inFunc) - { - if(NULL == inParent) - { - inParent = GetDesktopWindow(); - } - - ECWWindows children; - memset(&children, 0, sizeof(children)); - children.mArray = (HWND*)malloc(sizeof(HWND) * ECW_SIZEBY); - if(NULL != children.mArray) - { - children.mCapacity = ECW_SIZEBY; - - BOOL helperRes = ECWHelper(inParent, &children, TRUE); - if(FALSE != helperRes) - { - DWORD loop = 0; - for(loop = 0; loop < children.mCount; loop++) - { - if(IsWindow(children.mArray[loop])) // validate - { - if(FALSE == inFunc(children.mArray[loop], inParam)) - { - break; - } - } - } - } - - free(children.mArray); - } - } - - return retval; + return EnumWindows(MyEnumWindowsProc, (LPARAM) &myParams); } @@ -626,41 +570,9 @@ MOZCE_SHUNT_API BOOL mozce_EnumThreadWindows(DWORD inThreadID, WNDENUMPROC inFun MOZCE_PRECHECK #ifdef DEBUG - mozce_printf("mozce_EnumThreadWindows called\n"); + mozce_printf("-- mozce_EnumThreadWindows called\n"); #endif - - BOOL retval = FALSE; - - if(NULL != inFunc) - { - ECWWindows children; - memset(&children, 0, sizeof(children)); - children.mArray = (HWND*)malloc(sizeof(HWND) * ECW_SIZEBY); - if(NULL != children.mArray) - { - children.mCapacity = ECW_SIZEBY; - - BOOL helperRes = ECWHelper(GetDesktopWindow(), &children, FALSE); - if(FALSE != helperRes) - { - DWORD loop = 0; - for(loop = 0; loop < children.mCount; loop++) - { - if(IsWindow(children.mArray[loop]) && inThreadID == GetWindowThreadProcessId(children.mArray[loop], NULL)) // validate - { - if(FALSE == inFunc(children.mArray[loop], inParam)) - { - break; - } - } - } - } - - free(children.mArray); - } - } - - return retval; + return FALSE; // Stop Enumerating } @@ -669,13 +581,10 @@ MOZCE_SHUNT_API BOOL mozce_IsIconic(HWND inWnd) MOZCE_PRECHECK #ifdef DEBUG - mozce_printf("-- mozce_IsIconic called\n"); + mozce_printf("mozce_IsIconic called\n"); #endif BOOL retval = FALSE; - - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return retval; } diff --git a/build/wince/shunt/win32A.cpp b/build/wince/shunt/win32A.cpp index be3586b2240b..916fc3d5eb2f 100755 --- a/build/wince/shunt/win32A.cpp +++ b/build/wince/shunt/win32A.cpp @@ -660,6 +660,9 @@ MOZCE_SHUNT_API BOOL mozce_ExtTextOutA(HDC inDC, int inX, int inY, UINT inOption #endif BOOL retval = false; + + if (inCount == -1) + inCount = strlen(inString); int wLen = 0; LPTSTR wStr = a2w_malloc(inString, inCount, &wLen); @@ -667,7 +670,6 @@ MOZCE_SHUNT_API BOOL mozce_ExtTextOutA(HDC inDC, int inX, int inY, UINT inOption if(NULL != wStr) { retval = ExtTextOutW(inDC, inX, inY, inOptions, inRect, wStr, wLen, inDx); - free(wStr); wStr = NULL; } @@ -1238,6 +1240,8 @@ MOZCE_SHUNT_API ATOM mozce_RegisterClassA(CONST WNDCLASSA *lpwc) LPTSTR wClassName = a2w_malloc(lpwc->lpszClassName, -1, NULL); memcpy(&wcW, lpwc, sizeof(WNDCLASSA)); + + wcW.lpszMenuName = NULL; wcW.lpszClassName = wClassName; return RegisterClassW(&wcW);