Skip to content

Commit 0a96dc4

Browse files
authored
Merge a0c238f into 9606e11
2 parents 9606e11 + a0c238f commit 0a96dc4

File tree

16 files changed

+468
-278
lines changed

16 files changed

+468
-278
lines changed

Src/ClassicIE/ClassicIEDLL/ClassicIEDLL.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,25 @@ BEGIN
135135
IDS_LANGUAGE_SETTINGS "Language"
136136
IDS_CAPTION_FONT "Caption font"
137137
IDS_CAPTION_FONT_TIP "Select the font and text size to use for the caption"
138-
IDS_TEXT_COLOR "Text color"
138+
IDS_TEXT_COLOR "Text color (RRGGBB)"
139139
IDS_TEXT_COLOR_TIP "Select the color for the caption text"
140-
IDS_MAXTEXT_COLOR "Text color (maximized)"
140+
IDS_MAXTEXT_COLOR "Text color (maximized) (RRGGBB)"
141141
IDS_MAXTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized"
142-
IDS_INTEXT_COLOR "Text color (inactive)"
142+
IDS_INTEXT_COLOR "Text color (inactive) (RRGGBB)"
143143
IDS_INTEXT_COLOR_TIP "Select the color for the caption text when the window is inactive"
144-
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive)"
144+
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive) (RRGGBB)"
145145
IDS_MAXINTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized and inactive"
146146
IDS_GLOW "Text glow"
147147
IDS_GLOW_TIP "When this is checked, the text will have a glow around it"
148-
IDS_GLOW_COLOR "Glow color"
148+
IDS_GLOW_COLOR "Glow color (RRGGBB)"
149149
IDS_GLOW_COLOR_TIP "Select the color for the caption glow"
150150
END
151151

152152
STRINGTABLE
153153
BEGIN
154154
IDS_MAXGLOW "Text glow (maximized)"
155155
IDS_MAXGLOW_TIP "When this is checked, the text in the maximized window will have a glow around it"
156-
IDS_MAXGLOW_COLOR "Glow color (maximized)"
156+
IDS_MAXGLOW_COLOR "Glow color (maximized) (RRGGBB)"
157157
IDS_MAXGLOW_COLOR_TIP "Select the color for the caption glow when the window is maximized"
158158
IDS_STATUS_SETTINGS "Status Bar"
159159
IDS_SHOW_PROGRESS "Show progress"

Src/Lib/ResourceHelper.cpp

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,11 @@ HBITMAP LoadImageFile( const wchar_t *path, const SIZE *pSize, bool bUseAlpha, b
396396
CComPtr<IWICImagingFactory> pFactory;
397397
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
398398
{
399-
if (srcBmp) DeleteObject(srcBmp);
400-
return NULL;
399+
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory1)))
400+
{
401+
if (srcBmp) DeleteObject(srcBmp);
402+
return NULL;
403+
}
401404
}
402405

403406
CComPtr<IWICBitmapSource> pBitmap;
@@ -534,7 +537,10 @@ HBITMAP LoadImageResource( HMODULE hModule, const wchar_t *name, bool bTopDown,
534537
{
535538
CComPtr<IWICImagingFactory> pFactory;
536539
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
537-
return NULL;
540+
{
541+
if (FAILED(pFactory.CoCreateInstance(CLSID_WICImagingFactory1)))
542+
return NULL;
543+
}
538544

539545
CComPtr<IWICBitmapSource> pBitmap;
540546
if (hModule)
@@ -727,6 +733,19 @@ bool IsWin10RS4( void )
727733
return bIsRS4;
728734
}
729735

736+
static bool IsWin11Helper()
737+
{
738+
auto version = GetOSVersion();
739+
return version.dwMajorVersion >= 10 && version.dwBuildNumber >= 22000;
740+
}
741+
742+
// Returns true if the version is Windows11 or later
743+
bool IsWin11(void)
744+
{
745+
static bool bIsWin11 = IsWin11Helper();
746+
return bIsWin11;
747+
}
748+
730749
// Wrapper for IShellFolder::ParseDisplayName
731750
HRESULT ShParseDisplayName( const wchar_t *pszName, PIDLIST_ABSOLUTE *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut )
732751
{
@@ -903,3 +922,31 @@ HFONT CreateFontSetting( const wchar_t *fontStr, int dpi )
903922
int size=-_wtol(token);
904923
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);
905924
}
925+
926+
static UINT WINAPI GetDpiForWindow(HWND hwnd)
927+
{
928+
static auto p = static_cast<decltype(&GetDpiForWindow)>((void*)GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow"));
929+
if (p)
930+
return p(hwnd);
931+
932+
return 0;
933+
}
934+
935+
UINT GetDpi(HWND hwnd)
936+
{
937+
UINT dpi = GetDpiForWindow(hwnd);
938+
if (!dpi)
939+
{
940+
// fall-back for older systems
941+
HDC hdc = GetDC(nullptr);
942+
dpi = GetDeviceCaps(hdc, LOGPIXELSY);
943+
ReleaseDC(nullptr, hdc);
944+
}
945+
946+
return dpi;
947+
}
948+
949+
int ScaleForDpi(HWND hwnd, int value)
950+
{
951+
return MulDiv(value, GetDpi(hwnd), USER_DEFAULT_SCREEN_DPI);
952+
}

Src/Lib/ResourceHelper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ bool IsWin10RS1( void );
6767
// Returns true if the version is Windows10 RS4 (Spring Creator Update) or later
6868
bool IsWin10RS4( void );
6969

70+
// Returns true if the version is Windows11 or later
71+
bool IsWin11();
72+
7073
// Wrapper for IShellFolder::ParseDisplayName
7174
HRESULT ShParseDisplayName( const wchar_t *pszName, PIDLIST_ABSOLUTE *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut );
7275

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

88+
// Return DPI of given window (or system DPI on older systems)
89+
UINT GetDpi(HWND hwnd = nullptr);
90+
91+
// Scale given value according to DPI of window
92+
int ScaleForDpi(HWND hwnd, int value);
93+
8594
extern HINSTANCE g_Instance;
8695

8796
const int ANIM_BUTTON_TAG1='ANM';

Src/Lib/SettingsUIHelper.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,15 +2651,14 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
26512651
CString str;
26522652
m_EditBox.GetWindowText(str);
26532653
str.TrimLeft(); str.TrimRight();
2654-
wchar_t *end;
2655-
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
2654+
COLORREF val=RgbToBgr(ParseColor(str));
26562655
static COLORREF customColors[16];
26572656
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
26582657
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
26592658
if (ChooseColor(&choose))
26602659
{
26612660
wchar_t text[100];
2662-
Sprintf(text,_countof(text),L"%06X",choose.rgbResult);
2661+
Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
26632662
m_EditBox.SetWindowText(text);
26642663
ApplyEditBox();
26652664
UpdateGroup(m_pEditSetting);
@@ -3048,8 +3047,7 @@ void CTreeSettingsDlg::ApplyEditBox( void )
30483047
}
30493048
else if (pSetting->type==CSetting::TYPE_COLOR)
30503049
{
3051-
wchar_t *end;
3052-
int val=wcstol(str,&end,16)&0xFFFFFF;
3050+
int val=RgbToBgr(ParseColor(str));
30533051
if (pSetting->value.vt!=VT_I4 || pSetting->value.intVal!=val)
30543052
{
30553053
pSetting->value=CComVariant(val);
@@ -3156,7 +3154,7 @@ void CTreeSettingsDlg::ItemSelected( HTREEITEM hItem, CSetting *pSetting, bool b
31563154
mode=EDIT_COLOR;
31573155
int val=0;
31583156
if (valVar.vt==VT_I4)
3159-
val=valVar.intVal;
3157+
val=BgrToRgb(valVar.intVal);
31603158
Sprintf(text,_countof(text),L"%06X",val);
31613159
}
31623160
}
@@ -3462,7 +3460,7 @@ void CTreeSettingsDlg::UpdateGroup( const CSetting *pModified )
34623460
CString str=LoadStringEx(pSetting->nameID);
34633461
int val=0;
34643462
if (valVar.vt==VT_I4)
3465-
val=valVar.intVal;
3463+
val=BgrToRgb(valVar.intVal);
34663464
Sprintf(text,_countof(text),L"%s: %06X",str,val);
34673465
item.mask|=TVIF_TEXT;
34683466
}
@@ -3616,3 +3614,19 @@ bool CDefaultSettingsPanel::Validate( HWND parent )
36163614
s_Dialog.Validate();
36173615
return true;
36183616
}
3617+
3618+
DWORD RgbToBgr(DWORD val)
3619+
{
3620+
return ((val & 0xFF) << 16) | (val & 0xFF00) | ((val >> 16) & 0xFF);
3621+
}
3622+
3623+
DWORD BgrToRgb(DWORD val)
3624+
{
3625+
return RgbToBgr(val);
3626+
}
3627+
3628+
DWORD ParseColor(const wchar_t* str)
3629+
{
3630+
wchar_t* end;
3631+
return wcstoul(str, &end, 16) & 0xFFFFFF;
3632+
}

Src/Lib/SettingsUIHelper.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,11 @@ extern const GUID FOLDERID_DesktopRoot;
387387
bool BrowseCommandHelper( HWND parent, wchar_t *text );
388388
bool BrowseLinkHelper( HWND parent, wchar_t *text, bool bFoldersOnly );
389389
bool BrowseIconHelper( HWND parent, wchar_t *text );
390+
391+
// convert color in RRGGBB format to BBGGRR
392+
DWORD RgbToBgr(DWORD val);
393+
// convert color in BBGGRR format to RRGGBB
394+
DWORD BgrToRgb(DWORD val);
395+
396+
// parse color from hexadecimal string
397+
DWORD ParseColor(const wchar_t* str);

Src/Setup/BuildBinaries.bat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,26 @@ copy /B Output\x64\StartMenuHelper64.dll Output\PDB64 > nul
114114

115115
REM ********* Source Index PDBs
116116

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

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

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

127131
for %%f in (Output\PDB64\*.pdb) do (
128132
%PDBSTR_PATH% -w -p:%%f -s:srcsrv -i:Output\pdbstr.txt
133+
if not ERRORLEVEL 0 (
134+
echo Error adding source index to PDB
135+
exit /b 1
136+
)
129137
)
130138
)
131139

Src/StartMenu/StartMenuDLL/ItemManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ void CItemManager::LoadIconData::Init( void )
489489
HIMAGELIST_QueryInterface(m_TempLists[i],IID_IImageList2,(void**)&m_pTempLists[i]);
490490
}
491491
}
492-
m_pFactory.CoCreateInstance(CLSID_WICImagingFactory);
492+
if (FAILED(m_pFactory.CoCreateInstance(CLSID_WICImagingFactory)))
493+
m_pFactory.CoCreateInstance(CLSID_WICImagingFactory1);
493494
}
494495

495496
void CItemManager::LoadIconData::Close( void )

Src/StartMenu/StartMenuDLL/MenuCommands.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,10 @@ void CMenuContainer::ActivateItem( int index, TActivateType type, const POINT *p
28112811
if (bRefresh || bRefreshMain)
28122812
info.fMask|=CMIC_MASK_NOASYNC; // wait for delete/link commands to finish so we can refresh the menu
28132813

2814+
// we don't want our virtual folder to appear in Explorer's frequent list
2815+
if (wcsncmp(item.pItemInfo->PATH, L"::{82E749ED-B971-4550-BAF7-06AA2BF7E836}", 40) == 0)
2816+
info.fMask &= ~CMIC_MASK_FLAG_LOG_USAGE;
2817+
28142818
s_bPreventClosing=true;
28152819
for (auto& it : s_Menus)
28162820
{

Src/StartMenu/StartMenuDLL/MenuContainer.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ bool CMenuContainer::s_bMRULoaded=false;
345345
const CItemManager::ItemInfo *CMenuContainer::s_JumpAppInfo;
346346
CJumpList CMenuContainer::s_JumpList;
347347
int CMenuContainer::s_TaskBarId;
348-
HWND CMenuContainer::s_TaskBar, CMenuContainer::s_StartButton;
348+
HWND CMenuContainer::s_TaskBar;
349+
HWND CMenuContainer::s_StartButton; // custom start button (if any)
349350
UINT CMenuContainer::s_TaskBarEdge;
350351
RECT CMenuContainer::s_StartRect;
351352
HWND CMenuContainer::s_LastFGWindow;
@@ -7507,17 +7508,32 @@ RECT CMenuContainer::CalculateWorkArea( const RECT &taskbarRect )
75077508
return rc;
75087509
}
75097510

7511+
// Calculates start menu position
75107512
POINT CMenuContainer::CalculateCorner( void )
75117513
{
75127514
RECT margin={0,0,0,0};
75137515
if (IsAppThemed())
75147516
AdjustWindowRect(&margin,GetWindowLong(GWL_STYLE),FALSE);
75157517

75167518
POINT corner;
7517-
if (m_Options&CONTAINER_LEFT)
7518-
corner.x=s_MainMenuLimits.left+margin.left;
7519+
if (IsWin11())
7520+
{
7521+
// start button can be in the center on Win11
7522+
// we want to show menu at the position of start button
7523+
if (m_Options&CONTAINER_LEFT)
7524+
corner.x=s_StartRect.left+margin.left;
7525+
else
7526+
corner.x=s_StartRect.right+margin.right;
7527+
}
75197528
else
7520-
corner.x=s_MainMenuLimits.right+margin.right;
7529+
{
7530+
// start button can be only in corner on older systems
7531+
// we can use screen limits to determine menu position
7532+
if (m_Options&CONTAINER_LEFT)
7533+
corner.x=s_MainMenuLimits.left+margin.left;
7534+
else
7535+
corner.x=s_MainMenuLimits.right+margin.right;
7536+
}
75217537

75227538
if (m_Options&CONTAINER_TOP)
75237539
{
@@ -7636,6 +7652,9 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
76367652
// initialize all settings
76377653
bool bErr=false;
76387654
HMONITOR initialMonitor=MonitorFromWindow(s_TaskBar,MONITOR_DEFAULTTONEAREST);
7655+
// note: GetTaskbarPosition properly identifies monitor in case of multi-monitor setup and automatic taskbar hiding
7656+
GetTaskbarPosition(s_TaskBar,NULL,&initialMonitor,NULL);
7657+
76397658
int dpi=CItemManager::GetDPI(true);
76407659
if (!CItemManager::GetDPIOverride() && GetWinVersion()>=WIN_VER_WIN81)
76417660
{

0 commit comments

Comments
 (0)