2015-09-24 88 views
7

我有一些代碼將窗口定位到屏幕象限。它在Windows XP,7和8/8.1上運行良好。但是,在Windows 10上,窗口之間存在一個奇怪的差距。所有四面都有額外的空間環繞着窗戶。我認爲它與窗口邊界有關,但無法弄清楚如何糾正問題。任何意見將不勝感激。代碼如下:視窗XP/7/8/8.1的窗口定位結果在Windows 10上的窗口周圍的空間

// Get monitor info 
HMONITOR hm = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); 
MONITORINFO mi; 
mi.cbSize = sizeof(mi); 
GetMonitorInfo(hm, &mi); 

// Set screen coordinates and dimensions of monitor's work area 
DWORD x = mi.rcWork.left; 
DWORD y = mi.rcWork.top; 
DWORD w = mi.rcWork.right - x; 
DWORD h = mi.rcWork.bottom - y; 

switch (corner) { 
case 0: // Left top 
    SetWindowPos(hWnd, HWND_TOP, x, y, w/2, h/2, SWP_NOZORDER); 
    break; 
case 1: // Right top 
    SetWindowPos(hWnd, HWND_TOP, x + w/2, y, w/2, h/2, SWP_NOZORDER); 
    break; 
case 2: // Right bottom 
    SetWindowPos(hWnd, HWND_TOP, x + w/2, y + h/2, w/2, h/2, SWP_NOZORDER); 
    break; 
case 3: // Left bottom 
    SetWindowPos(hWnd, HWND_TOP, x, y + h/2, w/2, h/2, SWP_NOZORDER); 
    break; 
} 
+1

是,視窗10少了點,一切都應該顯示相同的方式。請注意,調整窗口大小的熱點實際上位於右側和底部邊緣的可見框之外。窗口的可見尺寸小於實際尺寸。 –

+0

@JonathanPotter謝謝。哇,微軟另一個可笑的變化。 – Paul

+5

在我們自己的應用程序中,我們在Windows 10上有相同的行爲。我通過使用普通的'GetWindowRect'函數和使用['DwmGetWindowAttribute'函數](https://msdn.microsoft.com/ en-us/library/windows/desktop/aa969515%28v = vs.85%29.aspx)以及'DWMWA_EXTENDED_FRAME_BOUNDS'參數。 –

回答

-3

的默認字體大小是100%,但在窗10的缺省值是在125%來顯示文本和項目。這直接影響到所有的窗口大小。

轉到設置,顯示你會發現一個滾動條,將其移動到100%,因爲它在Windows 8確實/ 7/XP

+0

你不能去改變那樣的客戶端設置。 – CodeCaster