Commit 75a1f6d0 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

When setting the buddy to 0 then we must still resize the updown

control.
parent 7d22cc16
...@@ -442,98 +442,109 @@ UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -442,98 +442,109 @@ UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/*********************************************************************** /***********************************************************************
* UPDOWN_SetBuddy * UPDOWN_SetBuddy
* Tests if 'bud' is a valid window handle. If not, returns FALSE. *
* Else, sets it as a new Buddy. * Sets bud as a new Buddy.
* Then, it should subclass the buddy * Then, it should subclass the buddy
* If window has the UDS_ARROWKEYS, it subcalsses the buddy window to * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to
* process the UP/DOWN arrow keys. * process the UP/DOWN arrow keys.
* If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style
* the size/pos of the buddy and the control are adjusted accordingly. * the size/pos of the buddy and the control are adjusted accordingly.
*/ */
static BOOL UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
{ {
DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
RECT budRect; /* new coord for the buddy */ RECT budRect; /* new coord for the buddy */
int x, width; /* new x position and width for the up-down */ int x, width; /* new x position and width for the up-down */
WNDPROC baseWndProc; WNDPROC baseWndProc;
CHAR buddyClass[40]; CHAR buddyClass[40];
HWND ret;
/* Is it a valid bud? */
if(!IsWindow(bud)) return FALSE;
TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud); TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
ret = infoPtr->Buddy;
/* there is already a body assigned */ /* there is already a body assigned */
if (infoPtr->Buddy) RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); if (infoPtr->Buddy) RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
if(!IsWindow(bud))
bud = 0;
/* Store buddy window handle */ /* Store buddy window handle */
infoPtr->Buddy = bud; infoPtr->Buddy = bud;
/* keep upDown ctrl hwnd in a buddy property */ if(bud) {
SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
/* Store buddy window class type */ /* keep upDown ctrl hwnd in a buddy property */
infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN; SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
if (GetClassNameA(bud, buddyClass, COUNT_OF(buddyClass))) {
if (lstrcmpiA(buddyClass, "Edit") == 0)
infoPtr->BuddyType = BUDDY_TYPE_EDIT;
else if (lstrcmpiA(buddyClass, "Listbox") == 0)
infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
}
if(dwStyle & UDS_ARROWKEYS){ /* Store buddy window class type */
/* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
when we reset the upDown ctrl buddy to another buddy because it is not if (GetClassNameA(bud, buddyClass, COUNT_OF(buddyClass))) {
good to break the window proc chain. */ if (lstrcmpiA(buddyClass, "Edit") == 0)
if (!GetPropA(bud, BUDDY_SUPERCLASS_WNDPROC)) { infoPtr->BuddyType = BUDDY_TYPE_EDIT;
baseWndProc = (WNDPROC)SetWindowLongW(bud, GWL_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc); else if (lstrcmpiA(buddyClass, "Listbox") == 0)
SetPropA(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc); infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
} }
}
/* Get the rect of the buddy relative to its parent */ if(dwStyle & UDS_ARROWKEYS){
GetWindowRect(infoPtr->Buddy, &budRect); /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2); when we reset the upDown ctrl buddy to another buddy because it is not
good to break the window proc chain. */
/* now do the positioning */ if (!GetPropA(bud, BUDDY_SUPERCLASS_WNDPROC)) {
if (dwStyle & UDS_ALIGNLEFT) { baseWndProc = (WNDPROC)SetWindowLongW(bud, GWL_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc);
x = budRect.left; SetPropA(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc);
budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP; }
} else if (dwStyle & UDS_ALIGNRIGHT) { }
budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
x = budRect.right+DEFAULT_XSEP;
} else {
x = budRect.right+DEFAULT_XSEP;
}
/* first adjust the buddy to accomodate the up/down */ /* Get the rect of the buddy relative to its parent */
SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top, GetWindowRect(infoPtr->Buddy, &budRect);
budRect.right - budRect.left, budRect.bottom - budRect.top, MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
SWP_NOACTIVATE|SWP_NOZORDER);
/* now do the positioning */
if (dwStyle & UDS_ALIGNLEFT) {
x = budRect.left;
budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
} else if (dwStyle & UDS_ALIGNRIGHT) {
budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
x = budRect.right+DEFAULT_XSEP;
} else {
x = budRect.right+DEFAULT_XSEP;
}
/* now position the up/down */ /* first adjust the buddy to accomodate the up/down */
/* Since the UDS_ALIGN* flags were used, */ SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
/* we will pick the position and size of the window. */ budRect.right - budRect.left, budRect.bottom - budRect.top,
width = DEFAULT_WIDTH; SWP_NOACTIVATE|SWP_NOZORDER);
/* now position the up/down */
/* Since the UDS_ALIGN* flags were used, */
/* we will pick the position and size of the window. */
width = DEFAULT_WIDTH;
/*
* If the updown has a buddy border, it has to overlap with the buddy
* to look as if it is integrated with the buddy control.
* We nudge the control or change it size to overlap.
*/
if (UPDOWN_HasBuddyBorder(infoPtr)) {
if(dwStyle & UDS_ALIGNLEFT)
width += DEFAULT_BUDDYBORDER;
else
x -= DEFAULT_BUDDYBORDER;
}
/* SetWindowPos(infoPtr->Self, infoPtr->Buddy, x,
* If the updown has a buddy border, it has to overlap with the buddy budRect.top - DEFAULT_ADDTOP, width,
* to look as if it is integrated with the buddy control. budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
* We nudge the control or change it size to overlap. SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
*/ } else {
if (UPDOWN_HasBuddyBorder(infoPtr)) { RECT rect;
if(dwStyle & UDS_ALIGNLEFT) GetWindowRect(infoPtr->Self, &rect);
width += DEFAULT_BUDDYBORDER; MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
else SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
x -= DEFAULT_BUDDYBORDER; SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
} }
return ret;
SetWindowPos(infoPtr->Self, infoPtr->Buddy, x,
budRect.top - DEFAULT_ADDTOP, width,
budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
SWP_NOACTIVATE);
return TRUE;
} }
/*********************************************************************** /***********************************************************************
...@@ -859,9 +870,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, ...@@ -859,9 +870,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
return (LRESULT)infoPtr->Buddy; return (LRESULT)infoPtr->Buddy;
case UDM_SETBUDDY: case UDM_SETBUDDY:
temp = (int)infoPtr->Buddy; return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
return temp;
case UDM_GETPOS: case UDM_GETPOS:
temp = UPDOWN_GetBuddyInt (infoPtr); temp = UPDOWN_GetBuddyInt (infoPtr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment