Re: hwnd on win32
- From: "T.J. Ferraro" <tjtoocool phreaker net>
- To: Gtk2-Perl Mailing List <gtk-perl-list gnome org>
- Subject: Re: hwnd on win32
- Date: Fri, 23 May 2008 01:24:47 -0700
Torsten Schoenfeld wrote:
T.J. Ferraro wrote:
Trying to get the hwnd of a Gtk2::Gdk::Drawable on win32. After pouring
through source I noticed nothing was being exported for this in
gtk2-perl. I'm not really an XS expert (yet...) so I threw together a
quick hack to try to get this working for me.
I modified GdkDrawable.xs by adding...
#include <gdk/gdkwin32.h>
And the following:
## HGDIOBJ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
gpointer
gdk_win32_drawable_get_handle (drawable)
GdkDrawable *drawable
This would make more sense in a separate XS file GdkWin32.xs that only
gets compiled on the relevant platforms -- just like GdkX11.xs. If you
want your changes going in, I think this is the way to go.
I tried the following in a separate file GdkWin32.xs and instructed
Makefile.PL to add this file to the xs list if the platform was win32.
It compiles, but neither get_handle or gdk_win32_drawable_get_handle
appear as a Gtk2::Gdk::Drawable method...
#include "gtk2perl.h"
#include <gdk/gdkwin32.h>
MODULE = Gtk2::Gdk::Win32 PACKAGE = Gtk2::Gdk::Drawable PREFIX =
gdk_win32_drawable_
## HGDIOBJ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
gpointer
gdk_win32_drawable_get_handle (drawable)
GdkDrawable *drawable
I call it as:
my $hwnd = Gtk2::Gdk::Drawable::gdk_win32_drawable_get_handle($drawable);
If you put the XSUB in its own MODULE ... PACKAGE ... PREFIX section,
you can turn that into
my $hwnd = $drawable->get_handle();
Or maybe better yet
my $hwnd = $drawable->get_win32_handle();
I applied your suggestion to my hack and put the following into
GdkDrawable.xs and now I can call the method get_handle on any drawable
and it works like a charm, thanks :)
MODULE = Gtk2::Gdk::Drawable PACKAGE = Gtk2::Gdk::Drawable PREFIX
= gdk_win32_drawable_
## HGDIOBJ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
gpointer
gdk_win32_drawable_get_handle (drawable)
GdkDrawable *drawable
Works (a little ugly), but as you can imagine, it's not handing me back
an hwnd, but rather numbers like: 1310846, 1245310, 983164.
Are these actual gpointers or am I getting garbage? Any way to
dereference if it is actually returning a gpointer?
As you found out yourself, you get back a numeric representation of the
pointer. You won't be able to do much with this pointer in pure Perl,
though. There would need to be another CPAN module that provides XS
wrappers for whatever function you want to pass this handle to.
I think you missed the follow up email I sent later. It actually turns
out it was in fact returning the value; the handle was being returned as
a base10 integer instead of base16. After getting that I just had to
sprintf("%x", $hwnd) and now I have what I need. I've been trying to get
this working as a separate xs file for about an hour to no avail. Since
I've got it working exactly as I wanted it to in the Drawable xs
file...I'm going to have to put off finishing that until next week when
I have more time. Thanks for the help =)
T.J.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]