summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/TSButton.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-12 15:30:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-12 15:30:21 +0000
commitc2cb7db85cbd67c5b95c2735d9b917eb0ac1d234 (patch)
tree730a517f85371ba59019bb80c32f62bbbc4abeb1 /plugins/TabSRMM/src/TSButton.cpp
parent9ffedbd49389d9aaebb0e118b0c0299b0d4d6a97 (diff)
- fix for a rare crash on tabsrmm tooltips;
- toolbar buttons added to a log git-svn-id: http://svn.miranda-ng.org/main/trunk@5659 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/TSButton.cpp')
-rw-r--r--plugins/TabSRMM/src/TSButton.cpp629
1 files changed, 322 insertions, 307 deletions
diff --git a/plugins/TabSRMM/src/TSButton.cpp b/plugins/TabSRMM/src/TSButton.cpp
index 55f5e781cc..06c3ff0d70 100644
--- a/plugins/TabSRMM/src/TSButton.cpp
+++ b/plugins/TabSRMM/src/TSButton.cpp
@@ -371,111 +371,110 @@ nonflat_themed:
static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- MButtonCtrl* bct = (MButtonCtrl *)GetWindowLongPtr(hwndDlg, 0);
+ MButtonCtrl* bct = (MButtonCtrl*)GetWindowLongPtr(hwndDlg, 0);
switch (msg) {
- case WM_NCCREATE: {
- SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
- bct = (MButtonCtrl *)malloc(sizeof(MButtonCtrl));
- if (bct == NULL)
- return FALSE;
- ZeroMemory(bct, sizeof(MButtonCtrl));
- bct->hwnd = hwndDlg;
- bct->stateId = PBS_NORMAL;
- bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- LoadTheme(bct);
- SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)bct);
- if (((CREATESTRUCT *)lParam)->lpszName)
- SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
- return TRUE;
+ case WM_NCCREATE:
+ SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
+ bct = (MButtonCtrl*)malloc(sizeof(MButtonCtrl));
+ if (bct == NULL)
+ return FALSE;
+ {
+ char *p = (char*)bct ;
+ _DebugTraceA("SESSION_INFO allocated: crashes at %lp", p + offsetof(MButtonCtrl, cHot));
}
- case WM_DESTROY: {
- if (bct) {
- EnterCriticalSection(&csTips);
- if (hwndToolTips) {
- TOOLINFO ti;
-
- ZeroMemory(&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND;
- ti.hwnd = bct->hwnd;
- ti.uId = (UINT_PTR)bct->hwnd;
- if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
- SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
- }
- if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) {
- DestroyWindow(hwndToolTips);
- hwndToolTips = NULL;
- }
+ ZeroMemory(bct, sizeof(MButtonCtrl));
+ bct->hwnd = hwndDlg;
+ bct->stateId = PBS_NORMAL;
+ bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ LoadTheme(bct);
+ SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)bct);
+ if (((CREATESTRUCT *)lParam)->lpszName)
+ SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
+ return TRUE;
+
+ case WM_DESTROY:
+ if (bct) {
+ mir_cslock lck(csTips);
+ if (hwndToolTips) {
+ TOOLINFO ti = { sizeof(ti) };
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT_PTR)bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti))
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
+
+ if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) {
+ DestroyWindow(hwndToolTips);
+ hwndToolTips = NULL;
}
- if (bct->hIconPrivate)
- DestroyIcon(bct->hIconPrivate);
- LeaveCriticalSection(&csTips);
- DestroyTheme(bct);
}
- break; // DONT! fall thru
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ DestroyTheme(bct);
}
-
- case WM_NCDESTROY:
- free(bct);
- SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)NULL);
- break;
-
- case WM_SETTEXT: {
- bct->cHot = 0;
- if ((TCHAR *)lParam) {
- TCHAR *tmp = (TCHAR *)lParam;
- while (*tmp) {
- if (*tmp == (TCHAR)'&' && *(tmp + 1)) {
- bct->cHot = _totlower(*(tmp + 1));
- break;
- }
- tmp++;
+ break; // DONT! fall thru
+
+ case WM_NCDESTROY:
+ free(bct);
+ SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)NULL);
+ break;
+
+ case WM_SETTEXT:
+ bct->cHot = 0;
+ if ((TCHAR*)lParam) {
+ TCHAR *tmp = (TCHAR*)lParam;
+ while (*tmp) {
+ if (*tmp == (TCHAR)'&' && *(tmp + 1)) {
+ bct->cHot = _totlower(*(tmp + 1));
+ break;
}
- InvalidateRect(bct->hwnd, NULL, TRUE);
+ tmp++;
}
- break;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
}
- case WM_KEYUP:
- if (bct->stateId != PBS_DISABLED && wParam == VK_SPACE && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
- if (bct->pushBtn) {
- if (bct->pbState) bct->pbState = 0;
- else bct->pbState = 1;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
- return 0;
- }
- break;
- case WM_SYSKEYUP:
- if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) {
- if (bct->pushBtn) {
- if (bct->pbState) bct->pbState = 0;
- else bct->pbState = 1;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
- return 0;
+ break;
+
+ case WM_KEYUP:
+ if (bct->stateId != PBS_DISABLED && wParam == VK_SPACE && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
}
- break;
- case WM_THEMECHANGED: {
- // themed changed, reload theme object
- if (bct->bThemed)
- LoadTheme(bct);
- InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
- break;
- }
- case WM_SETFONT: { // remember the font so we can use it later
- bct->hFont = (HFONT)wParam; // maybe we should redraw?
- break;
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ return 0;
}
- case WM_NCPAINT:
+ break;
+
+ case WM_SYSKEYUP:
+ if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
return 0;
+ }
+ break;
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC hdcPaint;
+ case WM_THEMECHANGED: // themed changed, reload theme object
+ if (bct->bThemed)
+ LoadTheme(bct);
+ InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
+ break;
+
+ case WM_SETFONT: // remember the font so we can use it later
+ bct->hFont = (HFONT)wParam; // maybe we should redraw?
+ break;
+
+ case WM_NCPAINT:
+ return 0;
- hdcPaint = BeginPaint(hwndDlg, &ps);
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdcPaint = BeginPaint(hwndDlg, &ps);
if (hdcPaint) {
if (bct->sitem)
bct->sitem->RenderThis(hdcPaint);
@@ -483,255 +482,271 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam,
PaintWorker(bct, hdcPaint);
EndPaint(hwndDlg, &ps);
}
- return 0;
}
- case BM_SETIMAGE:
- if (wParam == IMAGE_ICON) {
- ICONINFO ii;
- BITMAP bm;
-
- if (bct->hIconPrivate)
- DestroyIcon(bct->hIconPrivate);
-
- GetIconInfo((HICON)lParam, &ii);
- GetObject(ii.hbmColor, sizeof(bm), &bm);
- if (bm.bmWidth != PluginConfig.m_smcxicon || bm.bmHeight != PluginConfig.m_smcyicon) {
- HIMAGELIST hImageList;
- hImageList = ImageList_Create(PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
- ImageList_AddIcon(hImageList, (HICON)lParam);
- bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
- ImageList_RemoveAll(hImageList);
- ImageList_Destroy(hImageList);
- bct->hIcon = 0;
- } else {
- bct->hIcon = (HICON)lParam;
- bct->hIconPrivate = 0;
- }
-
- DeleteObject(ii.hbmMask);
- DeleteObject(ii.hbmColor);
- bct->hBitmap = NULL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- } else if (wParam == IMAGE_BITMAP) {
- bct->hBitmap = (HBITMAP)lParam;
- if (bct->hIconPrivate)
- DestroyIcon(bct->hIconPrivate);
- bct->hIcon = bct->hIconPrivate = NULL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- break;
- case BM_SETCHECK:
- if (!bct->pushBtn) break;
- if (wParam == BST_CHECKED) {
- bct->pbState = 1;
- bct->stateId = PBS_PRESSED;
- } else if (wParam == BST_UNCHECKED) {
- bct->pbState = 0;
- bct->stateId = PBS_NORMAL;
- }
- InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case BM_GETCHECK:
- if (bct->pushBtn) {
- return bct->pbState ? BST_CHECKED : BST_UNCHECKED;
+ return 0;
+
+ case BM_SETIMAGE:
+ if (wParam == IMAGE_ICON) {
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+
+ ICONINFO ii;
+ GetIconInfo((HICON)lParam, &ii);
+
+ BITMAP bm;
+ GetObject(ii.hbmColor, sizeof(bm), &bm);
+ if (bm.bmWidth != PluginConfig.m_smcxicon || bm.bmHeight != PluginConfig.m_smcyicon) {
+ HIMAGELIST hImageList;
+ hImageList = ImageList_Create(PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
+ ImageList_AddIcon(hImageList, (HICON)lParam);
+ bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
+ ImageList_RemoveAll(hImageList);
+ ImageList_Destroy(hImageList);
+ bct->hIcon = 0;
+ } else {
+ bct->hIcon = (HICON)lParam;
+ bct->hIconPrivate = 0;
}
- return 0;
- case BUTTONSETARROW: // turn arrow on/off
- bct->arrow = (HICON)wParam;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case BUTTONSETDEFAULT:
- bct->defbutton = (wParam != 0);
- InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case BUTTONSETASPUSHBTN:
- bct->pushBtn = (wParam != 0);
+
+ DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
+ bct->hBitmap = NULL;
InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case BUTTONSETASFLATBTN:
- bct->flatBtn = (wParam != 0);
+ }
+ else if (wParam == IMAGE_BITMAP) {
+ bct->hBitmap = (HBITMAP)lParam;
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ bct->hIcon = bct->hIconPrivate = NULL;
InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case BUTTONSETASTHEMEDBTN:
- bct->bThemed = (wParam != 0);
- break;
- case BUTTONSETASDIMMED:
- bct->dimmed = (wParam != 0);
- break;
- case BUTTONSETCONTAINER:
- bct->pContainer = (TContainerData *)wParam;
- break;
- case BUTTONSETASTITLE:
- bct->bTitleButton = TRUE;
- break;
- case BUTTONSETASNORMAL:
- bct->stateId = (wParam) ? PBS_NORMAL : PBS_DISABLED;
- InvalidateRect(bct->hwnd, NULL, FALSE);
- break;
- case BUTTONGETSTATEID:
- return bct->stateId;
- case BUTTONSETASTOOLBARBUTTON:
- bct->bToolbarButton = wParam;
- break;
- case BUTTONSETASSIDEBARBUTTON:
- bct->sitem = reinterpret_cast<CSideBarButton *>(wParam);
- break;
- case BUTTONSETOVERLAYICON:
- bct->overlay = (HICON)wParam;
- break;
- case BUTTONADDTOOLTIP: {
- TOOLINFO ti;
-
- if (!(char*)wParam)
- break;
- EnterCriticalSection(&csTips);
- if (!hwndToolTips) {
+ }
+ break;
+
+ case BM_SETCHECK:
+ if (!bct->pushBtn) break;
+ if (wParam == BST_CHECKED) {
+ bct->pbState = 1;
+ bct->stateId = PBS_PRESSED;
+ }
+ else if (wParam == BST_UNCHECKED) {
+ bct->pbState = 0;
+ bct->stateId = PBS_NORMAL;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case BM_GETCHECK:
+ if (bct->pushBtn)
+ return bct->pbState ? BST_CHECKED : BST_UNCHECKED;
+
+ return 0;
+
+ case BUTTONSETARROW: // turn arrow on/off
+ bct->arrow = (HICON)wParam;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case BUTTONSETDEFAULT:
+ bct->defbutton = (wParam != 0);
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case BUTTONSETASPUSHBTN:
+ bct->pushBtn = (wParam != 0);
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case BUTTONSETASFLATBTN:
+ bct->flatBtn = (wParam != 0);
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case BUTTONSETASTHEMEDBTN:
+ bct->bThemed = (wParam != 0);
+ break;
+
+ case BUTTONSETASDIMMED:
+ bct->dimmed = (wParam != 0);
+ break;
+
+ case BUTTONSETCONTAINER:
+ bct->pContainer = (TContainerData *)wParam;
+ break;
+
+ case BUTTONSETASTITLE:
+ bct->bTitleButton = TRUE;
+ break;
+
+ case BUTTONSETASNORMAL:
+ bct->stateId = (wParam) ? PBS_NORMAL : PBS_DISABLED;
+ InvalidateRect(bct->hwnd, NULL, FALSE);
+ break;
+
+ case BUTTONGETSTATEID:
+ return bct->stateId;
+
+ case BUTTONSETASTOOLBARBUTTON:
+ bct->bToolbarButton = wParam;
+ break;
+
+ case BUTTONSETASSIDEBARBUTTON:
+ bct->sitem = reinterpret_cast<CSideBarButton *>(wParam);
+ break;
+
+ case BUTTONSETOVERLAYICON:
+ bct->overlay = (HICON)wParam;
+ break;
+
+ case BUTTONADDTOOLTIP:
+ if (wParam) {
+ mir_cslock lck(csTips);
+ if (!hwndToolTips)
hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
- }
- ZeroMemory(&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
+
+ TOOLINFO ti = { sizeof(ti) };
ti.uFlags = TTF_IDISHWND;
ti.hwnd = bct->hwnd;
ti.uId = (UINT_PTR)bct->hwnd;
- if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti))
SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
- }
+
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ti.uId = (UINT_PTR)bct->hwnd;
- ti.lpszText = (TCHAR *)wParam;
+ ti.lpszText = (TCHAR*)wParam;
SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM)&ti);
SendMessage(hwndToolTips, TTM_SETMAXTIPWIDTH, 0, 300);
- LeaveCriticalSection(&csTips);
- break;
}
- case WM_SETFOCUS: // set keybord focus and redraw
- bct->focus = 1;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case WM_KILLFOCUS: // kill focus and redraw
- bct->focus = 0;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
- case WM_ENABLE: { // windows tells us to enable/disable
- bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED;
+ break;
+
+ case WM_SETFOCUS: // set keybord focus and redraw
+ bct->focus = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case WM_KILLFOCUS: // kill focus and redraw
+ bct->focus = 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case WM_ENABLE: // windows tells us to enable/disable
+ bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
+ case WM_MOUSELEAVE: // faked by the WM_TIMER
+ if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
+ bct->stateId = PBS_NORMAL;
InvalidateRect(bct->hwnd, NULL, TRUE);
- break;
}
- case WM_MOUSELEAVE: { // faked by the WM_TIMER
- if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
- bct->stateId = PBS_NORMAL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- break;
+ break;
+
+ case WM_CONTEXTMENU:
+ if (bct->sitem)
+ bct->sitem->invokeContextMenu();
+ break;
+
+ case WM_MBUTTONUP:
+ if (bct->sitem)
+ if (bct->sitem->getDat())
+ SendMessage(bct->sitem->getDat()->hwnd, WM_CLOSE, 1, 0);
+ break;
+
+ case WM_LBUTTONDOWN:
+ if (bct->sitem) {
+ if (bct->sitem->testCloseButton() != -1)
+ return TRUE;
+ bct->stateId = PBS_PRESSED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ bct->sitem->activateSession();
}
- case WM_CONTEXTMENU:
- if (bct->sitem)
- bct->sitem->invokeContextMenu();
- break;
-
- case WM_MBUTTONUP:
- if (bct->sitem) {
- if (bct->sitem->getDat())
- SendMessage(bct->sitem->getDat()->hwnd, WM_CLOSE, 1, 0);
- }
- break;
-
- case WM_LBUTTONDOWN: {
+ if (bct->arrow) {
RECT rc;
-
- if (bct->sitem) {
- if (bct->sitem->testCloseButton() != -1)
- return TRUE;
+ GetClientRect(bct->hwnd, &rc);
+ if (LOWORD(lParam) < rc.right - 12 && bct->stateId != PBS_DISABLED)
bct->stateId = PBS_PRESSED;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- bct->sitem->activateSession();
+ else if (LOWORD(lParam) > rc.right - 12) {
+ if (GetDlgCtrlID(hwndDlg) == IDOK || bct->stateId != PBS_DISABLED) {
+ WORD w = (WORD)((int)bct->arrow & 0x0000ffff);
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(w, BN_CLICKED), (LPARAM)hwndDlg);
+ }
}
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ else if (bct->stateId != PBS_DISABLED) {
+ bct->stateId = PBS_PRESSED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
- if (bct->arrow) {
- GetClientRect(bct->hwnd, &rc);
- if (LOWORD(lParam) < rc.right - 12 && bct->stateId != PBS_DISABLED)
- bct->stateId = PBS_PRESSED;
- else if (LOWORD(lParam) > rc.right - 12) {
- if (GetDlgCtrlID(hwndDlg) == IDOK || bct->stateId != PBS_DISABLED) {
- WORD w = (WORD)((int)bct->arrow & 0x0000ffff);
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(w, BN_CLICKED), (LPARAM)hwndDlg);
- }
- }
- InvalidateRect(bct->hwnd, NULL, TRUE);
- } else if (bct->stateId != PBS_DISABLED) {
- bct->stateId = PBS_PRESSED;
- InvalidateRect(bct->hwnd, NULL, TRUE);
+ case WM_LBUTTONUP: {
+ int showClick = 0;
+
+ if (bct->sitem) {
+ if (bct->sitem->testCloseButton() != -1) {
+ SendMessage(bct->sitem->getDat()->hwnd, WM_CLOSE, 1, 0);
+ return TRUE;
}
- break;
}
- case WM_LBUTTONUP: {
- int showClick = 0;
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ }
+ if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
+ if (bct->stateId == PBS_PRESSED)
+ showClick = 1;
+ if (msg == WM_LBUTTONUP)
+ bct->stateId = PBS_HOT;
+ else
+ bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ if (showClick)
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ break;
+ }
+ case WM_MOUSEMOVE:
+ if (bct->stateId == PBS_NORMAL) {
+ bct->stateId = PBS_HOT;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ else if (bct->arrow && bct->stateId == PBS_HOT)
+ InvalidateRect(bct->hwnd, NULL, TRUE);
- if (bct->sitem) {
- if (bct->sitem->testCloseButton() != -1) {
- SendMessage(bct->sitem->getDat()->hwnd, WM_CLOSE, 1, 0);
- return TRUE;
+ // Call timer, used to start cheesy TrackMouseEvent faker
+ SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
+ if (bct->sitem) {
+ if (bct->sitem->testCloseButton() != -1) {
+ if (bct->sitem->m_sideBar->getHoveredClose() != bct->sitem) {
+ bct->sitem->m_sideBar->setHoveredClose(bct->sitem);
+ InvalidateRect(hwndDlg, 0, FALSE);
}
}
- if (bct->pushBtn) {
- if (bct->pbState) bct->pbState = 0;
- else bct->pbState = 1;
- }
- if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
- if (bct->stateId == PBS_PRESSED)
- showClick = 1;
- if (msg == WM_LBUTTONUP)
- bct->stateId = PBS_HOT;
- else
- bct->stateId = PBS_NORMAL;
- InvalidateRect(bct->hwnd, NULL, TRUE);
+ else {
+ bct->sitem->m_sideBar->setHoveredClose(0);
+ InvalidateRect(hwndDlg, 0, FALSE);
}
- if (showClick)
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
- break;
}
- case WM_MOUSEMOVE:
- if (bct->stateId == PBS_NORMAL) {
- bct->stateId = PBS_HOT;
- InvalidateRect(bct->hwnd, NULL, TRUE);
- } else if (bct->arrow && bct->stateId == PBS_HOT) {
- InvalidateRect(bct->hwnd, NULL, TRUE);
- }
- // Call timer, used to start cheesy TrackMouseEvent faker
- SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
- if (bct->sitem) {
- if (bct->sitem->testCloseButton() != -1) {
- if (bct->sitem->m_sideBar->getHoveredClose() != bct->sitem) {
- bct->sitem->m_sideBar->setHoveredClose(bct->sitem);
- InvalidateRect(hwndDlg, 0, FALSE);
- }
- }
- else {
+ break;
+ case WM_TIMER: // use a timer to check if they have did a mouseout
+ if (wParam == BUTTON_POLLID) {
+ RECT rc;
+ POINT pt;
+ GetWindowRect(hwndDlg, &rc);
+ GetCursorPos(&pt);
+ if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave
+ PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L);
+ KillTimer(hwndDlg, BUTTON_POLLID);
+ if (bct->sitem) {
bct->sitem->m_sideBar->setHoveredClose(0);
InvalidateRect(hwndDlg, 0, FALSE);
}
}
- break;
- case WM_TIMER: { // use a timer to check if they have did a mouseout
- if (wParam == BUTTON_POLLID) {
- RECT rc;
- POINT pt;
- GetWindowRect(hwndDlg, &rc);
- GetCursorPos(&pt);
- if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave
- PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L);
- KillTimer(hwndDlg, BUTTON_POLLID);
- if (bct->sitem) {
- bct->sitem->m_sideBar->setHoveredClose(0);
- InvalidateRect(hwndDlg, 0, FALSE);
- }
- }
- }
- break;
}
- case WM_ERASEBKGND:
- return 1;
+ break;
+
+ case WM_ERASEBKGND:
+ return 1;
}
return DefWindowProc(hwndDlg, msg, wParam, lParam);
}