GTK+ 隐藏鼠标指针

GTK+ 支持对 GtkWindow 类型的对象设置个性化的鼠标指针(GdkCursor)对象,使用此方法我们就可以实现在指定的窗口隐藏鼠标指针功能。

直接看代码:

GdkColor color;
GdkPixmap *pixmap = NULL;
GdkCursor *cursor = NULL;
 
gdk_color_parse("#00000000", &color);
pixmap = gdk_pixmap_new(NULL, 1, 1, 1);
cursor = gdk_cursor_new_from_pixmap(pixmap, pixmap, &color, &color, 0, 0);
gdk_window_set_cursor(gtk_widget_get_window(window), cursor);

PS: 没有效果?将这段代码最后一行放至在 gtk_widget_show(window); 之后。

Over!

2 thoughts on “GTK+ 隐藏鼠标指针”

Leave a Reply

Your email address will not be published. Required fields are marked *