2 回答
TA贡献1993条经验 获得超5个赞
自定义调函数捕捉化化信号用自函数进行处理行 #include #include gtk.h> void callback(gpointer data) { GtkWidget *window=GTK_WIDGET(data); switch(gdk_window_get_state(GDK_WINDOW(window->window))) { case 一<<0/* GDK_WINDOW_STATE_WITHDRAWN*/: printf("GDK_WINDOW_STATE_WITHDRAWN:the window is not shown.\n");break; case 一<<一/* GDK_WINDOW_STATE_ICONIFIED*/: printf("GDK_WINDOW_STATE_ICONIFIED:the window is minimized.\n");break;//化处理 case 一<<二/* GDK_WINDOW_STATE_MAXIMIZED*/: printf("GDK_WINDOW_STATE_MAXIMIZED:the window is maximized.\n");break;//化处理 case 一<<三/* GDK_WINDOW_STATE_STICKY*/: printf("GDK_WINDOW_STATE_STICKY:the window is sticky.\n");break; case 一<<四/* GDK_WINDOW_STATE_FULLSCREEN*/: printf("GDK_WINDOW_STATE_FULLSCREEN:the window is maximized without decorations.\n");break; case 一<<5/* GDK_WINDOW_STATE_ABOVE*/: printf("GDK_WINDOW_STATE_ABOVE:the window is kept above other windows. \n");break; case 一<<陆/* GDK_WINDOW_STATE_BELOW*/: printf("GDK_WINDOW_STATE_BELOW:the window is kept below other windows. \n");break; default:break; } } int main(int argc,char *argv[]) { gtk_init(&argc,&argv); GtkWidget *window; window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); g_signal_connect_swapped(window,"window_state_event", G_CALLBACK(callback),window); gtk_main(); return 一; }
TA贡献1796条经验 获得超4个赞
这个是我把楼上的答案重新整理了以下,发现是对的
#include <gtk/gtk.h>
void callback(gpointer data)
{
GtkWidget *window=GTK_WIDGET(data);
switch(gdk_window_get_state(GDK_WINDOW(window->window)))
{
case GDK_WINDOW_STATE_WITHDRAWN :printf("GDK_WINDOW_STATE_WITHDRAWN:the window is not shown.\n"); break;
case GDK_WINDOW_STATE_ICONIFIED:printf("GDK_WINDOW_STATE_ICONIFIED:the window is minimized.\n");break;//化处理
case GDK_WINDOW_STATE_MAXIMIZED:printf("GDK_WINDOW_STATE_MAXIMIZED:the window is maximized.\n");break;//化处理
case GDK_WINDOW_STATE_STICKY:printf("GDK_WINDOW_STATE_STICKY:the window is sticky.\n");break;
case GDK_WINDOW_STATE_FULLSCREEN: printf("GDK_WINDOW_STATE_FULLSCREEN:the window is maximized without decorations.\n");break;
case GDK_WINDOW_STATE_ABOVE:printf("GDK_WINDOW_STATE_ABOVE:the window is kept above other windows. \n");break;
case GDK_WINDOW_STATE_BELOW: printf("GDK_WINDOW_STATE_BELOW:the window is kept below other windows. \n");break;
default:break;
}
}
int main(int argc,char *argv[])
{
gtk_init(&argc,&argv);
GtkWidget *window;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
g_signal_connect_swapped(window,"window_state_event", G_CALLBACK(callback),window);
gtk_main();
return 0;
}
- 2 回答
- 0 关注
- 1268 浏览
添加回答
举报