* - TB_INSERTMARKHITTEST
* - TB_SAVERESTORE
* - TB_SETMETRICS
+ * - WM_WININICHANGE
* - Notifications:
* - NM_CHAR
* - NM_KEYDOWN
BOOL bBtnTranspnt; /* button transparency flag */
BOOL bAutoSize; /* auto size deadlock indicator */
BOOL bAnchor; /* anchor highlight enabled */
- BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
BOOL bDoRedraw; /* Redraw status */
BOOL bDragOutSent; /* has TBN_DRAGOUT notification been sent for this drag? */
BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
#define ARROW_HEIGHT 3
#define INSERTMARK_WIDTH 2
+#define DEFPAD_CX 7
+#define DEFPAD_CY 6
+
/* gap between border of button and text/image */
#define OFFSET_X 1
#define OFFSET_Y 1
nmhdr->code = code;
TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code,
- (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
+ (infoPtr->bUnicode) ? "via Unicode" : "via ANSI");
- if (infoPtr->bNtfUnicode)
- return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
- (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
- else
- return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
- (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
+ return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
+ (WPARAM)nmhdr->idFrom, (LPARAM)nmhdr);
}
/***********************************************************************
{
INT ret = btnPtr->iBitmap;
- if (ret == I_IMAGECALLBACK) {
- /* issue TBN_GETDISPINFO */
- NMTBDISPINFOA nmgd;
-
- nmgd.idCommand = btnPtr->idCommand;
- nmgd.lParam = btnPtr->dwData;
- nmgd.dwMask = TBNF_IMAGE;
- TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
- (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
- TBN_GETDISPINFOA);
- if (nmgd.dwMask & TBNF_DI_SETITEM) {
- btnPtr->iBitmap = nmgd.iImage;
- }
- ret = nmgd.iImage;
- TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
- ret, nmgd.dwMask, infoPtr->nNumBitmaps);
+ if (ret == I_IMAGECALLBACK)
+ {
+ /* issue TBN_GETDISPINFO */
+ NMTBDISPINFOA nmgd;
+
+ memset(&nmgd, 0, sizeof(nmgd));
+ nmgd.idCommand = btnPtr->idCommand;
+ nmgd.lParam = btnPtr->dwData;
+ nmgd.dwMask = TBNF_IMAGE;
+ TOOLBAR_SendNotify(&nmgd.hdr, infoPtr,
+ infoPtr->bUnicode ? TBN_GETDISPINFOW : TBN_GETDISPINFOA);
+ if (nmgd.dwMask & TBNF_DI_SETITEM)
+ btnPtr->iBitmap = nmgd.iImage;
+ ret = nmgd.iImage;
+ TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
+ ret, nmgd.dwMask, infoPtr->nNumBitmaps);
}
if (ret != I_IMAGENONE)
tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
tbcd.nmcd.lItemlParam = btnPtr->dwData;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
/* reset these fields so the user can't alter the behaviour like native */
tbcd.nmcd.hdc = hdc;
tbcd.nmcd.rc = rc;
tbcd.rcText = rcText;
tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
}
}
tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
tbcd.nmcd.hdc = hdc;
tbcd.nmcd.rc = ps->rcPaint;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
infoPtr->dwBaseCustDraw = ntfret & 0xffff;
if (infoPtr->bBtnTranspnt)
tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
tbcd.nmcd.hdc = hdc;
tbcd.nmcd.rc = ps->rcPaint;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
}
}
/* MSDN states that iItem is the index of the button, rather than the
* command ID as used by every other NMTOOLBAR notification */
nmtb.iItem = nIndexFrom;
- if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
+ if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT))
{
PCUSTOMBUTTON btnInfo;
NMHDR hdr;
/* MSDN states that iItem is the index of the button, rather than the
* command ID as used by every other NMTOOLBAR notification */
nmtb.iItem = nIndexAvail;
- if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
+ if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT))
{
PCUSTOMBUTTON btnInfo;
NMHDR hdr;
/* send TBN_QUERYINSERT notification */
nmtb.iItem = custInfo->tbInfo->nNumButtons;
- if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
+ if (!TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT))
return FALSE;
/* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
+ /* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */
nmtb.iItem = (int)hwnd;
/* Send TBN_INITCUSTOMIZE notification */
if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
/* send TBN_QUERYINSERT notification */
nmtb.iItem = index;
- TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
- TBN_QUERYINSERT);
+ TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT);
/* get list box item */
btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageW (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
{
x = y = 1;
cy += GetSystemMetrics(SM_CYEDGE);
- cx += GetSystemMetrics(SM_CYEDGE);
+ cx += GetSystemMetrics(SM_CXEDGE);
}
infoPtr->bAutoSize = TRUE;
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
- if (infoPtr == NULL) {
- ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
- ERR("infoPtr == NULL!\n");
- return 0;
- }
-
infoPtr->dwStructSize = (DWORD)wParam;
return 0;
custInfo.tbHwnd = hwnd;
/* send TBN_BEGINADJUST notification */
- TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
- TBN_BEGINADJUST);
+ TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_BEGINADJUST);
if (!(hRes = FindResourceW (COMCTL32_hModule,
MAKEINTRESOURCEW(IDD_TBCUSTOMIZE),
(LPARAM)&custInfo);
/* send TBN_ENDADJUST notification */
- TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
- TBN_ENDADJUST);
+ TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_ENDADJUST);
return ret;
}
nmtb.tbButton.fsStyle = btnPtr->fsStyle;
nmtb.tbButton.dwData = btnPtr->dwData;
nmtb.tbButton.iString = btnPtr->iString;
- TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_DELETINGBUTTON);
+ TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_DELETINGBUTTON);
if ((infoPtr->hwndToolTip) &&
!(btnPtr->fsStyle & BTNS_SEP)) {
INT nIndex = (INT)wParam;
TBUTTON_INFO *btnPtr;
- if (infoPtr == NULL)
- return FALSE;
-
if (lpTbb == NULL)
return FALSE;
TBUTTON_INFO *btnPtr;
INT nIndex;
- if (infoPtr == NULL)
- return -1;
if (lpTbInfo == NULL)
return -1;
if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
TBUTTON_INFO *btnPtr;
INT nIndex;
- if (infoPtr == NULL)
- return -1;
if (lpTbInfo == NULL)
return -1;
if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
LPRECT lpRect;
INT nIndex;
- if (infoPtr == NULL)
- return FALSE;
nIndex = (INT)wParam;
btnPtr = &infoPtr->buttons[nIndex];
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
LPRECT lpRect;
INT nIndex;
- if (infoPtr == NULL)
- return FALSE;
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
btnPtr = &infoPtr->buttons[nIndex];
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
- if (infoPtr == NULL)
- return 0;
-
return infoPtr->nMaxTextRows;
}
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
- if (infoPtr == NULL)
- return 0;
return (LRESULT)infoPtr->hwndToolTip;
}
if ((cx < 0) || (cy < 0))
{
ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
- return FALSE;
+ return FALSE;
}
+ TRACE("%p, cx = %d, cy = %d\n", hwnd, cx, cy);
+
/* The documentation claims you can only change the button size before
* any button has been added. But this is wrong.
* WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
- if (infoPtr == NULL) {
- TRACE("Toolbar not initialized yet?????\n");
- return FALSE;
- }
-
/* if setting to current values, ignore */
if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
(infoPtr->cxMax == (INT)HIWORD(lParam))) {
else
nmhotitem.dwFlags |= HICF_LEAVING;
- no_highlight = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
+ no_highlight = TOOLBAR_SendNotify(&nmhotitem.hdr, infoPtr, TBN_HOTITEMCHANGE);
/* now invalidate the old and new buttons so they will be painted */
if (oldBtnPtr)
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
- if (infoPtr == NULL)
- return FALSE;
-
infoPtr->nMaxTextRows = (INT)wParam;
TOOLBAR_CalcToolbar(hwnd);
TRACE("\n");
- if (infoPtr == NULL)
- return 0;
hwndOldNotify = infoPtr->hwndNotify;
infoPtr->hwndNotify = (HWND)wParam;
TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd, (HWND)wParam, lParam);
- if (infoPtr == NULL)
- return 0;
infoPtr->hwndToolTip = (HWND)wParam;
return 0;
}
infoPtr->bDoRedraw = TRUE;
infoPtr->clrBtnHighlight = CLR_DEFAULT;
infoPtr->clrBtnShadow = CLR_DEFAULT;
- /* not sure where the +1 comes from, but this comes to the same value
- * as native so this is probably correct */
- infoPtr->szPadding.cx = 2*(GetSystemMetrics(SM_CXEDGE)+OFFSET_X) + 1;
- infoPtr->szPadding.cy = 2*(GetSystemMetrics(SM_CYEDGE)+OFFSET_Y);
+ infoPtr->szPadding.cx = DEFPAD_CX;
+ infoPtr->szPadding.cy = DEFPAD_CY;
infoPtr->iListGap = infoPtr->szPadding.cx / 2;
infoPtr->dwStyle = dwStyle;
infoPtr->tbim.iButton = -1;
hwnd, 0, 0, 0);
/* Send NM_TOOLTIPSCREATED notification */
- if (infoPtr->hwndToolTip) {
+ if (infoPtr->hwndToolTip)
+ {
NMTOOLTIPSCREATED nmttc;
nmttc.hwndToolTips = infoPtr->hwndToolTip;
- TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
- NM_TOOLTIPSCREATED);
+ TOOLBAR_SendNotify (&nmttc.hdr, infoPtr, NM_TOOLTIPSCREATED);
}
}
ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
tbcd.nmcd.hdc = (HDC)wParam;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
infoPtr->dwBaseCustDraw = ntfret & 0xffff;
/* FIXME: in general the return flags *can* be or'ed together */
ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
tbcd.nmcd.hdc = (HDC)wParam;
- ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+ ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
infoPtr->dwBaseCustDraw = ntfret & 0xffff;
switch (infoPtr->dwBaseCustDraw)
{
ClientToScreen(hwnd, &pt);
nmmouse.pt = pt;
- if (!TOOLBAR_SendNotify((LPNMHDR)&nmmouse, infoPtr, NM_LDOWN))
+ if (!TOOLBAR_SendNotify(&nmmouse.hdr, infoPtr, NM_LDOWN))
return DefWindowProcW(hwnd, WM_LBUTTONDOWN, wParam, lParam);
return 0;
if (index < 0)
return 0;
- if (infoPtr->bNtfUnicode)
+ if (infoPtr->bUnicode)
{
WCHAR wszBuffer[INFOTIPSIZE+1];
NMTBGETINFOTIPW tbgit;
return TOOLBAR_TTGetDispInfo(infoPtr, (LPNMTTDISPINFOW)lParam);
case TTN_GETDISPINFOA:
- FIXME("TTN_GETDISPINFOA - stub\n");
+ FIXME("TTN_GETDISPINFOA - should not be received; please report\n");
return 0;
default:
}
-static LRESULT
-TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
- /* remove this routine when Toolbar is improved to pass infoPtr
- * around instead of hwnd.
- */
- TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
- return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
-}
-
-
static LRESULT
TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
{
x = y = 1;
cy += GetSystemMetrics(SM_CYEDGE);
- cx += GetSystemMetrics(SM_CYEDGE);
+ cx += GetSystemMetrics(SM_CXEDGE);
}
if(infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS)
return TOOLBAR_Notify (hwnd, wParam, lParam);
case WM_NOTIFYFORMAT:
- return TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
+ return TOOLBAR_NotifyFormat (infoPtr, wParam, lParam);
case WM_PAINT:
return TOOLBAR_Paint (hwnd, wParam);
static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb)
{
if (infoPtr->bUnicode)
- return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW);
+ return TOOLBAR_SendNotify(&nmtb->hdr, infoPtr, TBN_GETBUTTONINFOW);
else
{
CHAR Buffer[256];
nmtba.cchText = 256;
ZeroMemory(nmtba.pszText, nmtba.cchText);
- if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA))
+ if (TOOLBAR_SendNotify(&nmtba.hdr, infoPtr, TBN_GETBUTTONINFOA))
{
int ccht = strlen(nmtba.pszText);
if (ccht)