#define TOOLBAR_NOWHERE (-1)
-#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
-#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
-
/* Used to find undocumented extended styles */
#define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
TBSTYLE_EX_UNDOC1 | \
return (infoPtr->dwStyle & TBSTYLE_FLAT ? 0 : TOP_BORDER);
}
+static inline BOOL TOOLBAR_HasDropDownArrows(DWORD exStyle)
+{
+ return (exStyle & TBSTYLE_EX_DRAWDDARROWS) != 0;
+}
+
static LPWSTR
TOOLBAR_GetText(const TOOLBAR_INFO *infoPtr, const TBUTTON_INFO *btnPtr)
{
if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
if (btnPtr->iBitmap == I_IMAGENONE) return NULL;
- ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
+ WARN("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
HIWORD(btnPtr->iBitmap), LOWORD(btnPtr->iBitmap), infoPtr->nNumBitmaps);
return NULL;
}
btnPtr = infoPtr->buttons;
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
- if(TOOLBAR_HasText(infoPtr, btnPtr))
+ if(TOOLBAR_GetText(infoPtr, btnPtr))
{
TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
if (sz.cx > lpSize->cx)
static INT
-TOOLBAR_InternalHitTest (const TOOLBAR_INFO *infoPtr, const POINT *lpPt)
+TOOLBAR_InternalHitTest (const TOOLBAR_INFO *infoPtr, const POINT *lpPt, BOOL *button)
{
TBUTTON_INFO *btnPtr;
INT i;
+ if (button)
+ *button = FALSE;
+
btnPtr = infoPtr->buttons;
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
if (btnPtr->fsState & TBSTATE_HIDDEN)
else {
if (PtInRect (&btnPtr->rect, *lpPt)) {
TRACE(" ON BUTTON %d!\n", i);
+ if (button)
+ *button = TRUE;
return i;
}
}
nmtb.tbButton.iString >= 0 ? debugstr_w(infoPtr->strings[nmtb.tbButton.iString])
: "");
- /* insert button into the apropriate list */
+ /* insert button into the appropriate list */
index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
if (index == -1)
{
btnPtr = &infoPtr->buttons[nIndex];
- bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
+ bChecked = (btnPtr->fsState & TBSTATE_CHECKED) != 0;
if (LOWORD(lParam) == FALSE)
btnPtr->fsState &= ~TBSTATE_CHECKED;
static inline LRESULT
TOOLBAR_HitTest (const TOOLBAR_INFO *infoPtr, const POINT* lpPt)
{
- return TOOLBAR_InternalHitTest (infoPtr, lpPt);
+ return TOOLBAR_InternalHitTest (infoPtr, lpPt, NULL);
}
* (MSDN says that this parameter is reserved)
*/
static LRESULT
-TOOLBAR_SetExtendedStyle (TOOLBAR_INFO *infoPtr, LPARAM lParam)
+TOOLBAR_SetExtendedStyle (TOOLBAR_INFO *infoPtr, DWORD mask, DWORD style)
{
- DWORD dwOldStyle;
+ DWORD old_style = infoPtr->dwExStyle;
- dwOldStyle = infoPtr->dwExStyle;
- infoPtr->dwExStyle = (DWORD)lParam;
+ TRACE("mask=0x%08x, style=0x%08x\n", mask, style);
- TRACE("new style 0x%08x\n", infoPtr->dwExStyle);
+ if (mask)
+ infoPtr->dwExStyle = (old_style & ~mask) | (style & mask);
+ else
+ infoPtr->dwExStyle = style;
if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
FIXME("Unknown Toolbar Extended Style 0x%08x. Please report.\n",
(infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
- if ((dwOldStyle ^ infoPtr->dwExStyle) & TBSTYLE_EX_MIXEDBUTTONS)
+ if ((old_style ^ infoPtr->dwExStyle) & TBSTYLE_EX_MIXEDBUTTONS)
TOOLBAR_CalcToolbar(infoPtr);
else
TOOLBAR_LayoutToolbar(infoPtr);
TOOLBAR_AutoSize(infoPtr);
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
- return (LRESULT)dwOldStyle;
+ return old_style;
}
TRACE("hwnd = %p, style=0x%08x\n", hwnd, lpcs->style);
- infoPtr->dwStyle = lpcs->style;
+ infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
GetClientRect(hwnd, &infoPtr->client_rect);
infoPtr->bUnicode = infoPtr->hwndNotify &&
(NFR_UNICODE == SendMessageW(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_REQUERY));
TOOLBAR_LButtonDblClk (TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
POINT pt;
- INT nHit;
+ BOOL button;
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
- nHit = TOOLBAR_InternalHitTest (infoPtr, &pt);
+ TOOLBAR_InternalHitTest (infoPtr, &pt, &button);
- if (nHit >= 0)
+ if (button)
TOOLBAR_LButtonDown (infoPtr, wParam, lParam);
else if (infoPtr->dwStyle & CCS_ADJUSTABLE)
TOOLBAR_Customize (infoPtr);
NMTOOLBARA nmtb;
NMMOUSE nmmouse;
BOOL bDragKeyPressed;
+ BOOL button;
TRACE("\n");
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
- nHit = TOOLBAR_InternalHitTest (infoPtr, &pt);
+ nHit = TOOLBAR_InternalHitTest (infoPtr, &pt, &button);
- btnPtr = &infoPtr->buttons[nHit];
+ if (button)
+ btnPtr = &infoPtr->buttons[nHit];
- if ((nHit >= 0) && bDragKeyPressed && (infoPtr->dwStyle & CCS_ADJUSTABLE))
+ if (button && bDragKeyPressed && (infoPtr->dwStyle & CCS_ADJUSTABLE))
{
infoPtr->nButtonDrag = nHit;
SetCapture (infoPtr->hwndSelf);
hCursorDrag = LoadCursorW(COMCTL32_hModule, (LPCWSTR)IDC_MOVEBUTTON);
SetCursor(hCursorDrag);
}
- else if (nHit >= 0)
+ else if (button)
{
RECT arrowRect;
infoPtr->nOldHit = nHit;
* NOTE: native doesn't do this, but that is a bug */
GetCursorPos(&pt);
ScreenToClient(infoPtr->hwndSelf, &pt);
- nHit = TOOLBAR_InternalHitTest(infoPtr, &pt);
- if (!infoPtr->bAnchor || (nHit >= 0))
- TOOLBAR_SetHotItemEx(infoPtr, nHit, HICF_MOUSE | HICF_LMOUSE);
+ nHit = TOOLBAR_InternalHitTest(infoPtr, &pt, &button);
+ if (!infoPtr->bAnchor || button)
+ TOOLBAR_SetHotItemEx(infoPtr, button ? nHit : TOOLBAR_NOWHERE, HICF_MOUSE | HICF_LMOUSE);
/* remove any left mouse button down or double-click messages
* so that we can get a toggle effect on the button */
btnPtr->fsState |= TBSTATE_PRESSED;
- TOOLBAR_SetHotItemEx(infoPtr, nHit, HICF_MOUSE | HICF_LMOUSE);
+ TOOLBAR_SetHotItemEx(infoPtr, button ? nHit : TOOLBAR_NOWHERE, HICF_MOUSE | HICF_LMOUSE);
if (btnPtr->fsState & TBSTATE_ENABLED)
InvalidateRect(infoPtr->hwndSelf, &btnPtr->rect, TRUE);
SetCapture (infoPtr->hwndSelf);
}
- if (nHit >=0)
+ if (button)
{
memset(&nmtb, 0, sizeof(nmtb));
nmtb.iItem = btnPtr->idCommand;
nmmouse.dwHitInfo = nHit;
/* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
- if (nHit < 0)
+ if (!button)
nmmouse.dwItemSpec = -1;
else
{
NMHDR hdr;
NMMOUSE nmmouse;
NMTOOLBARA nmtb;
+ BOOL button;
if (infoPtr->hwndToolTip)
TOOLBAR_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwndSelf,
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
- nHit = TOOLBAR_InternalHitTest (infoPtr, &pt);
+ nHit = TOOLBAR_InternalHitTest (infoPtr, &pt, &button);
- if (!infoPtr->bAnchor || (nHit >= 0))
- TOOLBAR_SetHotItemEx(infoPtr, nHit, HICF_MOUSE | HICF_LMOUSE);
+ if (!infoPtr->bAnchor || button)
+ TOOLBAR_SetHotItemEx(infoPtr, button ? nHit : TOOLBAR_NOWHERE, HICF_MOUSE | HICF_LMOUSE);
if (infoPtr->nButtonDrag >= 0) {
RECT rcClient;
}
/* button under cursor changed so need to re-set hot item */
- TOOLBAR_SetHotItemEx(infoPtr, nHit, HICF_MOUSE | HICF_LMOUSE);
+ TOOLBAR_SetHotItemEx(infoPtr, button ? nHit : TOOLBAR_NOWHERE, HICF_MOUSE | HICF_LMOUSE);
infoPtr->nButtonDrag = -1;
TOOLBAR_SendNotify(&hdr, infoPtr, TBN_TOOLBARCHANGE);
* NM_CLICK with the NMMOUSE structure. */
nmmouse.dwHitInfo = nHit;
- if (nHit < 0)
+ if (!button)
nmmouse.dwItemSpec = -1;
else
{
INT nHit;
NMMOUSE nmmouse;
POINT pt;
+ BOOL button;
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
- nHit = TOOLBAR_InternalHitTest(infoPtr, &pt);
+ nHit = TOOLBAR_InternalHitTest(infoPtr, &pt, &button);
nmmouse.dwHitInfo = nHit;
- if (nHit < 0) {
+ if (!button) {
nmmouse.dwItemSpec = -1;
} else {
nmmouse.dwItemSpec = infoPtr->buttons[nmmouse.dwHitInfo].idCommand;
TRACKMOUSEEVENT trackinfo;
INT nHit;
TBUTTON_INFO *btnPtr;
+ BOOL button;
if ((infoPtr->dwStyle & TBSTYLE_TOOLTIPS) && (infoPtr->hwndToolTip == NULL))
TOOLBAR_TooltipCreateControl(infoPtr);
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
- nHit = TOOLBAR_InternalHitTest (infoPtr, &pt);
+ nHit = TOOLBAR_InternalHitTest (infoPtr, &pt, &button);
if (((infoPtr->dwStyle & TBSTYLE_FLAT) || GetWindowTheme (infoPtr->hwndSelf))
- && (!infoPtr->bAnchor || (nHit >= 0)))
- TOOLBAR_SetHotItemEx(infoPtr, nHit, HICF_MOUSE);
+ && (!infoPtr->bAnchor || button))
+ TOOLBAR_SetHotItemEx(infoPtr, button ? nHit : TOOLBAR_NOWHERE, HICF_MOUSE);
if (infoPtr->nOldHit != nHit)
{
return TOOLBAR_SetDrawTextFlags (infoPtr, wParam, lParam);
case TB_SETEXTENDEDSTYLE:
- return TOOLBAR_SetExtendedStyle (infoPtr, lParam);
+ return TOOLBAR_SetExtendedStyle (infoPtr, wParam, lParam);
case TB_SETHOTIMAGELIST:
return TOOLBAR_SetHotImageList (infoPtr, wParam, (HIMAGELIST)lParam);