forked from Ivasoft/DSView
fix: The mouse scroll wheel cannot be used in Windows 7
This commit is contained in:
@@ -759,8 +759,16 @@ void MainFrame::AttachNativeWindow()
|
||||
_titleBar->EnableAbleDrag(false);
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
||||
if (nativeWindow->IsWin7()){
|
||||
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
}
|
||||
else{
|
||||
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
}
|
||||
|
||||
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
|
||||
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
|
||||
SetParent((HWND)winId(), nativeWindow->Handle());
|
||||
|
||||
setVisible(true);
|
||||
|
||||
@@ -726,9 +726,15 @@ void WinNativeWidget::hideBorder()
|
||||
}
|
||||
}
|
||||
|
||||
bool WinNativeWidget::isWinXOrGreater(DWORD major_version, DWORD minor_version, DWORD build_number)
|
||||
{
|
||||
bool is_win_x_or_greater = false;
|
||||
bool WinNativeWidget::getWinSysVersion(DWORD *major_version, DWORD *minor_version, DWORD *build_number)
|
||||
{
|
||||
assert(major_version);
|
||||
assert(minor_version);
|
||||
assert(build_number);
|
||||
|
||||
*major_version = 0;
|
||||
*minor_version = 0;
|
||||
*build_number = 0;
|
||||
|
||||
typedef NTSTATUS(WINAPI *tRtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||
tRtlGetVersion pRtlGetVersion = tRtlGetVersion(QLibrary::resolve("ntdll", "RtlGetVersion"));
|
||||
@@ -739,20 +745,47 @@ bool WinNativeWidget::isWinXOrGreater(DWORD major_version, DWORD minor_version,
|
||||
memset(&os_info, 0, sizeof(OSVERSIONINFOEXW));
|
||||
os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
||||
NTSTATUS status = pRtlGetVersion(&os_info);
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
is_win_x_or_greater = (os_info.dwMajorVersion >= major_version &&
|
||||
os_info.dwMinorVersion >= minor_version &&
|
||||
os_info.dwBuildNumber >= build_number);
|
||||
{
|
||||
*major_version = os_info.dwMajorVersion;
|
||||
*minor_version = os_info.dwMinorVersion;
|
||||
*build_number = os_info.dwBuildNumber;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return is_win_x_or_greater;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WinNativeWidget::IsWin11OrGreater()
|
||||
{
|
||||
return isWinXOrGreater(10, 0, 22000);
|
||||
DWORD major_version = 0;
|
||||
DWORD minor_version = 0;
|
||||
DWORD build_number = 0;
|
||||
|
||||
if (getWinSysVersion(&major_version, &minor_version, &build_number)){
|
||||
if (major_version >= 10 && build_number >= 22000){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WinNativeWidget::IsWin7()
|
||||
{
|
||||
DWORD major_version = 0;
|
||||
DWORD minor_version = 0;
|
||||
DWORD build_number = 0;
|
||||
|
||||
if (getWinSysVersion(&major_version, &minor_version, &build_number)){
|
||||
if (major_version == 6 && minor_version == 1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int WinNativeWidget::GetDevicePixelRatio()
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
|
||||
void SetBorderColor(QColor color);
|
||||
bool IsWin11OrGreater();
|
||||
bool IsWin7();
|
||||
|
||||
inline void SetTitleBarWidget(QWidget *w){
|
||||
_titleBarWidget = w;
|
||||
@@ -99,8 +100,8 @@ public:
|
||||
static void EnalbeNoClientArea(bool bEnabled);
|
||||
|
||||
private:
|
||||
QScreen* screenFromCurrentMonitorHandle();
|
||||
bool isWinXOrGreater(DWORD major_version, DWORD minor_version, DWORD build_number);
|
||||
QScreen* screenFromCurrentMonitorHandle();
|
||||
bool getWinSysVersion(DWORD *major_version, DWORD *minor_version, DWORD *build_number);
|
||||
void showBorder();
|
||||
void hideBorder();
|
||||
static RECT GetMonitorArea(HMONITOR hMonitor, bool isPhysics);
|
||||
|
||||
Reference in New Issue
Block a user