GTK 設定視窗在螢幕中的位置
阿新 • • 發佈:2019-02-19
-------------------------------------------------------------------------------------------------------------------------------------------------
GdkScreen *screen = gdk_screen_get_default();
gint screen_w = gdk_screen_get_width(screen);
gint screen_h = gdk_screen_get_height(screen);gtk_widget_set_size_request(window, screen_w/6, screen_h/6); // 設定視窗的最小大小
gtk_window_move(GTK_WINDOW(window), (screen_w - (screen_w/6)-50), (screen_h - (screen_h/6)));
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gint window_w = window->allocation.width;
gint window_h = window->allocation.height;
這兩句是獲得視窗本身大小,在gtk_widget_show_all();後才有效。