Glenn L.,

Base on Rob's post yesterday, I took this a little further. By using something 
like this in the main thread:

use threads::shared;
use Data::Dumper;

my $szMW : shared;

my $obMW = [... window definition ...]

$szMW = Dumper($obMW);

Then in the thread:

my $VAR1;
my $obMWCopy = eval ($szMW);

I was able to access and use all the main window controls as usual. Data:Dumper 
is doing all the magic here, by walking the WIN32::GUI tree and stringifying 
the result. It *is* possible to share a string, so the thread then simply uses 
eval to recreate the tree locally, blessing the structures appropriately as it 
goes. Of course, the names of the controls only exist for Win32::GUI windows, 
so there would be no equivalent for a window created by another application.

The problem came, as both Rob and Jez had suggested earlier, on destruction. No 
matter what I did, I was getting error messages and, I suspect, memory leaks.

So my solution was to stick to the function-call version of the Win32::GUI 
methods for now and wait for the day when the threads developers implement 
sharing of blessed variables!

Glenn M.

------------------- reply ---------------
> From: [EMAIL PROTECTED]
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: Re: [perl-win32-gui-users] Re: Attaching to a window created by some
 other
> Date: 2005-10-07 21:40:27
> ----------------------------------
> On approximately 10/7/2005 3:10 AM, came the following characters from 
> the keyboard of Robert May:
> > Jeremy White wrote:
> > 
> >>> Coincidentally, I've been working on a similar problem and was very 
> >>> interested
> >>
> >>
> >> For example:
> >>
> >> my $win=Win32::GUI::Window::CreateFromHandle($handle);
> >> $win->Show; #no problem
> >> $win->Hide; #no problem
> >> $win->SomeControl->Show(); #how would we know a control called 
> >> 'SomeContol' exists?
> > 
> > A control called 'SomeControl' doesn't exist if this is window created 
> > outside Win32::GUI.  Navigating the window tree can't be done like this.
> 
> This points up a basic deficiency in Win32::GUI in dealing with existing 
>   Windows.
> 
> While Win32::GUI is pretty amazing, and I haven't figured out all of the 
> data structures it uses, or what the lifetime of those data structures 
> are, it seems like some of them are quite redundant with data maintained 
> by Windows.
> 
> I wonder if it would be possible to add features to Win32::GUI to "walk" 
> a tree of Windows, and rebuild the needed GUI type structures.   And I 
> say "needed GUI structures" because I wonder if all of the existing 
> structures are truly needed, or if some of the info is redundant, and 
> could be obtained by calling Windows APIs.
> 
> If this "walk" could be done locally, it could likely also be done for 
> Winows owned by other processes, with the proper injected DLL.
> 
> -- 
> Glenn -- http://nevcal.com/
> ===========================
> Having identified a vast realm of ignorance, Wolfram is saying that much
> of this realm lies forever outside the light cone of human knowledge.
>                            -- Michael Swaine, Dr Dobbs Journal, Sept 2002
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
> 


Reply via email to