Using GTK & GDK-API

Linux specific forum
Andras
User
User
Posts: 34
Joined: Wed Oct 27, 2004 6:58 am
Location: Germany

Using GTK & GDK-API

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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)
quidquid Latine dictum sit altum videtur
Andras
User
User
Posts: 34
Joined: Wed Oct 27, 2004 6:58 am
Location: Germany

Post 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.)
Post Reply