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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Src/ClassicIE/ClassicIEDLL/ClassicIEDLL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,25 @@ BEGIN
IDS_LANGUAGE_SETTINGS "Language"
IDS_CAPTION_FONT "Caption font"
IDS_CAPTION_FONT_TIP "Select the font and text size to use for the caption"
IDS_TEXT_COLOR "Text color"
IDS_TEXT_COLOR "Text color (RRGGBB)"
IDS_TEXT_COLOR_TIP "Select the color for the caption text"
IDS_MAXTEXT_COLOR "Text color (maximized)"
IDS_MAXTEXT_COLOR "Text color (maximized) (RRGGBB)"
IDS_MAXTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized"
IDS_INTEXT_COLOR "Text color (inactive)"
IDS_INTEXT_COLOR "Text color (inactive) (RRGGBB)"
IDS_INTEXT_COLOR_TIP "Select the color for the caption text when the window is inactive"
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive)"
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive) (RRGGBB)"
IDS_MAXINTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized and inactive"
IDS_GLOW "Text glow"
IDS_GLOW_TIP "When this is checked, the text will have a glow around it"
IDS_GLOW_COLOR "Glow color"
IDS_GLOW_COLOR "Glow color (RRGGBB)"
IDS_GLOW_COLOR_TIP "Select the color for the caption glow"
END

STRINGTABLE
BEGIN
IDS_MAXGLOW "Text glow (maximized)"
IDS_MAXGLOW_TIP "When this is checked, the text in the maximized window will have a glow around it"
IDS_MAXGLOW_COLOR "Glow color (maximized)"
IDS_MAXGLOW_COLOR "Glow color (maximized) (RRGGBB)"
IDS_MAXGLOW_COLOR_TIP "Select the color for the caption glow when the window is maximized"
IDS_STATUS_SETTINGS "Status Bar"
IDS_SHOW_PROGRESS "Show progress"
Expand Down
53 changes: 50 additions & 3 deletions Src/Lib/ResourceHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,11 @@ HBITMAP LoadImageFile( const wchar_t *path, const SIZE *pSize, bool bUseAlpha, b
CComPtr<IWICImagingFactory> pFactory;
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
{
if (srcBmp) DeleteObject(srcBmp);
return NULL;
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory1)))
{
if (srcBmp) DeleteObject(srcBmp);
return NULL;
}
}

CComPtr<IWICBitmapSource> pBitmap;
Expand Down Expand Up @@ -534,7 +537,10 @@ HBITMAP LoadImageResource( HMODULE hModule, const wchar_t *name, bool bTopDown,
{
CComPtr<IWICImagingFactory> pFactory;
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
return NULL;
{
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory1)))
return NULL;
}

CComPtr<IWICBitmapSource> pBitmap;
if (hModule)
Expand Down Expand Up @@ -727,6 +733,19 @@ bool IsWin10RS4( void )
return bIsRS4;
}

static bool IsWin11Helper()
{
auto version = GetOSVersion();
return version.dwMajorVersion >= 10 && version.dwBuildNumber >= 22000;
}

// Returns true if the version is Windows11 or later
bool IsWin11(void)
{
static bool bIsWin11 = IsWin11Helper();
return bIsWin11;
}

// Wrapper for IShellFolder::ParseDisplayName
HRESULT ShParseDisplayName( const wchar_t *pszName, PIDLIST_ABSOLUTE *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut )
{
Expand Down Expand Up @@ -903,3 +922,31 @@ HFONT CreateFontSetting( const wchar_t *fontStr, int dpi )
int size=-_wtol(token);
return CreateFont(size*dpi/72,0,0,0,weight,bItalic?1:0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,name);
}

static UINT WINAPI GetDpiForWindow(HWND hwnd)
{
static auto p = static_cast<decltype(&GetDpiForWindow)>((void*)GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow"));
if (p)
return p(hwnd);

return 0;
}

UINT GetDpi(HWND hwnd)
{
UINT dpi = GetDpiForWindow(hwnd);
if (!dpi)
{
// fall-back for older systems
HDC hdc = GetDC(nullptr);
dpi = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(nullptr, hdc);
}

return dpi;
}

int ScaleForDpi(HWND hwnd, int value)
{
return MulDiv(value, GetDpi(hwnd), USER_DEFAULT_SCREEN_DPI);
}
9 changes: 9 additions & 0 deletions Src/Lib/ResourceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ bool IsWin10RS1( void );
// Returns true if the version is Windows10 RS4 (Spring Creator Update) or later
bool IsWin10RS4( void );

// Returns true if the version is Windows11 or later
bool IsWin11();

// Wrapper for IShellFolder::ParseDisplayName
HRESULT ShParseDisplayName( const wchar_t *pszName, PIDLIST_ABSOLUTE *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut );

Expand All @@ -82,6 +85,12 @@ void StringUpper( CString &str );
// Create a font from the user settings
HFONT CreateFontSetting( const wchar_t *fontStr, int dpi );

// Return DPI of given window (or system DPI on older systems)
UINT GetDpi(HWND hwnd = nullptr);

// Scale given value according to DPI of window
int ScaleForDpi(HWND hwnd, int value);

extern HINSTANCE g_Instance;

const int ANIM_BUTTON_TAG1='ANM';
Expand Down
28 changes: 21 additions & 7 deletions Src/Lib/SettingsUIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2651,15 +2651,14 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
CString str;
m_EditBox.GetWindowText(str);
str.TrimLeft(); str.TrimRight();
wchar_t *end;
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
COLORREF val=RgbToBgr(ParseColor(str));
static COLORREF customColors[16];
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
if (ChooseColor(&choose))
{
wchar_t text[100];
Sprintf(text,_countof(text),L"%06X",choose.rgbResult);
Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
m_EditBox.SetWindowText(text);
ApplyEditBox();
UpdateGroup(m_pEditSetting);
Expand Down Expand Up @@ -3048,8 +3047,7 @@ void CTreeSettingsDlg::ApplyEditBox( void )
}
else if (pSetting->type==CSetting::TYPE_COLOR)
{
wchar_t *end;
int val=wcstol(str,&end,16)&0xFFFFFF;
int val=RgbToBgr(ParseColor(str));
if (pSetting->value.vt!=VT_I4 || pSetting->value.intVal!=val)
{
pSetting->value=CComVariant(val);
Expand Down Expand Up @@ -3156,7 +3154,7 @@ void CTreeSettingsDlg::ItemSelected( HTREEITEM hItem, CSetting *pSetting, bool b
mode=EDIT_COLOR;
int val=0;
if (valVar.vt==VT_I4)
val=valVar.intVal;
val=BgrToRgb(valVar.intVal);
Sprintf(text,_countof(text),L"%06X",val);
}
}
Expand Down Expand Up @@ -3462,7 +3460,7 @@ void CTreeSettingsDlg::UpdateGroup( const CSetting *pModified )
CString str=LoadStringEx(pSetting->nameID);
int val=0;
if (valVar.vt==VT_I4)
val=valVar.intVal;
val=BgrToRgb(valVar.intVal);
Sprintf(text,_countof(text),L"%s: %06X",str,val);
item.mask|=TVIF_TEXT;
}
Expand Down Expand Up @@ -3616,3 +3614,19 @@ bool CDefaultSettingsPanel::Validate( HWND parent )
s_Dialog.Validate();
return true;
}

DWORD RgbToBgr(DWORD val)
{
return ((val & 0xFF) << 16) | (val & 0xFF00) | ((val >> 16) & 0xFF);
}

DWORD BgrToRgb(DWORD val)
{
return RgbToBgr(val);
}

DWORD ParseColor(const wchar_t* str)
{
wchar_t* end;
return wcstoul(str, &end, 16) & 0xFFFFFF;
}
8 changes: 8 additions & 0 deletions Src/Lib/SettingsUIHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,11 @@ extern const GUID FOLDERID_DesktopRoot;
bool BrowseCommandHelper( HWND parent, wchar_t *text );
bool BrowseLinkHelper( HWND parent, wchar_t *text, bool bFoldersOnly );
bool BrowseIconHelper( HWND parent, wchar_t *text );

// convert color in RRGGBB format to BBGGRR
DWORD RgbToBgr(DWORD val);
// convert color in BBGGRR format to RRGGBB
DWORD BgrToRgb(DWORD val);

// parse color from hexadecimal string
DWORD ParseColor(const wchar_t* str);
10 changes: 9 additions & 1 deletion Src/Setup/BuildBinaries.bat
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,26 @@ copy /B Output\x64\StartMenuHelper64.dll Output\PDB64 > nul

REM ********* Source Index PDBs

set PDBSTR_PATH="C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\srcsrv\pdbstr.exe"
set PDBSTR_PATH="C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\srcsrv\pdbstr.exe"

if exist %PDBSTR_PATH% (
echo --- Adding source index to PDBs
call CreateSourceIndex.bat ..\.. > Output\pdbstr.txt

for %%f in (Output\PDB32\*.pdb) do (
%PDBSTR_PATH% -w -p:%%f -s:srcsrv -i:Output\pdbstr.txt
if not ERRORLEVEL 0 (
echo Error adding source index to PDB
exit /b 1
)
)

for %%f in (Output\PDB64\*.pdb) do (
%PDBSTR_PATH% -w -p:%%f -s:srcsrv -i:Output\pdbstr.txt
if not ERRORLEVEL 0 (
echo Error adding source index to PDB
exit /b 1
)
)
)

Expand Down
3 changes: 2 additions & 1 deletion Src/StartMenu/StartMenuDLL/ItemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ void CItemManager::LoadIconData::Init( void )
HIMAGELIST_QueryInterface(m_TempLists[i],IID_IImageList2,(void**)&m_pTempLists[i]);
}
}
m_pFactory.CoCreateInstance(CLSID_WICImagingFactory);
if (FAILED(m_pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
m_pFactory.CoCreateInstance(CLSID_WICImagingFactory1);
}

void CItemManager::LoadIconData::Close( void )
Expand Down
4 changes: 4 additions & 0 deletions Src/StartMenu/StartMenuDLL/MenuCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,10 @@ void CMenuContainer::ActivateItem( int index, TActivateType type, const POINT *p
if (bRefresh || bRefreshMain)
info.fMask|=CMIC_MASK_NOASYNC; // wait for delete/link commands to finish so we can refresh the menu

// we don't want our virtual folder to appear in Explorer's frequent list
if (wcsncmp(item.pItemInfo->PATH, L"::{82E749ED-B971-4550-BAF7-06AA2BF7E836}", 40) == 0)
info.fMask &= ~CMIC_MASK_FLAG_LOG_USAGE;

s_bPreventClosing=true;
for (auto& it : s_Menus)
{
Expand Down
48 changes: 42 additions & 6 deletions Src/StartMenu/StartMenuDLL/MenuContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ bool CMenuContainer::s_bMRULoaded=false;
const CItemManager::ItemInfo *CMenuContainer::s_JumpAppInfo;
CJumpList CMenuContainer::s_JumpList;
int CMenuContainer::s_TaskBarId;
HWND CMenuContainer::s_TaskBar, CMenuContainer::s_StartButton;
HWND CMenuContainer::s_TaskBar;
HWND CMenuContainer::s_StartButton; // custom start button (if any)
UINT CMenuContainer::s_TaskBarEdge;
RECT CMenuContainer::s_StartRect;
HWND CMenuContainer::s_LastFGWindow;
Expand Down Expand Up @@ -1588,6 +1589,23 @@ static const wchar_t *g_MfuIgnoreExes[]={
L"WUAPP.EXE",
};

static bool IgnoreUserAssistItem(const UserAssistItem& uaItem)
{
static constexpr const wchar_t* ignoredNames[] =
{
DESKTOP_APP_ID,
L"Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy!App",
};

for (const auto& name : ignoredNames)
{
if (_wcsicmp(uaItem.name, name) == 0)
return true;
}

return false;
}

void CMenuContainer::GetRecentPrograms( std::vector<MenuItem> &items, int maxCount )
{
bool bShowMetro=GetSettingBool(L"RecentMetroApps");
Expand Down Expand Up @@ -1940,9 +1958,9 @@ void CMenuContainer::GetRecentPrograms( std::vector<MenuItem> &items, int maxCou
continue;
}

if (_wcsicmp(uaItem.name,DESKTOP_APP_ID)==0)
if (IgnoreUserAssistItem(uaItem))
{
LOG_MENU(LOG_MFU,L"UserAssist: Dropping: Ignore desktop");
LOG_MENU(LOG_MFU,L"UserAssist: Dropping: Ignore '%s'",uaItem.name);
continue;
}

Expand Down Expand Up @@ -7507,17 +7525,32 @@ RECT CMenuContainer::CalculateWorkArea( const RECT &taskbarRect )
return rc;
}

// Calculates start menu position
POINT CMenuContainer::CalculateCorner( void )
{
RECT margin={0,0,0,0};
if (IsAppThemed())
AdjustWindowRect(&margin,GetWindowLong(GWL_STYLE),FALSE);

POINT corner;
if (m_Options&CONTAINER_LEFT)
corner.x=s_MainMenuLimits.left+margin.left;
if (IsWin11())
{
// start button can be in the center on Win11
// we want to show menu at the position of start button
if (m_Options&CONTAINER_LEFT)
corner.x=s_StartRect.left+margin.left;
else
corner.x=s_StartRect.right+margin.right;
}
else
corner.x=s_MainMenuLimits.right+margin.right;
{
// start button can be only in corner on older systems
// we can use screen limits to determine menu position
if (m_Options&CONTAINER_LEFT)
corner.x=s_MainMenuLimits.left+margin.left;
else
corner.x=s_MainMenuLimits.right+margin.right;
}

if (m_Options&CONTAINER_TOP)
{
Expand Down Expand Up @@ -7636,6 +7669,9 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
// initialize all settings
bool bErr=false;
HMONITOR initialMonitor=MonitorFromWindow(s_TaskBar,MONITOR_DEFAULTTONEAREST);
// note: GetTaskbarPosition properly identifies monitor in case of multi-monitor setup and automatic taskbar hiding
GetTaskbarPosition(s_TaskBar,NULL,&initialMonitor,NULL);

int dpi=CItemManager::GetDPI(true);
if (!CItemManager::GetDPIOverride() && GetWinVersion()>=WIN_VER_WIN81)
{
Expand Down
Loading