Ah .... finally!!!
I finally made it work (more then 1 year after my first attempt).
The widget needs to be first shown before I can access it's window
property and finally hide it =/
I think I already mentioned that before, but I really dislike Gtk.
A working version:
program gtk_entry_test;
{$mode objfpc}
uses
glib, gdk, gtk;
function delete_event (widget : pGtkWidget ; event: pGdkEvent; data:
pgpointer ): integer; cdecl;
begin
writeln('Delete Event Occurred');
delete_event := ord(true);
gtk_main_quit();
end;
procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
begin
gtk_main_quit();
end;
var
window, entry : PGtkWidget;//GtkWidget is the storage type for widgets
cursorbits: array[0..31] of char;
cursormask: array[0..31] of char;
source, mask: PGdkBitmap;
cursor: PGdkCursor;
fg, bg: TGdkColor;
begin
// This is called in all GTK applications. Arguments are parsed
// from the command line and are returned to the application.
gtk_init (@argc, @argv);
// create a new window
window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
// When the window is given the "delete_event" signal (this is given
// by the window manager, usually by the 'close' option, or on the
// titlebar), we ask it to call the delete_event () function
// as defined above. The data passed to the callback
// function is NULL and is ignored in the callback function.
gtk_signal_connect (pGTKOBJECT (window), 'delete_event',
GTK_SIGNAL_FUNC (@delete_event), NIL);
// Here we connect the "destroy" event to a signal handler.
// This event occurs when we call gtk_widget_destroy() on the window,
// or if we return 'FALSE' in the "delete_event" callback.
gtk_signal_connect (pGTKOBJECT (window), 'destroy',
GTK_SIGNAL_FUNC (@destroy), NULL);
// Sets the border width of the window.
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
// Creates a new entry with the label "Hello World".
entry := gtk_entry_new ();
// This packs the entry into the window (a gtk container).
gtk_container_add (GTK_CONTAINER (window), entry);
// The final step is to display this newly created widget.
gtk_widget_show (entry);
// and the window
gtk_widget_show (window);
// Now Hide the cursor
FillChar(cursorbits, SizeOf(cursorbits), #0);
FillChar(cursormask, SizeOf(cursormask), #0);
FillChar(fg, SizeOf(fg), #0);
FillChar(bg, SizeOf(bg), #0);
source := gdk_bitmap_create_from_data (nil, cursorbits, 4, 4);
mask := gdk_bitmap_create_from_data (nil, cursormask, 4, 4);
cursor := gdk_cursor_new_from_pixmap (source, mask, @fg, @bg, 0, 0);
gdk_pixmap_unref (source);
gdk_pixmap_unref (mask);
gdk_window_set_cursor(window^.window, cursor);
// All GTK applications must have a gtk_main(). Control ends here
// and waits for an event to occur (like a key press or
// mouse event).
gtk_main ();
end.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives