mirror of https://github.com/Alia5/GlosSI
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
C++
33 lines
1.0 KiB
C++
#pragma once
|
|
#include <QAbstractNativeEventFilter>
|
|
#include <QString>
|
|
#define NOMINMAX
|
|
#include <Windows.h>
|
|
|
|
class WinEventFilter : public QAbstractNativeEventFilter
|
|
{
|
|
public:
|
|
WinEventFilter() = default;
|
|
|
|
/*
|
|
* When having the DWM frame fully extended into client area
|
|
* ever since WIN10 a 6px border is displayed on top.
|
|
* to remove that one has to catch the WM_NCCALCSIZE event and re-calculate the window-rect
|
|
* https://stackoverflow.com/a/2135120/5106063
|
|
* https://docs.microsoft.com/en-us/windows/win32/dwm/customframe
|
|
*/
|
|
bool nativeEventFilter(const QByteArray& eventType, void* message, qintptr* result) override
|
|
{
|
|
if (QString(eventType) == "windows_generic_MSG") {
|
|
auto msg = static_cast<MSG*>(message)->message;
|
|
auto lParam = static_cast<MSG*>(message)->lParam;
|
|
if (msg == WM_NCCALCSIZE)
|
|
{
|
|
auto sz = reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam);
|
|
sz->rgrc[0].top -= 6;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|