📄 taskswnd.c
字号:
border. We need to fill that area with the flashing color. Note
that since we're using DrawCaptionTemp() the flashing color is
COLOR_ACTIVECAPTION, not COLOR_HIGHLIGHT! */
FillRect(nmtbcd->nmcd.hdc,
&nmtbcd->nmcd.rc,
(HBRUSH)(COLOR_ACTIVECAPTION + 1));
/* Make the button content appear pressed. This however draws a bit
into the right and bottom border of the button edge, making it
look a bit odd. However, selecting a clipping region to prevent
that from happening causes problems with DrawCaptionTemp()! */
OffsetRect(&nmtbcd->nmcd.rc,
1,
1);
/* Render flashed */
uidctFlags |= DC_ACTIVE;
}
else
{
uidctFlags |= DC_INBUTTON;
if (nmtbcd->nmcd.uItemState & CDIS_CHECKED)
uidctFlags |= DC_ACTIVE;
}
/* Draw the button content */
TaskItem->DisplayTooltip = !DrawCaptionTemp(TaskItem->hWnd,
nmtbcd->nmcd.hdc,
&nmtbcd->nmcd.rc,
hCaptionFont,
NULL,
NULL,
uidctFlags);
return CDRF_SKIPDEFAULT;
#else /* !TASK_USE_DRAWCAPTIONTEMP */
/* Make the entire button flashing if neccessary */
if (nmtbcd->nmcd.uItemState & CDIS_MARKED)
{
if (TaskItem->RenderFlashed)
{
nmtbcd->hbrMonoDither = GetSysColorBrush(COLOR_HIGHLIGHT);
nmtbcd->clrTextHighlight = GetSysColor(COLOR_HIGHLIGHTTEXT);
nmtbcd->nHLStringBkMode = TRANSPARENT;
/* We don't really need to set clrMark because we set the
background mode to TRANSPARENT! */
nmtbcd->clrMark = GetSysColor(COLOR_HIGHLIGHT);
Ret |= TBCDRF_USECDCOLORS;
}
else
Ret |= TBCDRF_NOMARK;
}
/* Select the font we want to use */
SelectObject(nmtbcd->nmcd.hdc,
hCaptionFont);
return Ret | CDRF_NEWFONT;
#endif
}
}
else
{
PTASK_GROUP TaskGroup = GET_TASKGROUP_PTR(nmtbcd->nmcd.lItemlParam);
if (TaskGroup != NULL)
{
/* FIXME: Implement painting for task groups */
}
}
return Ret;
}
static LRESULT
TaskSwitchWnd_HandleToolbarNotification(IN OUT PTASK_SWITCH_WND This,
IN const NMHDR *nmh)
{
LRESULT Ret = 0;
switch (nmh->code)
{
case NM_CUSTOMDRAW:
{
LPNMTBCUSTOMDRAW nmtbcd = (LPNMTBCUSTOMDRAW)nmh;
switch (nmtbcd->nmcd.dwDrawStage)
{
#if TASK_USE_DRAWCAPTIONTEMP != 0
case CDDS_ITEMPREPAINT:
/* We handle drawing in the post-paint stage so that we
don't have to draw the button edges, etc */
Ret = CDRF_NOTIFYPOSTPAINT;
break;
case CDDS_ITEMPOSTPAINT:
#else /* !TASK_USE_DRAWCAPTIONTEMP */
case CDDS_ITEMPREPAINT:
#endif
Ret = TaskSwichWnd_HandleItemPaint(This,
nmtbcd);
break;
case CDDS_PREPAINT:
Ret = CDRF_NOTIFYITEMDRAW;
break;
default:
Ret = CDRF_DODEFAULT;
break;
}
break;
}
}
return Ret;
}
static LRESULT CALLBACK
TaskSwitchWndProc(IN HWND hwnd,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
PTASK_SWITCH_WND This = NULL;
LRESULT Ret = FALSE;
if (uMsg != WM_NCCREATE)
{
This = (PTASK_SWITCH_WND)GetWindowLongPtr(hwnd,
0);
}
if (This != NULL || uMsg == WM_NCCREATE)
{
switch (uMsg)
{
case WM_SIZE:
{
SIZE szClient;
szClient.cx = LOWORD(lParam);
szClient.cy = HIWORD(lParam);
if (This->hWndToolbar != NULL)
{
SetWindowPos(This->hWndToolbar,
NULL,
0,
0,
szClient.cx,
szClient.cy,
SWP_NOZORDER);
TaskSwitchWnd_UpdateButtonsSize(This,
FALSE);
}
break;
}
case WM_NCHITTEST:
{
/* We want the tray window to be draggable everywhere, so make the control
appear transparent */
Ret = DefWindowProc(hwnd,
uMsg,
wParam,
lParam);
if (Ret != HTVSCROLL && Ret != HTHSCROLL)
Ret = HTTRANSPARENT;
break;
}
case WM_COMMAND:
{
if (lParam != 0 && (HWND)lParam == This->hWndToolbar)
{
DbgPrint("WM_COMMAND %u:%u (%u)\n", (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (UINT)wParam);
}
break;
}
case WM_NOTIFY:
{
const NMHDR *nmh = (const NMHDR *)lParam;
if (nmh->hwndFrom == This->hWndToolbar)
{
Ret = TaskSwitchWnd_HandleToolbarNotification(This,
nmh);
}
break;
}
case TSWM_ENABLEGROUPING:
{
Ret = This->IsGroupingEnabled;
if (wParam != This->IsGroupingEnabled)
{
TaskSwitchWnd_EnableGrouping(This,
(BOOL)wParam);
}
break;
}
case TSWM_UPDATETASKBARPOS:
{
/* Update the button spacing */
TaskSwitchWnd_UpdateTbButtonSpacing(This,
ITrayWindow_IsHorizontal(This->Tray),
0);
break;
}
case WM_CONTEXTMENU:
{
if (This->hWndToolbar != NULL)
{
POINT pt;
INT_PTR iBtn;
pt.x = (LONG)LOWORD(lParam);
pt.y = (LONG)HIWORD(lParam);
MapWindowPoints(NULL,
This->hWndToolbar,
&pt,
1);
iBtn = (INT_PTR)SendMessage(This->hWndToolbar,
TB_HITTEST,
0,
(LPARAM)&pt);
if (iBtn >= 0)
{
/* FIXME: Display the system menu of the window */
}
else
goto ForwardContextMenuMsg;
}
else
{
ForwardContextMenuMsg:
/* Forward message */
Ret = SendMessage(ITrayWindow_GetHWND(This->Tray),
uMsg,
wParam,
lParam);
}
break;
}
case WM_NCCREATE:
{
LPCREATESTRUCT CreateStruct = (LPCREATESTRUCT)lParam;
This = (PTASK_SWITCH_WND)HeapAlloc(hProcessHeap,
0,
sizeof(*This));
if (This == NULL)
return FALSE;
ZeroMemory(This,
sizeof(*This));
This->hWnd = hwnd;
This->hWndNotify = CreateStruct->hwndParent;
This->Tray = (ITrayWindow*)CreateStruct->lpCreateParams;
This->IsGroupingEnabled = TRUE; /* FIXME */
SetWindowLongPtr(hwnd,
0,
(LONG_PTR)This);
return TRUE;
}
case WM_CREATE:
TaskSwitchWnd_Create(This);
#if DUMP_TASKS != 0
SetTimer(hwnd,
1,
5000,
NULL);
#endif
break;
case WM_DESTROY:
if (This->IsToolbarSubclassed)
{
if (RemoveWindowSubclass(This->hWndToolbar,
TaskSwichWnd_ToolbarSubclassedProc,
TSW_TOOLBAR_SUBCLASS_ID))
{
This->IsToolbarSubclassed = FALSE;
}
}
break;
case WM_NCDESTROY:
TaskSwitchWnd_NCDestroy(This);
HeapFree(hProcessHeap,
0,
This);
SetWindowLongPtr(hwnd,
0,
0);
break;
#if DUMP_TASKS != 0
case WM_TIMER:
switch(wParam)
{
case 1:
TaskSwitchWnd_DumpTasks(This);
break;
}
break;
#endif
default:
/* HandleDefaultMessage: */
if (uMsg == This->ShellHookMsg && This->ShellHookMsg != 0)
{
/* Process shell messages */
Ret = (LRESULT)TaskSwitchWnd_HandleShellHookMsg(This,
wParam,
lParam);
break;
}
Ret = DefWindowProc(hwnd,
uMsg,
wParam,
lParam);
break;
}
}
return Ret;
}
HWND
CreateTaskSwitchWnd(IN HWND hWndParent,
IN OUT ITrayWindow *Tray)
{
HWND hwndTaskBar;
hwndTaskBar = CreateWindowEx(0,
szTaskSwitchWndClass,
szRunningApps,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
0,
0,
0,
0,
hWndParent,
NULL,
hExplorerInstance,
(LPVOID)Tray);
return hwndTaskBar;
}
BOOL
RegisterTaskSwitchWndClass(VOID)
{
WNDCLASS wc;
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = TaskSwitchWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(PTASK_SWITCH_WND);
wc.hInstance = hExplorerInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,
IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szTaskSwitchWndClass;
return RegisterClass(&wc) != 0;
}
VOID
UnregisterTaskSwitchWndClass(VOID)
{
UnregisterClass(szTaskSwitchWndClass,
hExplorerInstance);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -