1 From e9ec8e9c1615ca545325998754c464214b6d6e8a Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Fri, 29 Aug 2008 14:59:05 -0500
4 Subject: [PATCH] tasklist: switch to user-drawn buttons
7 programs/explorer/tasklist.c | 39 +++++++++++++++++++++++++++++++++++++--
8 1 files changed, 37 insertions(+), 2 deletions(-)
10 diff --git a/programs/explorer/tasklist.c b/programs/explorer/tasklist.c
11 index d233dc2..2efcf70 100644
12 --- a/programs/explorer/tasklist.c
13 +++ b/programs/explorer/tasklist.c
14 @@ -88,13 +88,15 @@ static void update_window_caption(int index)
18 + HeapFree(GetProcessHeap(), 0, toplevels[index].caption);
20 length = GetWindowTextLengthW(toplevels[index].hwnd);
22 caption = HeapAlloc(GetProcessHeap(), 0, (length+1)*sizeof(WCHAR));
23 if (length == 0 || !GetWindowTextW(toplevels[index].hwnd, caption, length+1))
26 - SetWindowTextW(toplevels[index].button, caption);
27 + toplevels[index].caption = caption;
30 /* add a window to the list and return its index */
31 @@ -117,7 +119,7 @@ static int add_hwnd(HWND hwnd)
33 toplevels[result].hwnd = hwnd;
35 - toplevels[result].button = CreateWindowW(buttonW, buttonW, WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_LEFT, 0, 0, 0, 0, tasklist, (HMENU)result, NULL, NULL);
36 + toplevels[result].button = CreateWindowW(buttonW, buttonW, WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_LEFT|BS_OWNERDRAW, 0, 0, 0, 0, tasklist, (HMENU)result, NULL, NULL);
38 orig_button_proc = (WNDPROC)SetWindowLongPtrW(toplevels[result].button, GWLP_WNDPROC, (LONG_PTR)button_wndproc);
40 @@ -308,6 +310,39 @@ static LRESULT WINAPI tasklist_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
46 + int id = (int)wparam;
47 + DRAWITEMSTRUCT* dis=(DRAWITEMSTRUCT*)lparam;
51 + HFONT font, oldFont;
53 + pushed = SendMessageW(dis->hwndItem, BM_GETSTATE, 0, 0) & BST_PUSHED;
55 + DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH|(pushed?DFCS_PUSHED:0));
59 + InflateRect(&rc, -3, -3);
61 + OffsetRect(&rc, 1, 1);
63 + ZeroMemory(&lf, sizeof(lf));
65 + lf.lfWeight = FW_NORMAL;
66 + lf.lfPitchAndFamily = DEFAULT_PITCH|FF_SWISS;
67 + strcpy(lf.lfFaceName, "Arial");
68 + font = CreateFontIndirectA(&lf);
70 + oldFont = SelectObject(dis->hDC, font);
71 + DrawTextW(dis->hDC, toplevels[id].caption, -1, &rc, DT_LEFT|DT_TOP|DT_SINGLELINE|DT_WORD_ELLIPSIS);
72 + SelectObject(dis->hDC, oldFont);
79 return DefWindowProcW(hwnd, msg, wparam, lparam);