//=========================================================================== LRESULT CALLBACK Toolbar_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static UINT msgs[] = { BB_RECONFIGURE, BB_TASKSUPDATE, BB_SETTOOLBARLABEL, BB_BROADCAST, BB_DESKTOPINFO, BB_REDRAWGUI, 0 }; switch (message) { //==================== case WM_CREATE: DisableInputMethod(hwnd); TBInfo.hwnd = Toolbar_hwnd = hwnd; MessageManager_AddMessages (hwnd, msgs); MakeSticky(hwnd); Toolbar_UpdatePosition(); break; //==================== case WM_DESTROY: RemoveSticky(hwnd); MessageManager_RemoveMessages (hwnd, msgs); SetDesktopMargin(Toolbar_hwnd, 0, 0); if (Toolbar_hFont) DeleteObject(Toolbar_hFont), Toolbar_hFont = NULL; TBInfo.hwnd = Toolbar_hwnd = NULL; break; //==================== case BB_RECONFIGURE: tbreconfig: Toolbar_UpdatePosition(); Toolbar_ShowMenu(false); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case BB_REDRAWGUI: if (wParam & BBRG_TOOLBAR) { Toolbar_force_button_pressed = 0 != (wParam & BBRG_PRESSED); Toolbar_UpdatePosition(); InvalidateRect(hwnd, NULL, FALSE); } break; //==================== case BB_TASKSUPDATE: showlabel: Toolbar_setlabel(); InvalidateRect(hwnd, NULL, FALSE); break; case BB_DESKTOPINFO: Toolbar_setlabel(); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case WM_ACTIVATEAPP: if (wParam) SetOnTop(hwnd); break; //==================== case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); PaintToolbar(hdc, &ps.rcPaint); EndPaint(hwnd, &ps); break; } //==================== case BB_SETTOOLBARLABEL: SetTimer(hwnd, TOOLBAR_SETLABEL_TIMER, 2000, (TIMERPROC)NULL); Toolbar_ShowingExternalLabel = true; strcpy_max(Toolbar_CurrentWindow, (LPCTSTR)lParam, sizeof(Toolbar_CurrentWindow)/sizeof(TCHAR)); InvalidateRect(hwnd, NULL, FALSE); break; //==================== case WM_TIMER: if (wParam == TOOLBAR_AUTOHIDE_TIMER) { if (TBInfo.autoHide) { if (check_mouse(hwnd) || (TBInfo.bbsb_hwnd && check_mouse(TBInfo.bbsb_hwnd))) break; Toolbar_AutoHide(true); } KillTimer(hwnd, wParam); break; } if (wParam == TOOLBAR_UPDATE_TIMER) { Toolbar_setclock(); InvalidateRect(hwnd, NULL, FALSE); break; } KillTimer(hwnd, wParam); if (wParam == TOOLBAR_SETLABEL_TIMER) { Toolbar_ShowingExternalLabel = false; goto showlabel; } break; //==================== /* case WM_DROPFILES: drop_style((HDROP)wParam); break; */ //==================== case WM_LBUTTONDOWN: if (wParam & MK_CONTROL) { // Allow window to move if control key is being held down, UpdateWindow(hwnd); SendMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0); break; } goto left_mouse; case WM_LBUTTONDBLCLK: if (wParam & MK_CONTROL) { // double click moves the window back to the default position Toolbar_set_pos(); break; } goto left_mouse; case WM_MOUSEMOVE: if (TBInfo.autohidden) { // bring back from autohide SetTimer(hwnd, TOOLBAR_AUTOHIDE_TIMER, 250, NULL); Toolbar_AutoHide(false); break; } goto left_mouse; case WM_LBUTTONUP: left_mouse: { POINT MouseEventPoint; MouseEventPoint.x = (short)LOWORD(lParam); MouseEventPoint.y = (short)HIWORD(lParam); if (HandleCapture(hwnd, message, MouseEventPoint)) break; for (int i=0; i<5; i++) if (CheckButton( hwnd, message, MouseEventPoint, &Toolbar_Button[i].r, &Toolbar_Button[i].pressed, Toolbar_button_event, i )) goto _break; if (message == WM_LBUTTONDOWN) SetActiveWindow(hwnd); } _break: break; //==================== // show menus case WM_RBUTTONUP: { int x = (short)LOWORD(lParam); if (x < tbClockW) PostMessage(BBhwnd, BB_MENU, BB_MENU_TASKS, 0); else if (x >= TBInfo.width - tbClockW) PostMessage(BBhwnd, BB_MENU, BB_MENU_ROOT, 0); else Toolbar_ShowMenu(true); break; } //==================== case WM_MBUTTONUP: // Is shift key held down? if (wParam & MK_SHIFT) PostMessage(BBhwnd, BB_TOGGLEPLUGINS, 0, 0); else PostMessage(BBhwnd, BB_TOGGLETRAY, 0, 0); break; //==================== // If moved, snap window to screen edges... case WM_WINDOWPOSCHANGING: if (Toolbar_moving) SnapWindowToEdge((WINDOWPOS*)lParam, 0, SNAP_FULLSCREEN); break; case WM_ENTERSIZEMOVE: Toolbar_moving = true; break; case WM_EXITSIZEMOVE: Toolbar_moving = false; break; //==================== case BB_BROADCAST: if (0 == _tmemcmp((LPTSTR)lParam, _T("@Toolbar"), 8)) { const TCHAR *argument = (LPTSTR)lParam; const struct cfgmenu *p_menu, *p_item; const void *v = exec_internal_broam(argument, tb_main, &p_menu, &p_item); if (v) goto tbreconfig; break; } if (!_tcsicmp((LPCTSTR)lParam, _T("@BBShowPlugins"))) { Toolbar_hidden = false; Toolbar_UpdatePosition(); break; } if (!_tcsicmp((LPCTSTR)lParam, _T("@BBHidePlugins"))) { if (Settings_toolbarPluginToggle) { Toolbar_hidden = true; Toolbar_UpdatePosition(); } break; } break; case WM_CLOSE: break; default: return DefWindowProc(hwnd,message,wParam,lParam); //==================== } return 0; }
LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool supressRepos = false; switch(msg) { case WM_CREATE: g_ctrl->hWnd = hwnd; PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); return FALSE; case WM_DESTROY: g_ctrl->hWnd = NULL; break; case WM_MOVE: return 0; case WM_WINDOWPOSCHANGING: case WM_SIZE: if (g_ctrl->nLastHeight != HIWORD(lParam)) { db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); ArrangeButtons(); } if (supressRepos) { supressRepos = false; break; } // fall through case TTB_REPOSBUTTONS: if (g_ctrl->hWnd == hwnd) { int iHeight = ArrangeButtons(); if ( g_ctrl->bAutoSize) { RECT rcClient; GetClientRect(g_ctrl->hWnd, &rcClient); rcClient.bottom -= rcClient.top; if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) { supressRepos = true; PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); } } return 0; } break; case WM_NCPAINT: case WM_PAINT: PaintToolbar(hwnd); return 0; case WM_LBUTTONDOWN: if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) { POINT pt; GetCursorPos(&pt); return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); } return 0; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: case BN_DOUBLECLICKED: { int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); if (id != 0) { mir_cslock lck(csButtonsHook); TopButtonInt* b = idtopos(id); if (b == NULL || b->isSep()) return 0; if (b->dwFlags & TTBBF_ASPUSHBUTTON) b->bPushed = !b->bPushed; if (b->bPushed) { //Dn -> Up if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true if (b->pszService != NULL) CallService(b->pszService, b->wParamUp, b->lParamUp); } else { //Up -> Dn if (b->pszService != NULL) CallService(b->pszService, b->wParamDown, b->lParamDown); } b->SetBitmap(); } } break; } break; case TTB_UPDATEFRAMEVISIBILITY: { bool bResize = false; if (g_ctrl->bAutoSize) { int Height = ArrangeButtons(); INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0); if (Height != frameopt) { CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height); bResize = TRUE; } } if (g_ctrl->bOrderChanged) bResize = TRUE, g_ctrl->bOrderChanged = FALSE; if (bResize) CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS); } break; case TTB_SETCUSTOMDATASIZE: g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam); if (lParam > sizeof(TTBCtrl)) memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl)); SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }