eeeb419645
Adds drag-and-drop reordering support to toolbar/status-bar customization dialogs, including drag images, insertion markers, and shared drag callbacks for add/remove/move actions. Refactors ToolStatus command bar rendering and menu bar behavior: introduces shared toolbar/menu drawing helpers, better accelerator visibility handling, improved keyboard/menu tracking, and consistent themed/light rendering. Also fixes DPI/layout behavior by centralizing command-bar height calculations and updating rebar/graph/search band sizing so rows resize correctly across DPI/font changes. Includes related robustness fixes such as linking gdiplus, correcting tab-info hashtable storage to use stable pointers, and updating signatures/prototypes for const-correctness and shared exports.
1405 lines
45 KiB
C
1405 lines
45 KiB
C
/*
|
|
* Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved.
|
|
*
|
|
* This file is part of System Informer.
|
|
*
|
|
* Authors:
|
|
*
|
|
* dmex 2015-2026
|
|
*
|
|
*/
|
|
|
|
#include "toolstatus.h"
|
|
#include "commonutil.h"
|
|
|
|
static CONST PCWSTR CustomizeTextOptionsStrings[] =
|
|
{
|
|
L"No text labels",
|
|
L"Selective text",
|
|
L"Show text labels"
|
|
};
|
|
|
|
static CONST PCWSTR CustomizeSearchDisplayStrings[] =
|
|
{
|
|
L"Always show",
|
|
L"Hide when inactive (Ctrl+K)",
|
|
// L"Auto-hide"
|
|
};
|
|
|
|
BOOLEAN CustomizeToolbarItemExists(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG Command
|
|
)
|
|
{
|
|
LONG index = 0;
|
|
LONG count = 0;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if ((count = ListBox_GetCount(Context->CurrentListHandle)) == LB_ERR)
|
|
return FALSE;
|
|
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
if (!(button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->CurrentListHandle, index)))
|
|
continue;
|
|
|
|
if (button->IdCommand == Command)
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
VOID CustomizeInsertToolbarButton(
|
|
_In_ LONG Index,
|
|
_In_ PBUTTON_CONTEXT ItemContext
|
|
)
|
|
{
|
|
TBBUTTON button;
|
|
|
|
memset(&button, 0, sizeof(TBBUTTON));
|
|
button.idCommand = ItemContext->IdCommand;
|
|
button.iBitmap = I_IMAGECALLBACK;
|
|
button.fsState = TBSTATE_ENABLED;
|
|
button.iString = (INT_PTR)(PVOID)ToolbarGetText(ItemContext->IdCommand);
|
|
|
|
if (ItemContext->IsSeparator)
|
|
{
|
|
button.fsStyle = BTNS_SEP;
|
|
}
|
|
else
|
|
{
|
|
switch (DisplayStyle)
|
|
{
|
|
case TOOLBAR_DISPLAY_STYLE_IMAGEONLY:
|
|
button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
|
break;
|
|
case TOOLBAR_DISPLAY_STYLE_SELECTIVETEXT:
|
|
{
|
|
switch (button.idCommand)
|
|
{
|
|
case PHAPP_ID_VIEW_REFRESH:
|
|
case PHAPP_ID_HACKER_OPTIONS:
|
|
case PHAPP_ID_HACKER_FINDHANDLESORDLLS:
|
|
case PHAPP_ID_VIEW_SYSTEMINFORMATION:
|
|
button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
|
|
break;
|
|
default:
|
|
button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case TOOLBAR_DISPLAY_STYLE_ALLTEXT:
|
|
button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
|
|
break;
|
|
}
|
|
}
|
|
|
|
SendMessage(ToolBarHandle, TB_INSERTBUTTON, Index, (LPARAM)&button);
|
|
}
|
|
|
|
VOID CustomizeAddToolbarItem(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG IndexFrom,
|
|
_In_ LONG IndexTo
|
|
)
|
|
{
|
|
LONG count;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if ((count = ListBox_GetCount(Context->AvailableListHandle)) == LB_ERR)
|
|
return;
|
|
|
|
if (!(button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->AvailableListHandle, IndexFrom)))
|
|
return;
|
|
|
|
if (IndexFrom != 0) // index 0 is separator
|
|
{
|
|
// remove from 'available' list
|
|
ListBox_DeleteString(Context->AvailableListHandle, IndexFrom);
|
|
|
|
if (IndexFrom == count - 1)
|
|
{
|
|
ListBox_SetCurSel(Context->AvailableListHandle, IndexFrom - 1);
|
|
}
|
|
else
|
|
{
|
|
ListBox_SetCurSel(Context->AvailableListHandle, IndexFrom);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
button = PhAllocateZero(sizeof(BUTTON_CONTEXT));
|
|
button->IsSeparator = TRUE;
|
|
button->IsRemovable = TRUE;
|
|
}
|
|
|
|
// insert into 'current' list
|
|
ListBox_InsertItemData(Context->CurrentListHandle, IndexTo, button);
|
|
|
|
CustomizeInsertToolbarButton(IndexTo, button);
|
|
}
|
|
|
|
VOID CustomizeRemoveToolbarItem(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG IndexFrom
|
|
)
|
|
{
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if (!(button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->CurrentListHandle, IndexFrom)))
|
|
return;
|
|
|
|
ListBox_DeleteString(Context->CurrentListHandle, IndexFrom);
|
|
ListBox_SetCurSel(Context->CurrentListHandle, IndexFrom);
|
|
|
|
SendMessage(ToolBarHandle, TB_DELETEBUTTON, IndexFrom, 0);
|
|
|
|
if (button->IsSeparator)
|
|
{
|
|
PhFree(button);
|
|
}
|
|
else
|
|
{
|
|
// insert into 'available' list
|
|
ListBox_AddItemData(Context->AvailableListHandle, button);
|
|
}
|
|
|
|
SendMessage(Context->WindowHandle, WM_COMMAND, MAKEWPARAM(IDC_CURRENT, LBN_SELCHANGE), 0);
|
|
}
|
|
|
|
VOID CustomizeMoveToolbarItem(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG IndexFrom,
|
|
_In_ LONG IndexTo
|
|
)
|
|
{
|
|
LONG count;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if (IndexFrom == IndexTo)
|
|
return;
|
|
|
|
if ((count = ListBox_GetCount(Context->CurrentListHandle)) == LB_ERR)
|
|
return;
|
|
|
|
if (!(button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->CurrentListHandle, IndexFrom)))
|
|
return;
|
|
|
|
ListBox_DeleteString(Context->CurrentListHandle, IndexFrom);
|
|
ListBox_InsertItemData(Context->CurrentListHandle, IndexTo, button);
|
|
ListBox_SetCurSel(Context->CurrentListHandle, IndexTo);
|
|
|
|
if (IndexTo <= 0)
|
|
{
|
|
Button_Enable(Context->MoveUpButtonHandle, FALSE);
|
|
}
|
|
else
|
|
{
|
|
Button_Enable(Context->MoveUpButtonHandle, TRUE);
|
|
}
|
|
|
|
// last item is always separator
|
|
if (IndexTo >= (count - 2))
|
|
{
|
|
Button_Enable(Context->MoveDownButtonHandle, FALSE);
|
|
}
|
|
else
|
|
{
|
|
Button_Enable(Context->MoveDownButtonHandle, TRUE);
|
|
}
|
|
|
|
SendMessage(ToolBarHandle, TB_DELETEBUTTON, IndexFrom, 0);
|
|
|
|
CustomizeInsertToolbarButton(IndexTo, button);
|
|
}
|
|
|
|
VOID CustomizeFreeToolbarItems(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
LONG i = 0;
|
|
LONG count = 0;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if ((count = ListBox_GetCount(Context->CurrentListHandle)) != LB_ERR)
|
|
{
|
|
for (i = 0; i < count; i++)
|
|
{
|
|
if (button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->CurrentListHandle, i))
|
|
{
|
|
if (button->IconHandle)
|
|
{
|
|
DestroyIcon(button->IconHandle);
|
|
}
|
|
|
|
PhFree(button);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((count = ListBox_GetCount(Context->AvailableListHandle)) != LB_ERR)
|
|
{
|
|
for (i = 0; i < count; i++)
|
|
{
|
|
if (button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->AvailableListHandle, i))
|
|
{
|
|
if (button->IconHandle)
|
|
{
|
|
DestroyIcon(button->IconHandle);
|
|
}
|
|
|
|
PhFree(button);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
VOID CustomizeLoadToolbarItems(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
LONG index = 0;
|
|
LONG count = 0;
|
|
PBUTTON_CONTEXT context;
|
|
|
|
CustomizeFreeToolbarItems(Context);
|
|
|
|
ListBox_ResetContent(Context->AvailableListHandle);
|
|
ListBox_ResetContent(Context->CurrentListHandle);
|
|
|
|
count = (LONG)SendMessage(ToolBarHandle, TB_BUTTONCOUNT, 0, 0);
|
|
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
TBBUTTON button;
|
|
|
|
memset(&button, 0, sizeof(TBBUTTON));
|
|
|
|
if (SendMessage(ToolBarHandle, TB_GETBUTTON, index, (LPARAM)&button))
|
|
{
|
|
context = PhAllocateZero(sizeof(BUTTON_CONTEXT));
|
|
context->IsVirtual = FALSE;
|
|
context->IsRemovable = TRUE;
|
|
context->IdCommand = button.idCommand;
|
|
|
|
if (button.fsStyle & BTNS_SEP)
|
|
{
|
|
context->IsSeparator = TRUE;
|
|
}
|
|
else
|
|
{
|
|
context->IconHandle = CustomizeGetToolbarIcon(Context, context->IdCommand, Context->WindowDpi);
|
|
}
|
|
|
|
ListBox_AddItemData(Context->CurrentListHandle, context);
|
|
}
|
|
}
|
|
|
|
for (index = 0; index < MAX_TOOLBAR_ITEMS; index++)
|
|
{
|
|
TBBUTTON button = ToolbarButtons[index];
|
|
|
|
if (button.idCommand == 0)
|
|
continue;
|
|
|
|
if (CustomizeToolbarItemExists(Context, button.idCommand))
|
|
continue;
|
|
|
|
context = PhAllocateZero(sizeof(BUTTON_CONTEXT));
|
|
context->IsRemovable = TRUE;
|
|
context->IdCommand = button.idCommand;
|
|
context->IconHandle = CustomizeGetToolbarIcon(Context, button.idCommand, Context->WindowDpi);
|
|
|
|
ListBox_AddItemData(Context->AvailableListHandle, context);
|
|
}
|
|
|
|
// Append separator to the last 'current list' position
|
|
context = PhAllocateZero(sizeof(BUTTON_CONTEXT));
|
|
context->IsSeparator = TRUE;
|
|
context->IsVirtual = TRUE;
|
|
context->IsRemovable = FALSE;
|
|
|
|
index = ListBox_AddItemData(Context->CurrentListHandle, context);
|
|
ListBox_SetCurSel(Context->CurrentListHandle, index);
|
|
ListBox_SetTopIndex(Context->CurrentListHandle, index);
|
|
|
|
// Insert separator into first 'available list' position
|
|
context = PhAllocateZero(sizeof(BUTTON_CONTEXT));
|
|
context->IsSeparator = TRUE;
|
|
context->IsVirtual = FALSE;
|
|
context->IsRemovable = FALSE;
|
|
|
|
index = ListBox_InsertItemData(Context->AvailableListHandle, 0, context);
|
|
ListBox_SetCurSel(Context->AvailableListHandle, index);
|
|
ListBox_SetTopIndex(Context->AvailableListHandle, index);
|
|
|
|
// Disable buttons
|
|
Button_Enable(Context->MoveUpButtonHandle, FALSE);
|
|
Button_Enable(Context->MoveDownButtonHandle, FALSE);
|
|
Button_Enable(Context->AddButtonHandle, FALSE);
|
|
Button_Enable(Context->RemoveButtonHandle, FALSE);
|
|
}
|
|
|
|
VOID CustomizeLoadToolbarSettings(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
HWND toolbarCombo = GetDlgItem(Context->WindowHandle, IDC_TEXTOPTIONS);
|
|
HWND searchboxCombo = GetDlgItem(Context->WindowHandle, IDC_SEARCHOPTIONS);
|
|
|
|
PhAddComboBoxStrings(toolbarCombo, (PCWSTR*)CustomizeTextOptionsStrings, RTL_NUMBER_OF(CustomizeTextOptionsStrings));
|
|
PhAddComboBoxStrings(searchboxCombo, (PCWSTR*)CustomizeSearchDisplayStrings, RTL_NUMBER_OF(CustomizeSearchDisplayStrings));
|
|
|
|
ComboBox_SetCurSel(toolbarCombo, PhGetIntegerSetting(SETTING_NAME_TOOLBARDISPLAYSTYLE));
|
|
ComboBox_SetCurSel(searchboxCombo, PhGetIntegerSetting(SETTING_NAME_SEARCHBOXDISPLAYMODE));
|
|
|
|
Button_SetCheck(GetDlgItem(Context->WindowHandle, IDC_ENABLE_MODERN),
|
|
ToolStatusConfig.ModernIcons ? BST_CHECKED : BST_UNCHECKED);
|
|
Button_SetCheck(GetDlgItem(Context->WindowHandle, IDC_ENABLE_AUTOHIDE_MENU),
|
|
ToolStatusConfig.AutoHideMenu ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
if (!ToolStatusConfig.SearchBoxEnabled)
|
|
{
|
|
ComboBox_Enable(searchboxCombo, FALSE);
|
|
}
|
|
}
|
|
|
|
VOID CustomizeResetImages(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
LONG index = 0;
|
|
LONG count = 0;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if ((count = ListBox_GetCount(Context->CurrentListHandle)) != LB_ERR)
|
|
{
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
if (button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->CurrentListHandle, index))
|
|
{
|
|
if (button->IdCommand != 0)
|
|
{
|
|
if (button->IconHandle)
|
|
{
|
|
DestroyIcon(button->IconHandle);
|
|
button->IconHandle = NULL;
|
|
}
|
|
|
|
button->IconHandle = CustomizeGetToolbarIcon(Context, button->IdCommand, Context->WindowDpi);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((count = ListBox_GetCount(Context->AvailableListHandle)) != LB_ERR)
|
|
{
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
if (button = (PBUTTON_CONTEXT)ListBox_GetItemData(Context->AvailableListHandle, index))
|
|
{
|
|
if (button->IdCommand != 0)
|
|
{
|
|
if (button->IconHandle)
|
|
{
|
|
DestroyIcon(button->IconHandle);
|
|
button->IconHandle = NULL;
|
|
}
|
|
|
|
button->IconHandle = CustomizeGetToolbarIcon(Context, button->IdCommand, Context->WindowDpi);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
InvalidateRect(Context->AvailableListHandle, NULL, TRUE);
|
|
InvalidateRect(Context->CurrentListHandle, NULL, TRUE);
|
|
}
|
|
|
|
HICON CustomizeGetToolbarIcon(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG CommandID,
|
|
_In_ LONG DpiValue
|
|
)
|
|
{
|
|
HICON iconHandle = NULL;
|
|
HBITMAP bitmapHandle;
|
|
|
|
if (bitmapHandle = ToolbarGetImage(CommandID, DpiValue))
|
|
{
|
|
iconHandle = CommonBitmapToIcon(bitmapHandle, ToolBarImageSize.cx, ToolBarImageSize.cy);
|
|
DeleteBitmap(bitmapHandle);
|
|
}
|
|
|
|
return iconHandle;
|
|
}
|
|
|
|
VOID CustomizeResetToolbarImages(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
// Reset the image cache with the new icons.
|
|
// TODO: Move function to Toolbar.c
|
|
for (ULONG index = 0; index < RTL_NUMBER_OF(ToolbarButtons); index++)
|
|
{
|
|
if (ToolbarButtons[index].iBitmap != I_IMAGECALLBACK && !FlagOn(ToolbarButtons[index].fsStyle, BTNS_SEP))
|
|
{
|
|
HBITMAP bitmap;
|
|
|
|
if (bitmap = ToolbarGetImage(ToolbarButtons[index].idCommand, Context->WindowDpi))
|
|
{
|
|
PhImageListReplace(
|
|
ToolBarImageList,
|
|
ToolbarButtons[index].iBitmap,
|
|
bitmap,
|
|
NULL
|
|
);
|
|
|
|
DeleteBitmap(bitmap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static VOID CustomizeSetDragInsert(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG ItemIndex
|
|
)
|
|
{
|
|
RECT itemRect;
|
|
BOOLEAN dragImageActive;
|
|
|
|
// Only hide the drag image when the insert position changes. (Hiding and showing it on every DL_DRAGGING causes flicker.)
|
|
if (Context->DragInsertIndex == ItemIndex)
|
|
return;
|
|
|
|
dragImageActive = !!Context->DragImageList;
|
|
|
|
if (dragImageActive)
|
|
PhImageListDragShowNolock(FALSE);
|
|
|
|
if (Context->DragInsertIndex != LB_ERR &&
|
|
ListBox_GetItemRect(Context->CurrentListHandle, Context->DragInsertIndex, &itemRect) != LB_ERR)
|
|
{
|
|
InvalidateRect(Context->CurrentListHandle, &itemRect, FALSE);
|
|
}
|
|
|
|
Context->DragInsertIndex = ItemIndex;
|
|
|
|
if (Context->DragInsertIndex != LB_ERR &&
|
|
ListBox_GetItemRect(Context->CurrentListHandle, Context->DragInsertIndex, &itemRect) != LB_ERR)
|
|
{
|
|
InvalidateRect(Context->CurrentListHandle, &itemRect, FALSE);
|
|
}
|
|
|
|
UpdateWindow(Context->CurrentListHandle);
|
|
|
|
if (dragImageActive)
|
|
PhImageListDragShowNolock(TRUE);
|
|
}
|
|
|
|
static HIMAGELIST CustomizeCreateDragImage(
|
|
_In_ HWND ListBoxHandle,
|
|
_In_ LONG ItemIndex,
|
|
_In_ POINT CursorPosition,
|
|
_Out_ PPOINT Hotspot,
|
|
_Out_ PLONG ImageWidth,
|
|
_Out_ PLONG ImageHeight
|
|
)
|
|
{
|
|
RECT itemRect;
|
|
POINT clientPoint;
|
|
LONG width;
|
|
LONG height;
|
|
HDC windowDc;
|
|
HDC bufferDc;
|
|
HBITMAP bitmap;
|
|
HBITMAP oldBitmap;
|
|
HIMAGELIST imageList;
|
|
|
|
Hotspot->x = 0;
|
|
Hotspot->y = 0;
|
|
*ImageWidth = 0;
|
|
*ImageHeight = 0;
|
|
|
|
if (ListBox_GetItemRect(ListBoxHandle, ItemIndex, &itemRect) == LB_ERR)
|
|
return NULL;
|
|
|
|
width = itemRect.right - itemRect.left;
|
|
height = itemRect.bottom - itemRect.top;
|
|
|
|
if (width <= 0 || height <= 0)
|
|
return NULL;
|
|
|
|
clientPoint = CursorPosition;
|
|
|
|
if (!ScreenToClient(ListBoxHandle, &clientPoint))
|
|
return NULL;
|
|
|
|
if (!(windowDc = GetDC(ListBoxHandle)))
|
|
return NULL;
|
|
|
|
bufferDc = CreateCompatibleDC(windowDc);
|
|
bitmap = PhCreateDIBSection(windowDc, PHBF_TOPDOWNDIB, width, height, NULL);
|
|
|
|
if (!bufferDc || !bitmap)
|
|
{
|
|
if (bitmap)
|
|
DeleteBitmap(bitmap);
|
|
if (bufferDc)
|
|
DeleteDC(bufferDc);
|
|
|
|
ReleaseDC(ListBoxHandle, windowDc);
|
|
return NULL;
|
|
}
|
|
|
|
oldBitmap = SelectBitmap(bufferDc, bitmap);
|
|
BitBlt(bufferDc, 0, 0, width, height, windowDc, itemRect.left, itemRect.top, SRCCOPY);
|
|
SelectBitmap(bufferDc, oldBitmap);
|
|
DeleteDC(bufferDc);
|
|
ReleaseDC(ListBoxHandle, windowDc);
|
|
|
|
imageList = PhImageListCreate(width, height, ILC_COLOR32, 1, 0);
|
|
|
|
if (!imageList || PhImageListAddBitmap(imageList, bitmap, NULL) == INT_ERROR)
|
|
{
|
|
if (imageList)
|
|
PhImageListDestroy(imageList);
|
|
|
|
DeleteBitmap(bitmap);
|
|
return NULL;
|
|
}
|
|
|
|
DeleteBitmap(bitmap);
|
|
|
|
Hotspot->x = clientPoint.x - itemRect.left;
|
|
Hotspot->y = clientPoint.y - itemRect.top;
|
|
*ImageWidth = width;
|
|
*ImageHeight = height;
|
|
|
|
return imageList;
|
|
}
|
|
|
|
static BOOLEAN CustomizeGetDragWindowPoint(
|
|
_In_ HWND WindowHandle,
|
|
_In_ POINT ScreenPoint,
|
|
_In_ LONG ImageWidth,
|
|
_In_ LONG ImageHeight,
|
|
_In_ POINT Hotspot,
|
|
_Out_ PPOINT WindowPoint
|
|
)
|
|
{
|
|
RECT windowRect;
|
|
RECT clientRect;
|
|
POINT clientOrigin = { 0, 0 };
|
|
LONG minimumX;
|
|
LONG maximumX;
|
|
LONG minimumY;
|
|
LONG maximumY;
|
|
|
|
if (!GetWindowRect(WindowHandle, &windowRect) ||
|
|
!GetClientRect(WindowHandle, &clientRect) ||
|
|
!ClientToScreen(WindowHandle, &clientOrigin))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
WindowPoint->x = ScreenPoint.x - windowRect.left;
|
|
WindowPoint->y = ScreenPoint.y - windowRect.top;
|
|
|
|
// Keep the drag image inside the client area.
|
|
minimumX = clientOrigin.x - windowRect.left + Hotspot.x;
|
|
maximumX = minimumX + clientRect.right - ImageWidth;
|
|
minimumY = clientOrigin.y - windowRect.top + Hotspot.y;
|
|
maximumY = minimumY + clientRect.bottom - ImageHeight;
|
|
|
|
if (maximumX < minimumX || WindowPoint->x < minimumX)
|
|
WindowPoint->x = minimumX;
|
|
else if (WindowPoint->x > maximumX)
|
|
WindowPoint->x = maximumX;
|
|
|
|
if (maximumY < minimumY || WindowPoint->y < minimumY)
|
|
WindowPoint->y = minimumY;
|
|
else if (WindowPoint->y > maximumY)
|
|
WindowPoint->y = maximumY;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static VOID CustomizeDestroyDragImage(
|
|
_In_ PCUSTOMIZE_CONTEXT Context
|
|
)
|
|
{
|
|
HIMAGELIST imageList;
|
|
|
|
if (!(imageList = Context->DragImageList))
|
|
return;
|
|
|
|
Context->DragImageList = NULL;
|
|
|
|
PhImageListDragLeave(Context->WindowHandle);
|
|
PhImageListEndDrag();
|
|
PhImageListDestroy(imageList);
|
|
}
|
|
|
|
// Returns the row under the cursor, the count when the cursor is inside the
|
|
// list box but below the last item, or LB_ERR when outside.
|
|
static LONG CustomizeDragTargetIndex(
|
|
_In_ HWND ListBoxHandle,
|
|
_In_ POINT Point,
|
|
_In_ BOOLEAN AutoScroll
|
|
)
|
|
{
|
|
LONG index;
|
|
RECT rect;
|
|
|
|
if ((index = LBItemFromPt(ListBoxHandle, Point, AutoScroll)) == LB_ERR)
|
|
{
|
|
GetWindowRect(ListBoxHandle, &rect);
|
|
|
|
if (PtInRect(&rect, Point))
|
|
index = ListBox_GetCount(ListBoxHandle);
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
// Clamps an insert row in the current list so items are never placed after the virtual separator.
|
|
static LONG CustomizeClampCurrentInsertIndex(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LONG Index
|
|
)
|
|
{
|
|
LONG count = ListBox_GetCount(Context->CurrentListHandle);
|
|
|
|
if (count <= 0)
|
|
return 0;
|
|
|
|
return min(Index, count - 1);
|
|
}
|
|
|
|
VOID CustomizeDrawDragInsert(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LPDRAWITEMSTRUCT DrawInfo
|
|
)
|
|
{
|
|
RECT lineRect;
|
|
COLORREF oldColor;
|
|
|
|
if (DrawInfo->hwndItem != Context->CurrentListHandle ||
|
|
Context->DragInsertIndex == LB_ERR ||
|
|
(LONG)DrawInfo->itemID != Context->DragInsertIndex)
|
|
{
|
|
return;
|
|
}
|
|
|
|
lineRect = DrawInfo->rcItem;
|
|
lineRect.bottom = lineRect.top + PhScaleToDisplay(2, Context->WindowDpi);
|
|
|
|
oldColor = SetDCBrushColor(
|
|
DrawInfo->hDC,
|
|
PhGetIntegerSetting(SETTING_ENABLE_THEME_SUPPORT) ?
|
|
(COLORREF)PhGetIntegerSetting(SETTING_THEME_WINDOW_HIGHLIGHT_COLOR) :
|
|
GetSysColor(COLOR_HIGHLIGHT)
|
|
);
|
|
FillRect(DrawInfo->hDC, &lineRect, GetStockBrush(DC_BRUSH));
|
|
SetDCBrushColor(DrawInfo->hDC, oldColor);
|
|
}
|
|
|
|
LRESULT CustomizeDragListNotify(
|
|
_In_ PCUSTOMIZE_CONTEXT Context,
|
|
_In_ LPDRAGLISTINFO DragInfo,
|
|
_In_ PCUSTOMIZE_DRAG_CALLBACKS Callbacks
|
|
)
|
|
{
|
|
LRESULT result = 0;
|
|
|
|
switch (DragInfo->uNotification)
|
|
{
|
|
case DL_BEGINDRAG:
|
|
{
|
|
LONG index = LBItemFromPt(DragInfo->hWnd, DragInfo->ptCursor, FALSE);
|
|
POINT windowPoint;
|
|
POINT hotspot;
|
|
LONG imageWidth;
|
|
LONG imageHeight;
|
|
HIMAGELIST imageList;
|
|
PBUTTON_CONTEXT button;
|
|
|
|
if (index == LB_ERR)
|
|
break;
|
|
|
|
// Virtual items (the trailing placeholders) can't be moved.
|
|
if (!(button = (PBUTTON_CONTEXT)ListBox_GetItemData(DragInfo->hWnd, index)) || button->IsVirtual)
|
|
break;
|
|
|
|
Context->DragSourceHandle = DragInfo->hWnd;
|
|
Context->DragItemIndex = index;
|
|
ListBox_SetCurSel(DragInfo->hWnd, index);
|
|
UpdateWindow(DragInfo->hWnd);
|
|
|
|
if (imageList = CustomizeCreateDragImage(
|
|
DragInfo->hWnd,
|
|
index,
|
|
DragInfo->ptCursor,
|
|
&hotspot,
|
|
&imageWidth,
|
|
&imageHeight
|
|
))
|
|
{
|
|
BOOLEAN dragStarted = FALSE;
|
|
|
|
if (CustomizeGetDragWindowPoint(Context->WindowHandle, DragInfo->ptCursor, imageWidth, imageHeight, hotspot, &windowPoint))
|
|
{
|
|
if (PhImageListBeginDrag(imageList, 0, hotspot.x, hotspot.y))
|
|
{
|
|
dragStarted = TRUE;
|
|
|
|
if (PhImageListDragEnter(Context->WindowHandle, windowPoint.x, windowPoint.y))
|
|
{
|
|
Context->DragImageList = imageList;
|
|
Context->DragImageHotspot = hotspot;
|
|
Context->DragImageWidth = imageWidth;
|
|
Context->DragImageHeight = imageHeight;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!Context->DragImageList)
|
|
{
|
|
if (dragStarted)
|
|
PhImageListEndDrag();
|
|
|
|
PhImageListDestroy(imageList);
|
|
}
|
|
}
|
|
|
|
result = TRUE;
|
|
}
|
|
break;
|
|
case DL_DRAGGING:
|
|
{
|
|
LONG currentIndex = CustomizeDragTargetIndex(Context->CurrentListHandle, DragInfo->ptCursor, TRUE);
|
|
LONG availableIndex = CustomizeDragTargetIndex(Context->AvailableListHandle, DragInfo->ptCursor, FALSE);
|
|
|
|
if (currentIndex != LB_ERR)
|
|
{
|
|
CustomizeSetDragInsert(Context, CustomizeClampCurrentInsertIndex(Context, currentIndex));
|
|
result = DL_MOVECURSOR;
|
|
}
|
|
else if (availableIndex != LB_ERR && Context->DragSourceHandle == Context->CurrentListHandle)
|
|
{
|
|
// Dropping on the available list removes the item, there's no insert position to show.
|
|
CustomizeSetDragInsert(Context, LB_ERR);
|
|
result = DL_MOVECURSOR;
|
|
}
|
|
else
|
|
{
|
|
CustomizeSetDragInsert(Context, LB_ERR);
|
|
result = DL_STOPCURSOR;
|
|
}
|
|
|
|
if (Context->DragImageList)
|
|
{
|
|
POINT windowPoint;
|
|
|
|
if (CustomizeGetDragWindowPoint(
|
|
Context->WindowHandle,
|
|
DragInfo->ptCursor,
|
|
Context->DragImageWidth,
|
|
Context->DragImageHeight,
|
|
Context->DragImageHotspot,
|
|
&windowPoint
|
|
))
|
|
{
|
|
PhImageListDragMove(windowPoint.x, windowPoint.y);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case DL_DROPPED:
|
|
{
|
|
LONG currentIndex = CustomizeDragTargetIndex(Context->CurrentListHandle, DragInfo->ptCursor, FALSE);
|
|
LONG availableIndex = CustomizeDragTargetIndex(Context->AvailableListHandle, DragInfo->ptCursor, FALSE);
|
|
|
|
CustomizeSetDragInsert(Context, LB_ERR);
|
|
CustomizeDestroyDragImage(Context);
|
|
|
|
if (Context->DragItemIndex != LB_ERR)
|
|
{
|
|
if (Context->DragSourceHandle == Context->CurrentListHandle)
|
|
{
|
|
if (currentIndex != LB_ERR)
|
|
{
|
|
// The insert row is before the item at that row, translate it to the final index.
|
|
LONG insertIndex = CustomizeClampCurrentInsertIndex(Context, currentIndex);
|
|
|
|
if (insertIndex > Context->DragItemIndex)
|
|
insertIndex--;
|
|
|
|
Callbacks->MoveItem(Context, Context->DragItemIndex, insertIndex);
|
|
}
|
|
else if (availableIndex != LB_ERR)
|
|
{
|
|
Callbacks->RemoveItem(Context, Context->DragItemIndex);
|
|
}
|
|
}
|
|
else if (Context->DragSourceHandle == Context->AvailableListHandle)
|
|
{
|
|
if (currentIndex != LB_ERR)
|
|
{
|
|
LONG insertIndex = CustomizeClampCurrentInsertIndex(Context, currentIndex);
|
|
|
|
Callbacks->AddItem(Context, Context->DragItemIndex, insertIndex);
|
|
ListBox_SetCurSel(Context->CurrentListHandle, insertIndex);
|
|
SendMessage(Context->WindowHandle, WM_COMMAND, MAKEWPARAM(IDC_CURRENT, LBN_SELCHANGE), 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
Context->DragSourceHandle = NULL;
|
|
Context->DragItemIndex = LB_ERR;
|
|
}
|
|
break;
|
|
case DL_CANCELDRAG:
|
|
{
|
|
CustomizeSetDragInsert(Context, LB_ERR);
|
|
CustomizeDestroyDragImage(Context);
|
|
Context->DragSourceHandle = NULL;
|
|
Context->DragItemIndex = LB_ERR;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
INT_PTR CALLBACK CustomizeToolbarDialogProc(
|
|
_In_ HWND WindowHandle,
|
|
_In_ UINT WindowMessage,
|
|
_In_ WPARAM wParam,
|
|
_In_ LPARAM lParam
|
|
)
|
|
{
|
|
PCUSTOMIZE_CONTEXT context = NULL;
|
|
|
|
if (WindowMessage == WM_INITDIALOG)
|
|
{
|
|
context = PhAllocate(sizeof(CUSTOMIZE_CONTEXT));
|
|
memset(context, 0, sizeof(CUSTOMIZE_CONTEXT));
|
|
|
|
PhSetWindowContext(WindowHandle, PH_WINDOW_CONTEXT_DEFAULT, context);
|
|
}
|
|
else
|
|
{
|
|
context = PhGetWindowContext(WindowHandle, PH_WINDOW_CONTEXT_DEFAULT);
|
|
}
|
|
|
|
if (context == NULL)
|
|
return FALSE;
|
|
|
|
switch (WindowMessage)
|
|
{
|
|
case WM_INITDIALOG:
|
|
{
|
|
context->WindowHandle = WindowHandle;
|
|
context->AvailableListHandle = GetDlgItem(WindowHandle, IDC_AVAILABLE);
|
|
context->CurrentListHandle = GetDlgItem(WindowHandle, IDC_CURRENT);
|
|
context->MoveUpButtonHandle = GetDlgItem(WindowHandle, IDC_MOVEUP);
|
|
context->MoveDownButtonHandle = GetDlgItem(WindowHandle, IDC_MOVEDOWN);
|
|
context->AddButtonHandle = GetDlgItem(WindowHandle, IDC_ADD);
|
|
context->RemoveButtonHandle = GetDlgItem(WindowHandle, IDC_REMOVE);
|
|
|
|
context->WindowDpi = PhGetWindowDpi(WindowHandle);
|
|
context->FontHandle = PhCreateIconTitleFont(context->WindowDpi);
|
|
context->CXWidth = PhScaleToDisplay(16, context->WindowDpi);
|
|
|
|
if (PhGetIntegerSetting(SETTING_ENABLE_THEME_SUPPORT))
|
|
{
|
|
context->BrushNormal = CreateSolidBrush(PhGetIntegerSetting(SETTING_THEME_WINDOW_BACKGROUND_COLOR));
|
|
context->BrushHot = CreateSolidBrush(PhGetIntegerSetting(SETTING_THEME_WINDOW_HIGHLIGHT_COLOR));
|
|
context->BrushPushed = CreateSolidBrush(PhGetIntegerSetting(SETTING_THEME_WINDOW_HIGHLIGHT2_COLOR));
|
|
context->TextColor = PhGetIntegerSetting(SETTING_THEME_WINDOW_TEXT_COLOR);
|
|
}
|
|
else
|
|
{
|
|
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
|
|
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
|
|
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
|
|
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);
|
|
}
|
|
|
|
PhSetApplicationWindowIcon(WindowHandle);
|
|
|
|
PhCenterWindow(WindowHandle, GetParent(WindowHandle));
|
|
|
|
ListBox_SetItemHeight(context->AvailableListHandle, 0, context->CXWidth + 6); // BitmapHeight
|
|
ListBox_SetItemHeight(context->CurrentListHandle, 0, context->CXWidth + 6); // BitmapHeight
|
|
|
|
context->DragListMessage = RegisterWindowMessage(DRAGLISTMSGSTRING);
|
|
context->DragItemIndex = LB_ERR;
|
|
context->DragInsertIndex = LB_ERR;
|
|
MakeDragList(context->AvailableListHandle);
|
|
MakeDragList(context->CurrentListHandle);
|
|
|
|
CustomizeLoadToolbarItems(context);
|
|
CustomizeLoadToolbarSettings(context);
|
|
|
|
PhInitializeWindowTheme(WindowHandle, !!PhGetIntegerSetting(SETTING_ENABLE_THEME_SUPPORT));
|
|
|
|
PhSetDialogFocus(context->WindowHandle, context->CurrentListHandle);
|
|
}
|
|
break;
|
|
case WM_DESTROY:
|
|
{
|
|
ToolbarSaveButtonSettings();
|
|
ToolbarLoadSettings(FALSE);
|
|
CustomizeFreeToolbarItems(context);
|
|
|
|
if (context->BrushNormal)
|
|
DeleteBrush(context->BrushNormal);
|
|
|
|
if (context->BrushHot)
|
|
DeleteBrush(context->BrushHot);
|
|
|
|
if (context->BrushPushed)
|
|
DeleteBrush(context->BrushPushed);
|
|
|
|
if (context->FontHandle)
|
|
DeleteFont(context->FontHandle);
|
|
}
|
|
break;
|
|
case WM_NCDESTROY:
|
|
{
|
|
PhRemoveWindowContext(WindowHandle, PH_WINDOW_CONTEXT_DEFAULT);
|
|
PhFree(context);
|
|
}
|
|
break;
|
|
case WM_DPICHANGED:
|
|
{
|
|
context->WindowDpi = LOWORD(wParam);
|
|
if (context->FontHandle) DeleteFont(context->FontHandle);
|
|
context->FontHandle = PhCreateIconTitleFont(context->WindowDpi);
|
|
context->CXWidth = PhScaleToDisplay(16, context->WindowDpi);
|
|
ListBox_SetItemHeight(context->AvailableListHandle, 0, context->CXWidth + 6); // BitmapHeight
|
|
ListBox_SetItemHeight(context->CurrentListHandle, 0, context->CXWidth + 6); // BitmapHeight
|
|
|
|
{
|
|
LONG dpi = SystemInformer_GetWindowDpi();
|
|
ToolBarImageSize.cx = PhGetSystemMetrics(SM_CXSMICON, dpi);
|
|
ToolBarImageSize.cy = PhGetSystemMetrics(SM_CYSMICON, dpi);
|
|
}
|
|
|
|
CustomizeResetImages(context);
|
|
}
|
|
break;
|
|
case WM_COMMAND:
|
|
{
|
|
switch (GET_WM_COMMAND_ID(wParam, lParam))
|
|
{
|
|
case IDC_AVAILABLE:
|
|
{
|
|
switch (GET_WM_COMMAND_CMD(wParam, lParam))
|
|
{
|
|
case LBN_SELCHANGE:
|
|
{
|
|
Button_Enable(context->AddButtonHandle, TRUE);
|
|
}
|
|
break;
|
|
case LBN_DBLCLK:
|
|
{
|
|
LONG index;
|
|
LONG indexto;
|
|
|
|
index = ListBox_GetCurSel(context->AvailableListHandle);
|
|
indexto = ListBox_GetCurSel(context->CurrentListHandle);
|
|
|
|
if (index == LB_ERR)
|
|
break;
|
|
|
|
if (indexto == LB_ERR)
|
|
break;
|
|
|
|
CustomizeAddToolbarItem(context, index, indexto);
|
|
}
|
|
break;
|
|
//case LBN_KILLFOCUS:
|
|
// {
|
|
// Button_Enable(context->AddButtonHandle, FALSE);
|
|
// }
|
|
// break;
|
|
}
|
|
}
|
|
break;
|
|
case IDC_CURRENT:
|
|
{
|
|
switch (GET_WM_COMMAND_CMD(wParam, lParam))
|
|
{
|
|
case LBN_SELCHANGE:
|
|
{
|
|
LONG count;
|
|
LONG index;
|
|
PBUTTON_CONTEXT itemContext;
|
|
|
|
if ((count = ListBox_GetCount(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
if ((index = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
if (!(itemContext = (PBUTTON_CONTEXT)ListBox_GetItemData(context->CurrentListHandle, index)))
|
|
break;
|
|
|
|
if (index == 0 && count == 2)
|
|
{
|
|
// first and last item
|
|
Button_Enable(context->MoveUpButtonHandle, FALSE);
|
|
Button_Enable(context->MoveDownButtonHandle, FALSE);
|
|
}
|
|
else if (index == (count - 1))
|
|
{
|
|
// last item (virtual separator)
|
|
Button_Enable(context->MoveUpButtonHandle, FALSE);
|
|
Button_Enable(context->MoveDownButtonHandle, FALSE);
|
|
}
|
|
else if (index == (count - 2))
|
|
{
|
|
// second last item (last non-virtual item)
|
|
Button_Enable(context->MoveUpButtonHandle, TRUE);
|
|
Button_Enable(context->MoveDownButtonHandle, FALSE);
|
|
}
|
|
else if (index == 0)
|
|
{
|
|
// first item
|
|
Button_Enable(context->MoveUpButtonHandle, FALSE);
|
|
Button_Enable(context->MoveDownButtonHandle, TRUE);
|
|
}
|
|
else
|
|
{
|
|
Button_Enable(context->MoveUpButtonHandle, TRUE);
|
|
Button_Enable(context->MoveDownButtonHandle, TRUE);
|
|
}
|
|
|
|
Button_Enable(context->RemoveButtonHandle, itemContext->IsRemovable);
|
|
}
|
|
break;
|
|
case LBN_DBLCLK:
|
|
{
|
|
LONG count;
|
|
LONG index;
|
|
|
|
if ((count = ListBox_GetCount(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
if ((index = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
if (index == (count - 1))
|
|
{
|
|
// virtual separator
|
|
break;
|
|
}
|
|
|
|
CustomizeRemoveToolbarItem(context, index);
|
|
}
|
|
break;
|
|
//case LBN_KILLFOCUS:
|
|
// {
|
|
// Button_Enable(context->MoveUpButtonHandle, FALSE);
|
|
// Button_Enable(context->MoveDownButtonHandle, FALSE);
|
|
// Button_Enable(context->RemoveButtonHandle, FALSE);
|
|
// }
|
|
// break;
|
|
}
|
|
}
|
|
break;
|
|
case IDC_ADD:
|
|
{
|
|
LONG index;
|
|
LONG indexto;
|
|
|
|
if ((index = ListBox_GetCurSel(context->AvailableListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
if ((indexto = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
CustomizeAddToolbarItem(context, index, indexto);
|
|
}
|
|
break;
|
|
case IDC_REMOVE:
|
|
{
|
|
LONG index;
|
|
|
|
if ((index = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
CustomizeRemoveToolbarItem(context, index);
|
|
}
|
|
break;
|
|
case IDC_MOVEUP:
|
|
{
|
|
LONG index;
|
|
|
|
if ((index = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
CustomizeMoveToolbarItem(context, index, index - 1);
|
|
}
|
|
break;
|
|
case IDC_MOVEDOWN:
|
|
{
|
|
LONG index;
|
|
|
|
if ((index = ListBox_GetCurSel(context->CurrentListHandle)) == LB_ERR)
|
|
break;
|
|
|
|
CustomizeMoveToolbarItem(context, index, index + 1);
|
|
}
|
|
break;
|
|
case IDC_RESET:
|
|
{
|
|
// Reset the Toolbar buttons to default settings.
|
|
ToolbarResetSettings();
|
|
// Re-load the settings.
|
|
ToolbarLoadSettings(FALSE);
|
|
// Save as the new defaults.
|
|
ToolbarSaveButtonSettings();
|
|
|
|
CustomizeLoadToolbarItems(context);
|
|
}
|
|
break;
|
|
case IDC_TEXTOPTIONS:
|
|
{
|
|
if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE)
|
|
{
|
|
PhSetIntegerSetting(SETTING_NAME_TOOLBARDISPLAYSTYLE,
|
|
(DisplayStyle = (TOOLBAR_DISPLAY_STYLE)ComboBox_GetCurSel(GET_WM_COMMAND_HWND(wParam, lParam))));
|
|
|
|
ToolbarLoadSettings(FALSE);
|
|
}
|
|
}
|
|
break;
|
|
case IDC_SEARCHOPTIONS:
|
|
{
|
|
if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE)
|
|
{
|
|
PhSetIntegerSetting(SETTING_NAME_SEARCHBOXDISPLAYMODE,
|
|
(SearchBoxDisplayMode = (SEARCHBOX_DISPLAY_MODE)ComboBox_GetCurSel(GET_WM_COMMAND_HWND(wParam, lParam))));
|
|
|
|
ToolbarLoadSettings(FALSE);
|
|
}
|
|
}
|
|
break;
|
|
//case IDC_THEMEOPTIONS:
|
|
// {
|
|
// if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE)
|
|
// {
|
|
// PhSetIntegerSetting(SETTING_NAME_TOOLBAR_THEME,
|
|
// (ToolBarTheme = (TOOLBAR_THEME)ComboBox_GetCurSel(GET_WM_COMMAND_HWND(wParam, lParam))));
|
|
//
|
|
// switch (ToolBarTheme)
|
|
// {
|
|
// case TOOLBAR_THEME_NONE:
|
|
// {
|
|
// SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"");
|
|
// SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"");
|
|
// }
|
|
// break;
|
|
// case TOOLBAR_THEME_BLACK:
|
|
// {
|
|
// SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Media");
|
|
// SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Media");
|
|
// }
|
|
// break;
|
|
// case TOOLBAR_THEME_BLUE:
|
|
// {
|
|
// SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Communications");
|
|
// SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Communications");
|
|
// }
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
// break;
|
|
case IDC_ENABLE_MODERN:
|
|
{
|
|
if (GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED)
|
|
{
|
|
ToolStatusConfig.ModernIcons = Button_GetCheck(GET_WM_COMMAND_HWND(wParam, lParam)) == BST_CHECKED;
|
|
|
|
PhSetIntegerSetting(SETTING_NAME_TOOLSTATUS_CONFIG, ToolStatusConfig.Flags);
|
|
|
|
ToolbarLoadSettings(FALSE);
|
|
|
|
CustomizeResetImages(context);
|
|
CustomizeResetToolbarImages(context);
|
|
//CustomizeLoadItems(context);
|
|
}
|
|
}
|
|
break;
|
|
case IDC_ENABLE_AUTOHIDE_MENU:
|
|
{
|
|
if (GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED)
|
|
{
|
|
ToolStatusConfig.AutoHideMenu = !ToolStatusConfig.AutoHideMenu;
|
|
|
|
PhSetIntegerSetting(SETTING_NAME_TOOLSTATUS_CONFIG, ToolStatusConfig.Flags);
|
|
|
|
ToolStatusApplyMainMenuVisibility(MainWindowHandle);
|
|
}
|
|
}
|
|
break;
|
|
case IDCANCEL:
|
|
{
|
|
EndDialog(WindowHandle, IDCANCEL);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case WM_DRAWITEM:
|
|
{
|
|
LPDRAWITEMSTRUCT drawInfo = (LPDRAWITEMSTRUCT)lParam;
|
|
|
|
if (drawInfo->CtlID == IDC_AVAILABLE || drawInfo->CtlID == IDC_CURRENT)
|
|
{
|
|
HDC bufferDc;
|
|
HBITMAP bufferBitmap;
|
|
HBITMAP oldBufferBitmap;
|
|
PBUTTON_CONTEXT itemContext;
|
|
RECT bufferRect =
|
|
{
|
|
0, 0,
|
|
drawInfo->rcItem.right - drawInfo->rcItem.left,
|
|
drawInfo->rcItem.bottom - drawInfo->rcItem.top
|
|
};
|
|
BOOLEAN isSelected = (drawInfo->itemState & ODS_SELECTED) == ODS_SELECTED;
|
|
BOOLEAN isFocused = (drawInfo->itemState & ODS_FOCUS) == ODS_FOCUS;
|
|
|
|
if (drawInfo->itemID == UINT_MAX)
|
|
break;
|
|
|
|
if (!(itemContext = (PBUTTON_CONTEXT)ListBox_GetItemData(drawInfo->hwndItem, drawInfo->itemID)))
|
|
break;
|
|
|
|
bufferDc = CreateCompatibleDC(drawInfo->hDC);
|
|
bufferBitmap = PhCreateDIBSection(drawInfo->hDC, PHBF_TOPDOWNDIB, bufferRect.right, bufferRect.bottom, NULL);
|
|
|
|
oldBufferBitmap = SelectBitmap(bufferDc, bufferBitmap);
|
|
SelectFont(bufferDc, context->FontHandle);
|
|
SetBkMode(bufferDc, TRANSPARENT);
|
|
|
|
if (isFocused || isSelected)
|
|
FillRect(bufferDc, &bufferRect, context->BrushHot);
|
|
else
|
|
FillRect(bufferDc, &bufferRect, context->BrushNormal);
|
|
|
|
if (!itemContext->IsVirtual)
|
|
SetTextColor(bufferDc, context->TextColor);
|
|
else
|
|
SetTextColor(bufferDc, GetSysColor(COLOR_GRAYTEXT));
|
|
|
|
if (itemContext->IconHandle && !itemContext->IsSeparator)
|
|
{
|
|
DrawIconEx(
|
|
bufferDc,
|
|
bufferRect.left + 2,
|
|
bufferRect.top + ((bufferRect.bottom - bufferRect.top) - context->CXWidth) / 2,
|
|
itemContext->IconHandle,
|
|
context->CXWidth,
|
|
context->CXWidth,
|
|
0,
|
|
NULL,
|
|
DI_NORMAL
|
|
);
|
|
}
|
|
|
|
bufferRect.left += context->CXWidth + 4;
|
|
|
|
if (itemContext->IdCommand != 0)
|
|
{
|
|
PCWSTR stringBuffer = ToolbarGetText(itemContext->IdCommand);
|
|
SIZE_T stringLength = PhCountStringZ(stringBuffer);
|
|
|
|
DrawText(
|
|
bufferDc,
|
|
stringBuffer,
|
|
(LONG)stringLength,
|
|
&bufferRect,
|
|
DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP
|
|
);
|
|
}
|
|
else
|
|
{
|
|
DrawText(
|
|
bufferDc,
|
|
L"Separator",
|
|
sizeof(L"Separator") / sizeof(WCHAR),
|
|
&bufferRect,
|
|
DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP
|
|
);
|
|
}
|
|
|
|
BitBlt(
|
|
drawInfo->hDC,
|
|
drawInfo->rcItem.left,
|
|
drawInfo->rcItem.top,
|
|
drawInfo->rcItem.right,
|
|
drawInfo->rcItem.bottom,
|
|
bufferDc,
|
|
0,
|
|
0,
|
|
SRCCOPY
|
|
);
|
|
|
|
CustomizeDrawDragInsert(context, drawInfo);
|
|
|
|
SelectBitmap(bufferDc, oldBufferBitmap);
|
|
DeleteBitmap(bufferBitmap);
|
|
DeleteDC(bufferDc);
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
case WM_CTLCOLORBTN:
|
|
return HANDLE_WM_CTLCOLORBTN(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
|
|
case WM_CTLCOLORDLG:
|
|
return HANDLE_WM_CTLCOLORDLG(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
|
|
case WM_CTLCOLORSTATIC:
|
|
return HANDLE_WM_CTLCOLORSTATIC(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
|
|
}
|
|
|
|
if (context->DragListMessage && WindowMessage == context->DragListMessage)
|
|
{
|
|
static CUSTOMIZE_DRAG_CALLBACKS callbacks =
|
|
{
|
|
CustomizeAddToolbarItem,
|
|
CustomizeRemoveToolbarItem,
|
|
CustomizeMoveToolbarItem
|
|
};
|
|
LRESULT result = CustomizeDragListNotify(context, (LPDRAGLISTINFO)lParam, &callbacks);
|
|
|
|
SetWindowLongPtr(WindowHandle, DWLP_MSGRESULT, result);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
VOID ToolBarShowCustomizeDialog(
|
|
_In_ HWND ParentWindowHandle
|
|
)
|
|
{
|
|
PhDialogBox(
|
|
PluginInstance->DllBase,
|
|
MAKEINTRESOURCE(IDD_CUSTOMIZE_TB),
|
|
ParentWindowHandle,
|
|
CustomizeToolbarDialogProc,
|
|
NULL
|
|
);
|
|
}
|