Skip to content

Commit dcc883d

Browse files
committed
在Wine环境下时任务栏窗口显示在桌面的右下角
1 parent a1acee8 commit dcc883d

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
lines changed

TrafficMonitor/TrafficMonitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,10 +1302,10 @@ void CTrafficMonitorApp::UpdatePluginMenu(CMenu* pMenu, ITMPlugin* plugin, int p
13021302

13031303
void CTrafficMonitorApp::CheckWindows11Taskbar()
13041304
{
1305-
HWND hTaskbar = ::FindWindow(L"Shell_TrayWnd", NULL);
13061305
// 在“Shell_TrayWnd”的子窗口找到类名为“Windows.UI.Composition.DesktopWindowContentBridge”的窗口则认为是Windows11的任务栏
13071306
if (m_win_version.IsWindows11OrLater())
13081307
{
1308+
HWND hTaskbar = ::FindWindow(L"Shell_TrayWnd", NULL);
13091309
m_is_windows11_taskbar = (::FindWindowExW(hTaskbar, 0, L"Windows.UI.Composition.DesktopWindowContentBridge", NULL) != NULL);
13101310
}
13111311
else

TrafficMonitor/TrafficMonitor.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@
865865
<ClInclude Include="Win11TaskbarSettingDlg.h" />
866866
<ClInclude Include="WindowsSettingHelper.h" />
867867
<ClInclude Include="WindowsWebExperienceDetector.h" />
868+
<ClInclude Include="WineTaskbarDlg.h" />
868869
<ClInclude Include="WinVersionHelper.h" />
869870
</ItemGroup>
870871
<ItemGroup>
@@ -981,6 +982,7 @@
981982
<ClCompile Include="Win11TaskbarSettingDlg.cpp" />
982983
<ClCompile Include="WindowsSettingHelper.cpp" />
983984
<ClCompile Include="WindowsWebExperienceDetector.cpp" />
985+
<ClCompile Include="WineTaskbarDlg.cpp" />
984986
<ClCompile Include="WinVersionHelper.cpp" />
985987
</ItemGroup>
986988
<ItemGroup>

TrafficMonitor/TrafficMonitor.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@
553553
<ClInclude Include="DisplayItem.h">
554554
<Filter>源文件和头文件\公共的类\DisplayItem</Filter>
555555
</ClInclude>
556+
<ClInclude Include="WineTaskbarDlg.h">
557+
<Filter>源文件和头文件\TaskBarDlg</Filter>
558+
</ClInclude>
556559
</ItemGroup>
557560
<ItemGroup>
558561
<ClCompile Include="StaticEx.cpp">
@@ -819,6 +822,9 @@
819822
<ClCompile Include="DisplayItem.cpp">
820823
<Filter>源文件和头文件\公共的类\DisplayItem</Filter>
821824
</ClCompile>
825+
<ClCompile Include="WineTaskbarDlg.cpp">
826+
<Filter>源文件和头文件\TaskBarDlg</Filter>
827+
</ClCompile>
822828
</ItemGroup>
823829
<ItemGroup>
824830
<ResourceCompile Include="TrafficMonitor.rc">

TrafficMonitor/TrafficMonitorDlg.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "SupportedRenderEnums.h"
1616
#include "ClassicalTaskbarDlg.h"
1717
#include "Win11TaskbarDlg.h"
18+
#include "WineTaskbarDlg.h"
1819
#include "TaskbarHelper.h"
1920
#include "SkinManager.h"
2021

@@ -565,7 +566,9 @@ void CTrafficMonitorDlg::OpenTaskBarWnd()
565566
{
566567
// 强制初始化theApp.m_is_windows11_taskbar的值
567568
theApp.CheckWindows11Taskbar();
568-
if (theApp.IsWindows11Taskbar())
569+
if (theApp.m_win_version.IsWine())
570+
m_tBarDlg = new CWineTaskbarDlg();
571+
else if (theApp.IsWindows11Taskbar())
569572
m_tBarDlg = new CWin11TaskbarDlg();
570573
else
571574
m_tBarDlg = new CClassicalTaskbarDlg();

TrafficMonitor/WinVersionHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CWinVersionHelper
1212
bool IsWindows8Point1OrLater() const; //判断Windows版本是否大于等于Windows8.1
1313
bool IsWindows8OrLater() const;
1414
bool IsWindows10OrLater() const;
15-
bool IsWine() const;
15+
bool IsWine() const; //判断是否在Wine环境下
1616

1717
int GetMajorVersion() const { return m_major_version; }
1818
int GetMinorVersion() const { return m_minor_version; }

TrafficMonitor/WineTaskbarDlg.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "stdafx.h"
2+
#include "WineTaskbarDlg.h"
3+
4+
void CWineTaskbarDlg::InitTaskbarWnd()
5+
{
6+
}
7+
8+
void CWineTaskbarDlg::AdjustTaskbarWndPos(bool force_adjust)
9+
{
10+
//ÒÆ¶¯µ½×ÀÃæÓÒϽÇ
11+
int screen_width = GetSystemMetrics(SM_CXSCREEN);
12+
int screen_height = GetSystemMetrics(SM_CYSCREEN);
13+
CRect rect{ m_rect };
14+
rect.MoveToXY(screen_width - m_rect.Width(), screen_height - m_rect.Height());
15+
this->MoveWindow(rect);
16+
}
17+
18+
void CWineTaskbarDlg::ResetTaskbarPos()
19+
{
20+
}
21+
22+
void CWineTaskbarDlg::CheckTaskbarOnTopOrBottom()
23+
{
24+
m_taskbar_on_top_or_bottom = true;
25+
}
26+
27+
HWND CWineTaskbarDlg::GetParentHwnd()
28+
{
29+
return GetDesktopWindow()->GetSafeHwnd();
30+
}

TrafficMonitor/WineTaskbarDlg.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
#include "TaskBarDlg.h"
3+
class CWineTaskbarDlg :
4+
public CTaskBarDlg
5+
{
6+
private:
7+
// ͨ¹ý CTaskBarDlg ¼Ì³Ð
8+
void InitTaskbarWnd() override;
9+
void AdjustTaskbarWndPos(bool force_adjust) override;
10+
void ResetTaskbarPos() override;
11+
void CheckTaskbarOnTopOrBottom() override;
12+
HWND GetParentHwnd() override;
13+
};
14+

0 commit comments

Comments
 (0)