獲取gtk控件位置,寬高

gint width, height;
gdk_drawable_get_size(GDK_DRAWABLE(main_window->window), &width, &height);
gint x, y;
GdkScreen* cur_screen = NULL;
GdkWindow* window = NULL;
GdkPixbuf* pixbuf_screenshot = NULL;
GdkRectangle rect;
GdkRectangle screen_rect;

screen_rect.width = gdk_screen_get_width (cur_screen); //get screen width
screen_rect.height = gdk_screen_get_height (cur_screen); //get screen height
g_print("screen_rect: x=%d,y=%d,w=%d,h=%d\n",screen_rect.x,screen_rect.y,screen_rect.width,screen_rect.height);
window = gdk_screen_get_root_window (cur_screen); //get window by screen


GdkWindow * gdk_window = gtk_widget_get_window (main_window);

gdk_window_get_origin (gdk_window, &x, &y); //get origin point

g_print("xwindow  is x:%d,y:%d\n",x,y);
gdk_window_get_position(gdk_window,&x,&y);

g_print("main_window  is x:%d,y:%d\n",x,y);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章