2016-12-21 33 views
0

我想找到一個解決方案來啓動一個窗口作爲屏幕大小的函數。我知道有Gtk :: Window的方法resize(),但它只是像素而不是百分比,這是問題所在。如何啓動窗口作爲屏幕大小的函數?

謝謝!

+0

獲得屏幕分辨率[描述在這裏](http://stackoverflow.com/questions/4631292/how-detect-current-screen-resolution)並用這些值調整它的大小。 – izlin

+0

它不會工作,因爲gtkmm 3與OpenGL不兼容 –

回答

0

你可以在像素的屏幕寬度和高度的快速和骯髒的方式是這樣的:

#include <Windows.h> // Need this to get the screen resolution. 

// Get the horizontal and vertical screen sizes in pixels: 
static void GetDesktopResolution(int& horizontal, int& vertical) { 
    SetProcessDPIAware(); 

    horizontal = GetSystemMetrics(SM_CXVIRTUALSCREEN); 
    vertical = GetSystemMetrics(SM_CYVIRTUALSCREEN); 
} 

對於更高級的功能,如處理多個顯示器,請從第一個評論的鏈接你的問題。那裏的答案不僅適用於OpenGL。