From e4ff24d8abc2af58b91585bc3ce221214d5a148b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 10 Jul 2012 17:54:52 +0000 Subject: fixes for Clist Modern's skinned toolbar git-svn-id: http://svn.miranda-ng.org/main/trunk@890 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TopToolBar/common.h | 2 ++ plugins/TopToolBar/toolbar.cpp | 63 +++++++++++++++++++++++++++------------- plugins/TopToolBar/topbutton.cpp | 5 +--- 3 files changed, 46 insertions(+), 24 deletions(-) (limited to 'plugins/TopToolBar') diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h index 82fad3485f..23c0bcb2f0 100644 --- a/plugins/TopToolBar/common.h +++ b/plugins/TopToolBar/common.h @@ -34,6 +34,8 @@ #include "m_icolib.h" #include "BkgrCfg.h" +#define TTB_BUTTON_CLASS _T("TopToolbarButtonClass") + #define TTBDEFAULT_BKBMPUSE CLB_STRETCH #define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE) #define TTBDEFAULT_USEBITMAP 0 diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 48957e9171..45add6f4f7 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -14,6 +14,7 @@ int nextButtonId = 200; static HANDLE hTTBModuleLoaded, hTTBInitButtons; static TCHAR pluginname[] = _T("TopToolBar"); +static WNDPROC buttonWndProc; //------------ options ------------- COLORREF bkColour; @@ -648,6 +649,24 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara switch(msg) { case WM_CREATE: g_ctrl->hWnd = hwnd; + + // if we're working in skinned clist, receive the standard buttons & customizations + if (g_CustomProc && g_ctrl->hWnd) + g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); + { + CLISTFrame Frame = { 0 }; + Frame.cbSize = sizeof(Frame); + Frame.tname = _T("Toolbar"); + Frame.hWnd = hwnd; + Frame.align = alTop; + Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_TCHAR | F_NO_SUBCONTAINER; + Frame.height = 18; + g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); + } + + // receive all buttons + NotifyEventHooks(hTTBInitButtons, 0, 0); + NotifyEventHooks(hTTBModuleLoaded, 0, 0); return FALSE; case WM_MOVE: @@ -671,9 +690,6 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } return 0; - case WM_NOTIFY: - return 0; - case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: @@ -753,23 +769,6 @@ static INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) ttbOptionsChanged(); - // if we're working in skinned clist, receive the standard buttons & customizations - NotifyEventHooks(hTTBInitButtons, 0, 0); - if (g_CustomProc && g_ctrl->hWnd) - g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); - - // receive all another buttons - NotifyEventHooks(hTTBModuleLoaded, 0, 0); - - CLISTFrame Frame = { 0 }; - Frame.cbSize = sizeof(Frame); - Frame.tname = pluginname; - Frame.hWnd = g_ctrl->hWnd; - Frame.align = alTop; - Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_TCHAR | F_NO_SUBCONTAINER; - Frame.height = 18; - g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); - bEventFired = true; return 0; } @@ -823,6 +822,19 @@ int OnModulesLoad(WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// +static LRESULT CALLBACK TTBButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + LRESULT lResult = buttonWndProc(hwnd, msg, wParam, lParam); + + if (msg == WM_NCCREATE) { + TopButtonInt* p = (TopButtonInt*)((CREATESTRUCT*)lParam)->lpCreateParams; + if (g_CustomProc) + g_CustomProc((HANDLE)p->id, hwnd, g_CustomProcParam); + } + + return lResult; +} + int LoadToolbarModule() { g_ctrl = (TTBCtrl*)mir_calloc( sizeof(TTBCtrl)); @@ -853,6 +865,17 @@ int LoadToolbarModule() CreateServiceFunction("TopToolBar/SetCustomProc", TTBSetCustomProc); CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire); + buttonWndProc = (WNDPROC)CallService("Button/GetWindowProc",0,0); + WNDCLASSEX wc = {0}; + wc.cbSize = sizeof(wc); + wc.lpszClassName = TTB_BUTTON_CLASS; + wc.lpfnWndProc = TTBButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(void*); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; + RegisterClassEx(&wc); + g_ctrl->nButtonHeight = db_get_b(0, TTB_OPTDIR, "BUTTHEIGHT", DEFBUTTHEIGHT); g_ctrl->nButtonWidth = db_get_b(0, TTB_OPTDIR, "BUTTWIDTH", DEFBUTTWIDTH); g_ctrl->nButtonSpace = db_get_b(0, TTB_OPTDIR, "BUTTGAP", DEFBUTTGAP); diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp index 5bcab82017..762b784934 100644 --- a/plugins/TopToolBar/topbutton.cpp +++ b/plugins/TopToolBar/topbutton.cpp @@ -51,10 +51,7 @@ DWORD TopButtonInt::CheckFlags(DWORD Flags) void TopButtonInt::CreateWnd() { if ( !(dwFlags & TTBBF_ISSEPARATOR)) { - hwnd = CreateWindow(MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, 0); - - if (g_CustomProc) - g_CustomProc((HANDLE)id, hwnd, g_CustomProcParam); + hwnd = CreateWindow(TTB_BUTTON_CLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, this); if (dwFlags & TTBBF_ASPUSHBUTTON) SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0); -- cgit v1.2.3