Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions Src/ClassicExplorer/ClassicExplorer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -231,32 +231,43 @@ BEGIN
CONTROL "<a>&More...</a>",IDC_LINKMORE,"SysLink",WS_TABSTOP,7,84,45,10
END

IDD_CUSTOMTOOLBAR DIALOGEX 0, 0, 249, 183
IDD_CUSTOMTOOLBAR DIALOGEX 0, 0, 249, 218
STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Edit Toolbar Button (%s)"
FONT 9, "Segoe UI", 400, 0, 0x0
BEGIN
LTEXT "Command:",IDC_STATICCOMMAND,7,7,35,12,SS_CENTERIMAGE
COMBOBOX IDC_COMBOCOMMAND,47,7,180,30,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDC_BUTTONCOMMAND,228,7,14,12

LTEXT "Link:",IDC_STATICLINK,7,23,16,12,SS_CENTERIMAGE
COMBOBOX IDC_COMBOLINK,47,23,180,30,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDC_BUTTONLINK,228,23,14,12

LTEXT "Label:",IDC_STATICTEXT,7,41,22,12,SS_CENTERIMAGE
EDITTEXT IDC_EDITLABEL,47,41,195,12,ES_AUTOHSCROLL

LTEXT "Tip:",IDC_STATICINFOTIP,7,58,13,12,SS_CENTERIMAGE
EDITTEXT IDC_EDITTIP,47,58,195,12,ES_AUTOHSCROLL

LTEXT "Icon:",IDC_STATICICON,7,74,18,12,SS_CENTERIMAGE
EDITTEXT IDC_EDITICON,47,74,180,12,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTONICON,228,74,14,12
ICON "",IDC_ICONN,9,89,20,20
LTEXT "Disabled:",IDC_STATICICOND,7,113,35,12,SS_CENTERIMAGE
EDITTEXT IDC_EDITICOND,47,113,180,12,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTONICOND,228,113,14,12
ICON "",IDC_ICOND,9,127,20,20
PUSHBUTTON "Restore defaults",IDC_BUTTONRESET,7,162,90,14
DEFPUSHBUTTON "OK",IDOK,135,162,50,14
PUSHBUTTON "Cancel",IDCANCEL,192,162,50,14

LTEXT "Hover:", IDC_STATICICONH, 7, 113, 35, 12, SS_CENTERIMAGE
EDITTEXT IDC_EDITICONH, 47, 113, 180, 12, ES_AUTOHSCROLL
PUSHBUTTON "...", IDC_BUTTONICONH, 228, 113, 14, 12
ICON "", IDC_ICONH, 9, 127, 20, 20

LTEXT "Disabled:",IDC_STATICICOND,7,148,35,12,SS_CENTERIMAGE
EDITTEXT IDC_EDITICOND,47,148,180,12,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTONICOND,228,148,14,12
ICON "",IDC_ICOND,9,162,20,20

PUSHBUTTON "Restore defaults",IDC_BUTTONRESET,7,197,90,14
DEFPUSHBUTTON "OK",IDOK,135,197,50,14
PUSHBUTTON "Cancel",IDCANCEL,192,197,50,14
END


Expand Down
17 changes: 17 additions & 0 deletions Src/ClassicExplorer/ExplorerBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void CBandWindow::ParseToolbarItem( const wchar_t *name, StdToolbarItem &item )
Sprintf(text,_countof(text),L"%s.Icon",name);
item.iconPath=m_Parser.FindSetting(text);

Sprintf(text, _countof(text), L"%s.IconHover", name);
item.iconPathH = m_Parser.FindSetting(text);

Sprintf(text,_countof(text),L"%s.IconDisabled",name);
item.iconPathD=m_Parser.FindSetting(text);

Expand Down Expand Up @@ -169,6 +172,7 @@ void CBandWindow::ParseToolbar( void )
item.command=NULL;
item.link=NULL;
item.iconPath=NULL;
item.iconPathH=NULL;
item.iconPathD=NULL;
item.submenu=NULL;
item.menuIcon=NULL;
Expand Down Expand Up @@ -271,6 +275,7 @@ LRESULT CBandWindow::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
if (m_MenuIconSize>32) m_MenuIconSize=32;

m_ImgEnabled=ImageList_Create(iconSize,iconSize,ILC_COLOR32|ILC_MASK|(IsLanguageRTL()?ILC_MIRROR:0),0,mainCount);
m_ImgHover=ImageList_Create(iconSize, iconSize, ILC_COLOR32 | ILC_MASK | (IsLanguageRTL() ? ILC_MIRROR : 0), 0, mainCount);
m_ImgDisabled=ImageList_Create(iconSize,iconSize,ILC_COLOR32|ILC_MASK|(IsLanguageRTL()?ILC_MIRROR:0),0,mainCount);

HMODULE hShell32=GetModuleHandle(L"Shell32.dll");
Expand Down Expand Up @@ -332,14 +337,23 @@ LRESULT CBandWindow::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
hIcon2=CreateDisabledIcon(hIcon,iconSize);
int idx=ImageList_AddIcon(m_ImgDisabled,hIcon2);
Assert(button.iBitmap==idx);
HICON hIcon3 = item.iconPathH ? LoadIcon(iconSize, item.iconPathH, modules) : NULL;
if (!hIcon3)
hIcon3=hIcon;
int idy = ImageList_AddIcon(m_ImgHover, hIcon3);
Assert(button.iBitmap == idy);
DestroyIcon(hIcon);
DestroyIcon(hIcon2);
if (hIcon3 != hIcon)
DestroyIcon(hIcon3);
}
else if (hBitmap)
{
button.iBitmap=ImageList_AddMasked(m_ImgEnabled,hBitmap,CLR_NONE);
int idx=ImageList_AddMasked(m_ImgDisabled,hBitmap,CLR_NONE);
Assert(button.iBitmap==idx);
int idy=ImageList_AddMasked(m_ImgHover,hBitmap,CLR_NONE);
Assert(button.iBitmap == idy);
DeleteObject(hBitmap);
}

Expand Down Expand Up @@ -381,6 +395,8 @@ LRESULT CBandWindow::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
if (old) ImageList_Destroy(old);
old=(HIMAGELIST)m_Toolbar.SendMessage(TB_SETDISABLEDIMAGELIST,0,(LPARAM)m_ImgDisabled);
if (old) ImageList_Destroy(old);
old=(HIMAGELIST)m_Toolbar.SendMessage(TB_SETHOTIMAGELIST,0,(LPARAM)m_ImgHover);
if (old) ImageList_Destroy(old);
if (!m_Buttons.empty())
m_Toolbar.SendMessage(TB_ADDBUTTONS,(WPARAM)m_Buttons.size(),(LPARAM)&m_Buttons[0]);
SendMessage(WM_CLEAR);
Expand All @@ -391,6 +407,7 @@ LRESULT CBandWindow::OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
{
if (m_ImgEnabled) ImageList_Destroy(m_ImgEnabled); m_ImgEnabled=NULL;
if (m_ImgDisabled) ImageList_Destroy(m_ImgDisabled); m_ImgDisabled=NULL;
if (m_ImgHover) ImageList_Destroy(m_ImgHover); m_ImgHover=NULL;
for (std::vector<StdToolbarItem>::iterator it=m_Items.begin();it!=m_Items.end();++it)
{
if (it->menuIcon) DeleteObject(it->menuIcon);
Expand Down
2 changes: 2 additions & 0 deletions Src/ClassicExplorer/ExplorerBand.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class CBandWindow: public CWindowImpl<CBandWindow>
CComPtr<IWebBrowser2> m_pWebBrowser;
CComPtr<IPropertyBag> m_pBrowserBag;
HIMAGELIST m_ImgEnabled;
HIMAGELIST m_ImgHover;
HIMAGELIST m_ImgDisabled;
int m_MenuIconSize;

Expand All @@ -131,6 +132,7 @@ class CBandWindow: public CWindowImpl<CBandWindow>
const wchar_t *label; // text on the button
const wchar_t *tip; // default tooltip
const wchar_t *iconPath;
const wchar_t *iconPathH;
const wchar_t *iconPathD;
CString regName; // name of the registry value to check for enabled/checked state
CString labelString, tipString; // additional storage for the strings
Expand Down
44 changes: 37 additions & 7 deletions Src/ClassicExplorer/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const wchar_t *g_DefaultToolbar=
L"UpItem.Command=up\n"
L"UpItem.Tip=$Toolbar.GoUp\n"
L"UpItem.Icon=,2\n"
L"UpItem.IconHover=,6\n"
L"UpItem.IconDisabled=,3\n"
L"NavPaneItem.Command=nav_pane\n"
L"NavPaneItem.Tip=$Toolbar.NavigationPane\n"
Expand Down Expand Up @@ -205,10 +206,12 @@ class CEditToolbarDlg: public CEditCustomItemDlg
COMMAND_HANDLER( IDC_BUTTONCOMMAND, BN_CLICKED, OnBrowseCommand )
COMMAND_HANDLER( IDC_BUTTONLINK, BN_CLICKED, OnBrowseLink )
COMMAND_HANDLER( IDC_BUTTONICON, BN_CLICKED, OnBrowseIcon )
COMMAND_HANDLER( IDC_BUTTONICONH, BN_CLICKED, OnBrowseIcon )
COMMAND_HANDLER( IDC_BUTTONICOND, BN_CLICKED, OnBrowseIcon )
COMMAND_HANDLER( IDC_COMBOLINK, CBN_KILLFOCUS, OnLinkChanged )
COMMAND_HANDLER( IDC_COMBOLINK, CBN_SELENDOK, OnLinkChanged )
COMMAND_HANDLER( IDC_EDITICON, EN_KILLFOCUS, OnIconChanged )
COMMAND_HANDLER(IDC_EDITICONH, EN_KILLFOCUS, OnIconHChanged)
COMMAND_HANDLER( IDC_EDITICOND, EN_KILLFOCUS, OnIconDChanged )
COMMAND_HANDLER( IDC_BUTTONRESET, BN_CLICKED, OnReset )
CHAIN_MSG_MAP( CEditCustomItemDlg )
Expand All @@ -223,6 +226,8 @@ class CEditToolbarDlg: public CEditCustomItemDlg
RESIZE_CONTROL(IDC_EDITTIP,MOVE_SIZE_X)
RESIZE_CONTROL(IDC_EDITICON,MOVE_SIZE_X)
RESIZE_CONTROL(IDC_BUTTONICON,MOVE_MOVE_X)
RESIZE_CONTROL(IDC_EDITICONH, MOVE_SIZE_X)
RESIZE_CONTROL(IDC_BUTTONICONH, MOVE_MOVE_X)
RESIZE_CONTROL(IDC_EDITICOND,MOVE_SIZE_X)
RESIZE_CONTROL(IDC_BUTTONICOND,MOVE_MOVE_X)
RESIZE_CONTROL(IDOK,MOVE_MOVE_X)
Expand All @@ -239,6 +244,7 @@ class CEditToolbarDlg: public CEditCustomItemDlg
LRESULT OnCommandChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
LRESULT OnLinkChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
LRESULT OnIconChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
LRESULT OnIconHChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnIconDChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
LRESULT OnBrowseCommand( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
LRESULT OnBrowseLink( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
Expand All @@ -259,11 +265,12 @@ LRESULT CEditToolbarDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam,
SetDlgItemText(IDC_EDITLABEL,m_pItem->label);
SetDlgItemText(IDC_EDITTIP,m_pItem->tip);
SetDlgItemText(IDC_EDITICON,m_pItem->icon);
SetDlgItemText(IDC_EDITICONH, m_pItem->iconH);
SetDlgItemText(IDC_EDITICOND,m_pItem->iconD);

GetDlgItem(IDC_BUTTONRESET).EnableWindow(m_pItem->pStdCommand && *m_pItem->pStdCommand->name);

UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);

CWindow tooltip=CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW|WS_EX_TRANSPARENT,TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP,0,0,0,0,m_hWnd,NULL,g_Instance,NULL);
tooltip.SendMessage(TTM_SETMAXTIPWIDTH,0,GetSystemMetrics(SM_CXSCREEN)/2);
Expand Down Expand Up @@ -327,7 +334,7 @@ LRESULT CEditToolbarDlg::OnCommandChanged( WORD wNotifyCode, WORD wID, HWND hWnd
if (text==m_pItem->command) return 0;
m_pItem->SetCommand(text,g_StdCommands,m_Style,SETTINGS_STYLE_MASK);
GetDlgItem(IDC_BUTTONRESET).EnableWindow(m_pItem->pStdCommand && *m_pItem->pStdCommand->name);
UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

Expand All @@ -336,7 +343,7 @@ LRESULT CEditToolbarDlg::OnLinkChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl
CString text=GetComboText(wNotifyCode,wID);
if (text==m_pItem->link) return 0;
m_pItem->link=text;
UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

Expand All @@ -348,7 +355,7 @@ LRESULT CEditToolbarDlg::OnIconChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl
text.TrimRight();
if (text==m_pItem->icon) return 0;
m_pItem->icon=text;
UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

Expand All @@ -360,7 +367,19 @@ LRESULT CEditToolbarDlg::OnIconDChanged( WORD wNotifyCode, WORD wID, HWND hWndCt
text.TrimRight();
if (text==m_pItem->iconD) return 0;
m_pItem->iconD=text;
UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

LRESULT CEditToolbarDlg::OnIconHChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
CString text;
GetDlgItemText(IDC_EDITICONH, text);
text.TrimLeft();
text.TrimRight();
if (text == m_pItem->iconH) return 0;
m_pItem->iconH = text;
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

Expand Down Expand Up @@ -392,9 +411,10 @@ LRESULT CEditToolbarDlg::OnBrowseIcon( WORD wNotifyCode, WORD wID, HWND hWndCtl,
{
wchar_t text[_MAX_PATH];
if (wID==IDC_BUTTONICON) wID=IDC_EDITICON;
if (wID==IDC_BUTTONICONH) wID=IDC_EDITICONH;
if (wID==IDC_BUTTONICOND) wID=IDC_EDITICOND;
GetDlgItemText(wID,text,_countof(text));
if (wID==IDC_EDITICOND && !*text)
if ((wID==IDC_EDITICOND || wID==IDC_EDITICONH) && !*text)
GetDlgItemText(IDC_EDITICON,text,_countof(text));
if (BrowseIconHelper(m_hWnd,text))
{
Expand All @@ -417,9 +437,10 @@ LRESULT CEditToolbarDlg::OnReset( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
SetDlgItemText(IDC_EDITLABEL,m_pItem->label);
SetDlgItemText(IDC_EDITTIP,m_pItem->tip);
SetDlgItemText(IDC_EDITICON,m_pItem->icon);
SetDlgItemText(IDC_EDITICONH, m_pItem->iconD);
SetDlgItemText(IDC_EDITICOND,m_pItem->iconD);

UpdateIcons(IDC_ICONN,IDC_ICOND);
UpdateIcons(IDC_ICONN,IDC_ICOND,IDC_ICONH);
return 0;
}

Expand All @@ -439,6 +460,8 @@ class CCustomToolbarDlg: public CCustomTreeDlg
void CCustomToolbarDlg::ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &parser )
{
wchar_t text[256];
Sprintf(text, _countof(text), L"%s.IconHover", pItem->name);
pItem->iconH = parser.FindSetting(text, L"");
Sprintf(text,_countof(text),L"%s.IconDisabled",pItem->name);
pItem->iconD=parser.FindSetting(text,L"");
}
Expand All @@ -451,6 +474,13 @@ void CCustomToolbarDlg::SerializeItemExtra( CTreeItem *pItem, std::vector<wchar_
Sprintf(text,_countof(text),L"%s.IconDisabled=%s\n",pItem->name,pItem->iconD);
AppendString(stringBuilder,text);
}

if (!pItem->iconH.IsEmpty())
{
wchar_t text[2048];
Sprintf(text, _countof(text), L"%s.IconHover=%s\n", pItem->name, pItem->iconH);
AppendString(stringBuilder, text);
}
}

bool CCustomToolbarDlg::EditItem( CTreeItem *pItem, HWND tree, HTREEITEM hItem, std::vector<HMODULE> &modules )
Expand Down
4 changes: 4 additions & 0 deletions Src/ClassicExplorer/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
#define IDC_COMBOLINK 258
#define IDC_STATICICON1 260
#define IDC_BUTTONRESET 261
#define IDC_EDITICONH 262
#define IDC_BUTTONICONH 263
#define IDC_ICONH 264
#define IDC_STATICICONH 265
#define IDC_STATICFNAME 1003
#define IDC_STATICSRCSIZE 1004
#define IDC_STATICSRCTIME 1005
Expand Down
37 changes: 36 additions & 1 deletion Src/Lib/SettingsUIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ unsigned int CTreeItem::GetIconDKey( unsigned int iconKey ) const
return CalcFNVHash(iconD);
}

unsigned int CTreeItem::GetIconHKey(unsigned int iconKey) const
{
if (iconH.IsEmpty())
return ~iconKey;
return CalcFNVHash(iconH);
}

HICON CTreeItem::LoadIconH(std::vector<HMODULE>& modules) const
{
if (!iconH.IsEmpty())
{
if (_wcsicmp(iconH, L"none") == 0)
return NULL;
return ::LoadIcon(GetSystemMetrics(SM_CXICON), iconH, modules);
}
else
return NULL;
}

HICON CTreeItem::LoadIconD( HICON hIcon, std::vector<HMODULE> &modules ) const
{
if (!iconD.IsEmpty())
Expand Down Expand Up @@ -647,6 +666,7 @@ HTREEITEM CSettingsTree::CreateStdItem( const CStdCommand *pCommand, HTREEITEM h
pNewItem->label=pCommand->label;
pNewItem->tip=pCommand->tip;
pNewItem->icon=pCommand->icon;
pNewItem->iconH=pCommand->iconH;
pNewItem->iconD=pCommand->iconD;
pNewItem->pStdCommand=pCommand;
pNewItem->settings=pCommand->settings&~m_StyleMask;
Expand Down Expand Up @@ -933,6 +953,7 @@ LRESULT CCommandsTree::OnChar( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
CEditCustomItemDlg::~CEditCustomItemDlg( void )
{
if (m_hIcon) DestroyIcon(m_hIcon);
if (m_hIconH) DestroyIcon(m_hIconH);
if (m_hIconD) DestroyIcon(m_hIconD);
}

Expand Down Expand Up @@ -987,6 +1008,8 @@ void CEditCustomItemDlg::InitDialog( CWindow commandCombo, const CStdCommand *pS

m_hIcon=NULL;
m_IconKey=0;
m_hIconH = NULL;
m_IconHKey = 0;
m_hIconD=NULL;
m_IconDKey=0;
m_StoredItem=*m_pItem;
Expand Down Expand Up @@ -1043,7 +1066,7 @@ LRESULT CEditCustomItemDlg::OnCancel( WORD wNotifyCode, WORD wID, HWND hWndCtl,
return 0;
}

void CEditCustomItemDlg::UpdateIcons( int iconID, int iconDID )
void CEditCustomItemDlg::UpdateIcons( int iconID, int iconDID, int iconHID )
{
unsigned int key=m_pItem->GetIconKey();

Expand All @@ -1066,6 +1089,18 @@ void CEditCustomItemDlg::UpdateIcons( int iconID, int iconDID )
SendDlgItemMessage(iconDID,STM_SETICON,(WPARAM)m_hIconD);
}
}

if (iconHID)
{
key = m_pItem->GetIconHKey(key);
if (key != m_IconHKey)
{
m_IconHKey = key;
if (m_hIconH) DestroyIcon(m_hIconH);
m_hIconH = m_pItem->LoadIconH(m_Modules);
SendDlgItemMessage(iconHID, STM_SETICON, (WPARAM)m_hIconH);
}
}
}

CString CEditCustomItemDlg::GetComboText( WORD wNotifyCode, WORD wID )
Expand Down
Loading