Page 1 of 1

Using GTK & GDK-API

Posted: Fri Nov 19, 2004 12:19 am
by Andras
Hi,

I'm trying to use GTK & GDK-API at the same time and can't seem to even move a window. What am I doing wrong?

gtk_init_(0,0)
gdk_init_(0,0)

window = gtk_window_new_(#GTK_WINDOW_TOPLEVEL)

gtk_window_set_position_(window,#GTK_WIN_POS_CENTER)

gtk_window_set_title_(window, @"MyWindow")

gtk_widget_show_(window)

;gdk_window_move_(window,200,200) ; <- This does not work...

gtk_main_()

End

Posted: Fri Nov 19, 2004 1:56 am
by freak
A GtkWindow is not the same as a GdkWindow. They are different handles.
You can't just use the 'window' variable in a gdk call.

The GtkWidget structure (which is inside the GtkWindow one) contains a field
that stores the gtk window identifyer for that widget.

first do his:

*window.GtkWidget = gtk_window_new_(#GTK_WINDOW_TOPLEVEL)

(and of course use *window instead of window for the gtk calls)
then for the gdk call, use this:

gdk_window_move_(*window\window,200,200)

(there is also *window\parent which is the gdk identifyer of the widgets parent)

Posted: Fri Nov 19, 2004 8:28 am
by Andras
Thanks, sounds good! I'll try that...

(Hatte mir auch schon sowas gedacht, bin aber in den APIs nicht so schnell drauf gestoßen.)