kthakore,

I've produced code to test for get_handle on Windows, and follows at
the end of this message. As it is, it works for me (with the distro of
the SDL module you provided on IRC, and on Perl v5.12.0 built for
MSWin32-x86-multi-thread on Vista x64). I hope it's useful enough for
you.

It uses the "IsWindow" function from the Win32 API to test whether the
handle we get from SDL::get_handle is a valid window handle.
Win32::API is distributed with 32-bit Windows Perl distributions, but
I don't think it works in 64-bit ones, yet. Note that $^E holds the
error message when Win32::API fails to import a function. I suppose
the test only makes sense when $^O is either 'MSWin32' or 'cygwin'
(Win32::API works in cygwin Perl, but I haven't tried SDL there yet),
but I don't know if what I have here is proper.

Let me know if there's any more I can do. Thank you so much for the
work to get this functionality in Perl's SDL bindings!

burnedcelery



#!perl
use strict;
use warnings;
use SDL;
use SDLx::App;
use Test::More;

if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
        plan( tests => 1 );
        ok( win32_hwnd(), "got a valid window handle on win32" );
}

sub win32_hwnd {
        require Win32::API;
        # IsWindow Function:
http://msdn.microsoft.com/en-us/library/ms633528%28v=vs.85%29.aspx
        my $IsWindow = Win32::API->new(qw/user32 IsWindow N N/);
        unless ($IsWindow) {
                die "error importing IsWindow with Win32::API: $^E";
        }
        my $wnd = SDLx::App->new( eoq => 1 );
        my $hwnd = SDL::get_handle();
        return $IsWindow->Call($hwnd) ? 1 : 0;
}

Reply via email to