This commit is contained in:
zhuzichu 2023-12-15 16:04:00 +08:00
parent 7ba06d183d
commit 95f48b51bf
3 changed files with 20 additions and 0 deletions

View File

@ -46,11 +46,13 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
} }
return false; return false;
}else if(uMsg == WM_NCCALCSIZE){ }else if(uMsg == WM_NCCALCSIZE){
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
NCCALCSIZE_PARAMS& sz = *reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam); NCCALCSIZE_PARAMS& sz = *reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam);
if (sz.rgrc[0].top != 0) if (sz.rgrc[0].top != 0)
sz.rgrc[0].top -= 1; sz.rgrc[0].top -= 1;
*result = WVR_REDRAW; *result = WVR_REDRAW;
return true; return true;
#endif
} }
return false; return false;
#endif #endif
@ -163,6 +165,7 @@ void FluFrameless::componentComplete(){
HWND hWnd = reinterpret_cast<HWND>(_window->winId()); HWND hWnd = reinterpret_cast<HWND>(_window->winId());
ULONG_PTR cNewStyle = GetClassLongPtr(hWnd, GCL_STYLE) | CS_DROPSHADOW; ULONG_PTR cNewStyle = GetClassLongPtr(hWnd, GCL_STYLE) | CS_DROPSHADOW;
SetClassLongPtr(hWnd, GCL_STYLE, cNewStyle); SetClassLongPtr(hWnd, GCL_STYLE, cNewStyle);
SetWindowPos(hWnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
#endif #endif
} }
} }

View File

@ -70,6 +70,7 @@ Window {
} }
lifecycle.onCompleted(window) lifecycle.onCompleted(window)
initArgument(argument) initArgument(argument)
moveWindowToDesktopCenter()
if(window.autoMaximize){ if(window.autoMaximize){
window.showMaximized() window.showMaximized()
}else{ }else{
@ -248,6 +249,15 @@ Window {
} }
return true return true
} }
Rectangle{
color: parent.border.color
width: parent.width
height: 1
anchors{
top: parent.top
topMargin: 1
}
}
} }
function destoryOnClose(){ function destoryOnClose(){
lifecycle.onDestoryOnClose() lifecycle.onDestoryOnClose()
@ -275,6 +285,9 @@ Window {
function registerForWindowResult(path){ function registerForWindowResult(path){
return lifecycle.createRegister(window,path) return lifecycle.createRegister(window,path)
} }
function moveWindowToDesktopCenter(){
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height)
}
function onResult(data){ function onResult(data){
if(_pageRegister){ if(_pageRegister){
_pageRegister.onResult(data) _pageRegister.onResult(data)

View File

@ -69,6 +69,7 @@ Window {
} }
lifecycle.onCompleted(window) lifecycle.onCompleted(window)
initArgument(argument) initArgument(argument)
moveWindowToDesktopCenter()
if(window.autoMaximize){ if(window.autoMaximize){
window.showMaximized() window.showMaximized()
}else{ }else{
@ -274,6 +275,9 @@ Window {
function registerForWindowResult(path){ function registerForWindowResult(path){
return lifecycle.createRegister(window,path) return lifecycle.createRegister(window,path)
} }
function moveWindowToDesktopCenter(){
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height)
}
function onResult(data){ function onResult(data){
if(_pageRegister){ if(_pageRegister){
_pageRegister.onResult(data) _pageRegister.onResult(data)