Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-06

gdk_window_get_frame_extents

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Airr

Hello, all.

I'm trying to get the current position and size of a GTK2 gtkwindow using the following:

===
function configure_event(widget: PGtkWidget; event : PGdkEvent; data  :
gpointer):gboolean;cdecl;
var
  grect :PGdkRectangle;
begin
  gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),@grect);
  configure_event := True;
end;
===

The signal is attached to the window via:

===
g_signal_connect (G_OBJECT (window), 'configure_event',

                              G_CALLBACK (@configure_event), NULL);

===

Executing the program results in:

An unhandled exception occurred at $0000004B :
EAccessViolation : Access violation
$0000004B

FPC version is:
Free Pascal Compiler version 2.0.4 [2007/02/02] for i386

OS is: Kubuntu 7.04

Any thoughts on why this is causing the AV?

Thanks!

AIR.

"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.
Flávio Etrusco
to Airr

I don't have access to FPC right now, but it seems as if PGdkRectangle is a pointer type already, not a record type?

-Flávio

Airr wrote 50 lines
Hello, all. I'm trying to get the current position and size of a GTK2 gtkwindow using the following: === function configure_event(widget: PGtkWidget; event : PGdkEvent; data : gpointer):gboolean;cdecl; var grect :PGdkRectangle; begin gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),@grect); configure_event := True; end; === The signal is attached to the window via: === g_signal_connect (G_OBJECT (window), 'configure_event', G_CALLBACK (@configure_event), NULL); === Executing the program results in: An unhandled exception occurred at $0000004B : EAccessViolation : Access violation $0000004B FPC version is: Free Pascal Compiler version 2.0.4 [2007/02/02] for i386 OS is: Kubuntu 7.04 Any thoughts on why this is causing the AV? Thanks! AIR. -- "Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Airr
to Flávio Etrusco
I don't have access to FPC right now, but it seems as if PGdkRectangle is a pointer type already, not a record type? -Flávio

Thanks for that. If I replace the PGtkRectangle with a TRect, or a simple home-grown Rect record type, it works fine.

So now my question is, how would I use the pointer to GtkRectangle in the function? Sorry for asking such a basic question, but I'm reacquainting myself with Pascal.

Thanks again!

AIR.

"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.
Unknown author
to Airr: Hello, all. I'm trying to get the current position and size of a GTK2 gtkwindow using the…
Show quoted text 13 lines
var grect :PGdkRectangle; begin gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),@grect); configure_event := True; end; ===

fpc header for the gdk function is

	procedure gdk_window_get_frame_extents(window:PGdkWindow; rect:PGdkRectangle);

so, having grect: pGDKRectangle declared, you should use it rather by

	gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),grect);

With regards,

Jan Je/lowicki
----------------------------------------------------------------- Department of Mathematics Katedra Matematyki University of Life Sciences Uniwersytet Przyrodniczy Wroc/law, POLAND
-----------------------------------------------------------------

Flávio Etrusco
to Unknown author
Show quoted text 22 lines
> > > var > grect :PGdkRectangle; > > begin > gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),@grect); > > > configure_event := True; > end; > === fpc header for the gdk function is procedure gdk_window_get_frame_extents(window:PGdkWindow; rect:PGdkRectangle); so, having grect: pGDKRectangle declared, you should use it rather by gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),grect);

Yes and no. The correct fix is to declare grect as GdkRectagle, as you need to pass to the function the pointer to an allocated record.

-Flávio

Unknown author
to Flávio Etrusco
Show quoted text 6 lines
Yes and no. The correct fix is to declare grect as GdkRectagle, as you need to pass to the function the pointer to an allocated record.

Surely you're right.

Jan Je/lowicki
----------------------------------------------------------------- Department of Mathematics Katedra Matematyki University of Life Sciences Uniwersytet Przyrodniczy Wroc/law, POLAND
-----------------------------------------------------------------

Airr
to Flávio Etrusco: Yes and no. The correct fix is to declare grect as GdkRectagle, as you need to pass to…
Show quoted text 18 lines
On 6/4/07, wrote: > > fpc header for the gdk function is > > procedure gdk_window_get_frame_extents(window:PGdkWindow; > rect:PGdkRectangle); > > so, having grect: pGDKRectangle declared, you should use it rather > by > > gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),grect); > Yes and no. The correct fix is to declare grect as GdkRectagle, as you need to pass to the function the pointer to an allocated record. -Flávio

Thanks, everyone.

I got it working by using:

grect : TGdkRectangle;
gdk_window_get_frame_extents(GDK_WINDOW(widget^.window),@grect);

AIR.

"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.