I tried putting the commands in the callback signal_realize signal_realize().connect (sigc::mem_fun (*this, &ExampleWindow::onWindowRealize)); void ExampleWindow::onWindowRealize() { Glib::RefPtr<Gdk::Window> win = get_window(); Glib::RefPtr<Gdk::GC> some_gc = Gdk::GC::create(win); Glib::RefPtr<Gdk::Colormap> some_colormap = get_default_colormap(); my_gray.set_red(0xc900); my_gray.set_green(0xca00); my_gray.set_blue(0xc800); some_colormap->alloc_color(my_gray); my_blue.set_red(0x0000); my_blue.set_green(0x7200); my_blue.set_blue(0xc800); some_colormap->alloc_color(my_blue); some_gc->set_foreground(my_gray); some_gc->set_background(my_blue); } The program console showed: (Hello:2839): Gdk-CRITICAL **: gdk_gc_new: assertion `drawable != NULL' failed (Hello:2839): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed But the background and foreground were unchanged. I also tried using: Glib::RefPtr<Gdk::Window> win = get_window(); gtk_widget_modify_bg( GtkWidget(win), (GtkStateType)Gtk::STATE_NORMAL, (GdkColor*)&my_blue ); gtk_widget_modify_fg( GtkWidget(win), (GtkStateType)Gtk::STATE_NORMAL, (GdkColor*)&my_gray ); It won’t compile because it does not like the reference pointer to widget conversion. Any other ideas ?? Randy Seedle PS: This solution needs to work with “Gtkmm”. From: José Alburquerque [mailto:jaalburquerque cox net] El Jan 10, 2011, a las 4:32 PM, "Charles Seedle" <charles seedle rigaku com> escribió:
When getting the window of a widget, you have to be sure it is realized first. See Gtk::Widget::signal_realize(). Or maybe use one of the Gtk::Widget::modify_* methods. Randy
|