2016-04-04 48 views
2

我想在Qt5.6.0,使用航空捕捉功能使無邊界窗口。 一切工作,除非我最大化窗口:它太大了。無界限窗口與航空捕捉太大,處於最大化狀態

我的屏幕分辨率是2560x1440,所以窗口的大小應2560x1400(任務欄40個像素),但在WM_SIZE消息,新的大小2576x1416。因此,窗口在每個方向上都只有8個像素太大。 這也意味着窗口沒有在左上角對齊,它在兩個方向上正好是8個像素的屏幕。

我找不到這個問題的解決方案,我嘗試過的所有東西都不起作用並導致錯誤。

修復此問題的唯一方法是刪除WS_CAPTIONWS_THICKFRAME樣式,但後來我失去了areo捕捉功能。

我不知道如何告訴Qt或DWM使窗口變小16個像素,然後向右移動8個像素,然後移動底部。有沒有人有關於如何做到這一點的想法?

回答

0

我的第一次嘗試,是窗口的尺寸設置爲可用的幾何形狀:

QRect rect = QApplication::desktop()->availableGeometry(); 
setGeometry(rect.left() , rect.top(), rect.right(), rect.bottom()); 

唯一的問題是,該窗口是一個像素的右側和下側和

setGeometry(rect.left() , rect.top(), rect.right() + 1, rect.bottom() + 1); 
太小

給我一個錯誤:

QWindowsWindow::setGeometry: Unable to set geometry 2560x1400+0+0 on QWidgetWindow/'MainWindowWindow'. Resulting geometry: 2576x1416+-8+-8 (frame: 0, 0, 0, 0, custom margin: 0, 0, 0, 0, minimum size: 45x13, maximum size: 16777215x16777215) 

然後我看着Visual Studio 2的矩形座標015,它們與我實現無邊框窗口的大小相同,每個方向都有8個像素。

我可以給我的窗口爲8的餘量,因此不會夾出屏幕,如果最大化了窗口的內容,並設置窗口區域:

setContentsMargins({ 8, 8, 8, 8 }); 

HRGN WinRgn; 
RECT winrect; 
GetClientRect(hwnd, &winrect); 
WinRgn = CreateRectRgn(8, 8, winrect.right - 8, winrect.bottom - 8); 
SetWindowRgn(hwnd, WinRgn, true); 

當窗口被恢復,我們需要重置之前的更改。 結果是:

case WM_SIZE: 
    WINDOWPLACEMENT wp; 
    wp.length = sizeof(WINDOWPLACEMENT); 
    GetWindowPlacement(hwnd, &wp); 
    if (wp.showCmd == SW_MAXIMIZE) { 
     setContentsMargins({ 8, 8, 8, 8 }); 

     HRGN WinRgn; 
     RECT winrect; 
     GetClientRect(hwnd, &winrect); 
     WinRgn = CreateRectRgn(8, 8, winrect.right - 8, winrect.bottom - 8); 
     SetWindowRgn(hwnd, WinRgn, true); 
     UpdateWindow(hwnd); 

     is_fullscreen = true; 

    } else { 
     if (is_fullscreen) { 
      setContentsMargins({ 0, 0, 0, 0 }); 
      SetWindowRgn(hwnd, NULL, true); 

      is_fullscreen = false; 
     } 
    } 
    break; 
0

I somehow have to tell Qt or DWM to make the window 16 pixels smaller and move it 8 pixels right, and bottom. Does anybody have an idea on how to do that?

DWM是桌面窗口管理器?那麼平臺就是Windows。

只要是關於Qt 5.6,你很可能在談論使用Qt :: CustomizeWindowHint小部件屬性設置則在Qt的一個已知的錯誤,這是不固定尚未:

https://bugreports.qt.io/browse/QTBUG-4362

我偶然偶然發現了這個錯誤,並在上面的鏈接中提出了BiTOk的解決方法。

相關問題