List Info

Thread: Re: dos cmd window woes




Re: dos cmd window woes
country flaguser name
United States
2007-02-28 17:01:48
Would this not suffer from the same
window hiding delay problem as my hack?

I was under the impression that the problem
was caused by delays in starting up the
perl interpreter.  I assume your code
below is also perl code which would have
to run in the same delayed interpreter.
Is this not so?

--- Mark Dootson <mark.dootsonznix.com> wrote:

> Hi,
> 
> using perl 5.8?
> 
> You need
> 
> Win32::SetChildShowWindow( Win32::SW_HIDE() );
> 
> 
> I had similar hacks in place for a long time until I
noticed this in the
> docs.
> 
> 
> Mark
> 
> 
> 
> Steve Madere wrote:
> > When building applications using PerlApp, I have a
choice
> > to build them without an associated DOS console
window using --gui.
> > 
> > 
> > However, if the application I built ever does
something like
> > either of the following:
> > 
> > system($my_other_program);
> > 
> > or
> > 
> > my $fh = new FileHandle($my_pipeline_command)
> > 
> > 
> > A dos command window suddenly pops up for the
duration of
> > the executed subprocess and then goes away.
> > 
> > 
> > Since my application needs to regularly invoke
other
> > executables, I have gotten in the habit of
building it
> > without the --gui option so I won't get a sequence
of
> > dancing console windows.
> > 
> > 
> > However, without the --gui option I of course get
one
> > persistent command window for the duration of my
application's
> > run.
> > 
> > Just today, I finally figured out a workaround
(sort of) for this
> > problem.
> > 
> > I inserted the following ugly hack at the top of
my
> > main.pl:
> > 
> > =======================================
> >          
> > my $perl_win32_window;
> > BEGIN {  
> >     if ($^O =~ /mswin/i) {
> >         # prevent the appearance of a DOS CMD
window associated with
> >         # the perl application
> >         use Win32::GUI;
> >         $perl_win32_window =
Win32::GUI::GetPerlWindow();
> >         # however, when we are actually in the
process of building
> >         # our perl application with PerlApp, we do
not want to
> >         # hide the window so use an environment
variable to communicate
> >         # this fact from the batch file that runs
PerlApp
> >         if (!$ENV) {
> >             no strict 'subs';
> >            
Win32::GUI::Show($perl_win32_window,SW_HIDE);
> >         }   
> >     }   
> > }   
> > 
> > END {
> >     if ($^O =~ /mswin/i) {
> >         Win32::GUI::Show($perl_win32_window);
> >     }   
> > }   
> > 
> > ================================
> > 
> > Unfortunately, Win32::GUI is not available from
ActiveState
> > right now so anybody else who wants to apply this
hack
> > should know that you'll need to get it from
bribes.org
> > with this command:
> > 
> > ppm install http://w
ww.bribes.org/perl/ppm/Win32-GUI.ppd
> > 
> > 
> > This is a partial solution but it has the drawback
that the
> > DOS command window shows up for several seconds
when the
> > user first clicks on my application's icon and
then it
> > disappears.  I would prefer if I could get it to
go
> > away earlier.  I have a feeling that the reason
for the
> > delay is startup delay in my packaged perl process
while
> > the various components are being extracted to
temporary
> > directories.
> > 
> > 
> > Is there any other way to solve this problem?
> > 
> > Is there some way that the bootstrap code
generated by
> > PerlApp could be directed to do the window hide so
that
> > it will happen earlier in the process?
> > 
> > - Steve Madere
> > _______________________________________________
> > PDK mailing list
> > PDKlistserv.ActiveState.com
> > To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
> 
> 
> 

_______________________________________________
PDK mailing list
PDKlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

Re: dos cmd window woes
country flaguser name
United Kingdom
2007-02-28 17:15:13
Hi,

>From the Win32 docs:

Sets the ShowMode of child processes started by system(). By
default
system() will create a new console window for child
processes if Perl
itself is not running from a console. Calling
SetChildShowWindow(0) will
make these new console windows invisible. Calling
SetChildShowWindow()
without arguments reverts system() to the default behavior.
The return
value of SetChildShowWindow() is the previous setting or
undef.

So, build your app with --gui option.
Call Win32::SetChildShowWindow( Win32::SW_HIDE() ); early
on.

Then progs you start with system() get hidden windows.

open(FILE, "$progname |");
while(<FILE>) {

works too.

Cheers

Mark


Steve Madere wrote:
> Would this not suffer from the same
> window hiding delay problem as my hack?
> 
> I was under the impression that the problem
> was caused by delays in starting up the
> perl interpreter.  I assume your code
> below is also perl code which would have
> to run in the same delayed interpreter.
> Is this not so?
> 
> --- Mark Dootson <mark.dootsonznix.com> wrote:
> 
>> Hi,
>>
>> using perl 5.8?
>>
>> You need
>>
>> Win32::SetChildShowWindow( Win32::SW_HIDE() );
>>
>>
>> I had similar hacks in place for a long time until
I noticed this in the
>> docs.
>>
>>
>> Mark
>>
>>
>>
>> Steve Madere wrote:
>>> When building applications using PerlApp, I
have a choice
>>> to build them without an associated DOS console
window using --gui.
>>>
>>>
>>> However, if the application I built ever does
something like
>>> either of the following:
>>>
>>> system($my_other_program);
>>>
>>> or
>>>
>>> my $fh = new FileHandle($my_pipeline_command)
>>>
>>>
>>> A dos command window suddenly pops up for the
duration of
>>> the executed subprocess and then goes away.
>>>
>>>
>>> Since my application needs to regularly invoke
other
>>> executables, I have gotten in the habit of
building it
>>> without the --gui option so I won't get a
sequence of
>>> dancing console windows.
>>>
>>>
>>> However, without the --gui option I of course
get one
>>> persistent command window for the duration of
my application's
>>> run.
>>>
>>> Just today, I finally figured out a workaround
(sort of) for this
>>> problem.
>>>
>>> I inserted the following ugly hack at the top
of my
>>> main.pl:
>>>
>>> =======================================
>>>          
>>> my $perl_win32_window;
>>> BEGIN {  
>>>     if ($^O =~ /mswin/i) {
>>>         # prevent the appearance of a DOS CMD
window associated with
>>>         # the perl application
>>>         use Win32::GUI;
>>>         $perl_win32_window =
Win32::GUI::GetPerlWindow();
>>>         # however, when we are actually in the
process of building
>>>         # our perl application with PerlApp, we
do not want to
>>>         # hide the window so use an environment
variable to communicate
>>>         # this fact from the batch file that
runs PerlApp
>>>         if (!$ENV) {
>>>             no strict 'subs';
>>>            
Win32::GUI::Show($perl_win32_window,SW_HIDE);
>>>         }   
>>>     }   
>>> }   
>>>
>>> END {
>>>     if ($^O =~ /mswin/i) {
>>>         Win32::GUI::Show($perl_win32_window);
>>>     }   
>>> }   
>>>
>>> ================================
>>>
>>> Unfortunately, Win32::GUI is not available from
ActiveState
>>> right now so anybody else who wants to apply
this hack
>>> should know that you'll need to get it from
bribes.org
>>> with this command:
>>>
>>> ppm install http://w
ww.bribes.org/perl/ppm/Win32-GUI.ppd
>>>
>>>
>>> This is a partial solution but it has the
drawback that the
>>> DOS command window shows up for several seconds
when the
>>> user first clicks on my application's icon and
then it
>>> disappears.  I would prefer if I could get it
to go
>>> away earlier.  I have a feeling that the reason
for the
>>> delay is startup delay in my packaged perl
process while
>>> the various components are being extracted to
temporary
>>> directories.
>>>
>>>
>>> Is there any other way to solve this problem?
>>>
>>> Is there some way that the bootstrap code
generated by
>>> PerlApp could be directed to do the window hide
so that
>>> it will happen earlier in the process?
>>>
>>> - Steve Madere
>>>
_______________________________________________
>>> PDK mailing list
>>> PDKlistserv.ActiveState.com
>>> To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
>>
>>
> 


_______________________________________________
PDK mailing list
PDKlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )