That jpeg image viewing with fP...

Fairlight fairlite at fairlite.com
Mon Apr 4 07:43:42 PDT 2005


Simon--er, no...it was Chad McWilliams--said:
> I agree with Mark here.  I did something similar to this a few years back.
> We wanted to have filePro (running on Unix) generate a pdf file that would
> popup on the users desktop.  I wrote a small perl program that runs in the
> background on the Win machine and listens on a specified port for a
> connection.  Then the unix box also had a perl program to initiate that
> connection and send the data.  This could be used in the same way for this
> task.  It would accomplish being able to have a single window open, while
> changing what is displayed in the window.  I'm not sure if filepro would
> loose focus or not when this happened since a windows command isn't
> executing to display the image (i.e. start).

Well, my thoughts on this would be that you -could- actually start the
image viewer at boot and have it either just invisible or in the systray.
(I haven't yet figured out how to get something out of the Alt-TAB
listing).

So at start it comes up "invisible", as you'd withdraw the window
immediately at creation before you ever hit Tk's MainLoop.  Then you listen
to the socket, and whenever a proper message with a path to the protocol
comes in, you deiconify the window and shift focus back to the last window
that had it.  I do have the code for doing that, btw.  I haven't tested it,
but it looked sane, and the poster in question seems to be a knowledgeable
regular in the ptk group.  I'll include it in case you need it.

Here was his suggested code:

#########################
use warnings;
use strict;
use Win32::API;
use Tk;

my $getFW = new Win32::API('user32','GetForegroundWindow','','N');
my $setFW = new Win32::API('user32','SetForegroundWindow',['N'],'N');

my $handle = $getFW->Call();

my $mw = tkinit;
$mw->after(10,sub{
  $setFW->Call($handle);
});

MainLoop;
__END__
#########################


Basically, this is in the context of starting a window that gives focus to
the last window that had focus before the Tk app started.  However, if you
embed the pertinent code in the callback that handles socket event
processing, you could skip the after() method and just flat-out do it right
after deiconifying your window with the new image--assuming it's even
iconified.  Obviously you can track whether the window's been minimized or
not, so you know whether or not to shift focus back at any given point--so
this should ostensibly be in something like &relinqush_focus(), as you'll
want to call it from several points.

Just my thoughts on how it would work in this kind of scenario.

Don't ask me how to handle the focus shift in X11.  I expect that's going
to be highly wm-dependent.  But we're talking about Win32 clients in
general here, so I guess we don't -have- to ask that, right?  :)

mark->
-- 
          *****   Fairlight Consulting's Software Solutions   *****
OneGate Universal CGI Gateway:                  http://onegate.fairlite.com/
FairPay PayPal Integration Kit:                 http://fairpay.fairlite.com/
RawQuery B2B HTTP[S] Client & CGI Debugger:     http://rawquery.fairlite.com/
Lightmail Mail Sending Agent:                   http://lightmail.fairlite.com/


More information about the Filepro-list mailing list