From de3c137f514ccc88b649daf199cf72cc26f57cb2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Nov 2012 18:51:23 +0000 Subject: fix for fnHitTest in all clists: extra icons could mask the mouse click git-svn-id: http://svn.miranda-ng.org/main/trunk@2236 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/clcutils.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index 9c1fb44956..19367af5ad 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -65,9 +65,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact * { ClcContact *hitcontact = NULL; ClcGroup *hitgroup = NULL; - int hit, indent, width, i; - int checkboxWidth; - SIZE textSize; + int indent, i; HFONT hFont; DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); @@ -117,7 +115,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact * *flags |= CLCHT_INLEFTMARGIN | CLCHT_NOWHERE; return -1; } - hit = cli.pfnRowHitTest(dat, dat->yScroll + testy); + int hit = cli.pfnRowHitTest(dat, dat->yScroll + testy); if (hit != -1) hit = cli.pfnGetRowByIndex(dat, hit, &hitcontact, &hitgroup); if (hit == -1) { @@ -135,7 +133,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact * *flags |= CLCHT_ONITEMINDENT; return hit; } - checkboxWidth = 0; + int checkboxWidth = 0; if (style & CLS_CHECKBOXES && hitcontact->type == CLCIT_CONTACT) checkboxWidth = dat->checkboxSize + 2; if (style & CLS_GROUPCHECKBOXES && hitcontact->type == CLCIT_GROUP) @@ -153,23 +151,27 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact * return hit; } + int eiOffset = 0; for (i=0; i < dat->extraColumnsCount; i++) { if (hitcontact->iExtraImage[i] == EMPTY_EXTRA_ICON) continue; - if (testx >= clRect.right - dat->extraColumnSpacing * (dat->extraColumnsCount - i) && - testx < clRect.right - dat->extraColumnSpacing * (dat->extraColumnsCount - i) + g_IconWidth) { - if (flags) - *flags |= CLCHT_ONITEMEXTRA | (i << 24); - return hit; - } + + eiOffset += dat->extraColumnSpacing; + if (testx >= clRect.right - eiOffset && testx < clRect.right - eiOffset + g_IconWidth) { + if (flags) + *flags |= CLCHT_ONITEMEXTRA | (i << 24); + return hit; + } } HDC hdc = GetDC(hwnd); if (hitcontact->type == CLCIT_GROUP) hFont = (HFONT)SelectObject(hdc, dat->fontInfo[FONTID_GROUPS].hFont); else hFont = (HFONT)SelectObject(hdc, dat->fontInfo[FONTID_CONTACTS].hFont); + + SIZE textSize; GetTextExtentPoint32(hdc, hitcontact->szText, lstrlen(hitcontact->szText), &textSize); - width = textSize.cx; + int width = textSize.cx; if (hitcontact->type == CLCIT_GROUP) { char *szCounts; szCounts = cli.pfnGetGroupCountsText(dat, hitcontact); -- cgit v1.2.3