[COMCTL32] Sync with Wine Staging 3.3. CORE-14434

This commit is contained in:
Giannis Adamopoulos 2018-04-04 16:39:21 +03:00 committed by David Quintana
parent aba6ce5b84
commit b3fb8555bf
46 changed files with 12993 additions and 1255 deletions

View file

@ -16,19 +16,25 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTE
*
* This code was audited for completeness against the documented features
* of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
*
* Unless otherwise noted, we believe this code to be complete, as per
* the specification mentioned above.
* If you discover missing features, or bugs, please note them below.
*
*/
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(updown);
@ -83,7 +89,6 @@ typedef struct
#define TIMER_AUTOPRESS 3
#define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
/* id used for SetWindowSubclass */
#define BUDDY_SUBCLASSID 1
@ -269,7 +274,7 @@ static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
/* we have a regular window, so will get the text */
/* note that a zero-length string is a legitimate value for 'txt',
* and ought to result in a successful conversion to '0'. */
if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0)
if (GetWindowTextW(infoPtr->Buddy, txt, ARRAY_SIZE(txt)) < 0)
return FALSE;
sep = UPDOWN_GetThousandSep();
@ -322,7 +327,7 @@ static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
/* Do thousands separation if necessary */
if ((infoPtr->Base == 10) && !(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) {
WCHAR tmp[COUNT_OF(txt)], *src = tmp, *dst = txt;
WCHAR tmp[ARRAY_SIZE(txt)], *src = tmp, *dst = txt;
WCHAR sep = UPDOWN_GetThousandSep();
int start = len % 3;
@ -338,7 +343,7 @@ static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
}
/* if nothing changed exit earlier */
GetWindowTextW(infoPtr->Buddy, txt_old, sizeof(txt_old)/sizeof(WCHAR));
GetWindowTextW(infoPtr->Buddy, txt_old, ARRAY_SIZE(txt_old));
if (lstrcmpiW(txt_old, txt) == 0) return FALSE;
return SetWindowTextW(infoPtr->Buddy, txt);
@ -577,14 +582,22 @@ UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
switch(uMsg)
{
case WM_KEYDOWN:
UPDOWN_KeyPressed(infoPtr, (int)wParam);
if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
break;
if (infoPtr)
{
UPDOWN_KeyPressed(infoPtr, (int)wParam);
if (wParam == VK_UP || wParam == VK_DOWN)
return 0;
}
break;
case WM_MOUSEWHEEL:
UPDOWN_MouseWheel(infoPtr, (int)wParam);
break;
if (infoPtr)
UPDOWN_MouseWheel(infoPtr, (int)wParam);
break;
case WM_NCDESTROY:
RemoveWindowSubclass(hwnd, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID);
break;
default:
break;
}
@ -592,6 +605,11 @@ UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
static void UPDOWN_ResetSubclass (UPDOWN_INFO *infoPtr)
{
SetWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID, 0);
}
/***********************************************************************
* UPDOWN_SetBuddy
*
@ -613,9 +631,8 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
old_buddy = infoPtr->Buddy;
/* there is already a buddy assigned */
if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
BUDDY_SUBCLASSID);
UPDOWN_ResetSubclass (infoPtr);
if (!IsWindow(bud)) bud = NULL;
/* Store buddy window handle */
@ -624,7 +641,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
if(bud) {
/* Store buddy window class type */
infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) {
if (GetClassNameW(bud, buddyClass, ARRAY_SIZE(buddyClass))) {
if (lstrcmpiW(buddyClass, WC_EDITW) == 0)
infoPtr->BuddyType = BUDDY_TYPE_EDIT;
else if (lstrcmpiW(buddyClass, WC_LISTBOXW) == 0)
@ -893,7 +910,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
{
CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
infoPtr = Alloc (sizeof(UPDOWN_INFO));
infoPtr = heap_alloc_zero(sizeof(*infoPtr));
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
/* initialize the info struct */
@ -926,12 +943,9 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
break;
case WM_DESTROY:
Free (infoPtr->AccelVect);
if (infoPtr->Buddy)
RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
BUDDY_SUBCLASSID);
Free (infoPtr);
heap_free (infoPtr->AccelVect);
UPDOWN_ResetSubclass (infoPtr);
heap_free (infoPtr);
SetWindowLongPtrW (hwnd, 0, 0);
theme = GetWindowTheme (hwnd);
CloseThemeData (theme);
@ -1056,13 +1070,13 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
TRACE("UDM_SETACCEL\n");
if(infoPtr->AccelVect) {
Free (infoPtr->AccelVect);
heap_free (infoPtr->AccelVect);
infoPtr->AccelCount = 0;
infoPtr->AccelVect = 0;
}
if(wParam==0) return TRUE;
infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
if(infoPtr->AccelVect == 0) return FALSE;
infoPtr->AccelVect = heap_alloc(wParam*sizeof(UDACCEL));
if(!infoPtr->AccelVect) return FALSE;
memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
infoPtr->AccelCount = wParam;