Re: [Re: [gtkmm] Get Xwindow ID from A Gtk(mm) Window (gtkmm 2.0)]



I got it :)
I had to place the code to get the xid of the Gtk window into the on_realize function.(get_window() will return 0 if the Gdk::Window has not yet been realized)

this is the working code to get the xid of a Gtk::Window:

void full::on_realize()
{
    
    Gtk::Window::on_realize();
    gwindow = get_window();//gwindow is a Glib::RefPtr<Gdk::Window>
    if(gwindow)
	xwin = GDK_WINDOW_XID(gwindow ->gobj());
    std::cout<<"on_realize occoured\n";    
    std::cout<<"xwin id: "<<xwin<<"\n";
}


On Wed, 06 Aug 2003 14:46:43 +0200
Murray Cumming <murrayc usa net> wrote:

> stephan wezel <s wezel web de> wrote:
> > hmm it doesn't work :(
> > i can't compile it. I get following error:
> > 
> > main.cpp: In constructor `full::full()':
> > main.cpp:356: cannot convert `_GdkDrawable' to `GdkDrawable*' for argument
> `1' 
> >    to `XID gdk_x11_drawable_get_xid(GdkDrawable*)'
> > make: *** [main.o] Fehler 1
> 
> You might need to #include a gtk header. gtk.h would get you everything you
> need.
> 
> > When i use 
> > GDK_WINDOW_XID((get_frame()->gobj())); in place of 
> GDK_WINDOW_XID(*(get_frame()->gobj()));
> > is can compile it. 
> > But when i want to start the programm, i become a Memory access error.
> 
> You should probably check the result of get_frame() for null.
> e.g.
> Glib::RefPtr<Gdk::Window> refWindow = get_frame();
> if(refWindow)
>   ... GDK_WINDOW_XID( refWindow ->gobj() );
> 
> However, I've never heard of get_frame(). I would have tried get_window()
> first. But I never do this stuff.
> 
> 
> Murray Cumming
> murrayc usa net
> www.murrayc.com
> 
> 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]