|
发表于 2003-8-30 10:08:35
|
显示全部楼层
我也来试试
[code:1]
#include <gtk/gtk.h>
void on_button_clicked(GtkWidget* button, gpointer userdata)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL |GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
(gchar*)userdata);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
int main(int argc, char* argv[])
{
GtkWidget *window, *button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",
G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"Hello World!");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
button=gtk_button_new_with_label("Hello World!");
g_signal_connect(G_OBJECT(button),"clicked",
G_CALLBACK(on_button_clicked),(gpointer)"你好!\n自由的世界。");
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return FALSE;
}
[/code:1] |
|