|
From: Gail H. <gh...@ho...> - 2012-09-22 11:47:00
|
Thanks, Richard.
I am enclosing here two versions of a complete little script, originally
showing the problem. The problem was solved by avoiding -addexstyle =>
WS_EX_TOPMOST, and using "-owner => " instead.
Here is the script showing the problem: (5.014 not essential) Note: change
the 'D:\My documents' to an existing directory.
# Start example script
use strict;
use warnings;
use 5.014;
use Win32::GUI();
use Win32::GUI qw{ WS_EX_TOPMOST};
my ($InputDir, $TopDir, $InputFileName, $dw, $dh, $desktop, $Window);
$TopDir = 'D:\My documents'; # Change this to an existing direcotry of
yours
$desktop = Win32::GUI::GetDesktopWindow();
$dw = Win32::GUI::Width($desktop);
$dh = Win32::GUI::Height($desktop);
$Window = Win32::GUI::Window->new( -name => 'main', -text => 'Main window',
-pos => [20/100*$dw, 20/100*$dh], -size => [50/100*$dw, 60/100*$dh],
-onTerminate => \&TerminateWindow,
-addexstyle => WS_EX_TOPMOST, -dialogui => 1, -tabstop => 1, -cancel
=> 1, );
$Window -> AddButton ( -name => 'ButtonCommit', -pos => [10,10],
-size =>[16/100*$dw,3.5/100*$dh], -text => 'Commit changes', -onClick =>
\&Commit);
sub Commit {
$InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefiles =>
1,
-title => 'Select directory for parameter file',
-text =>'Selext directory for parameter file',
-size => [50/100*$dw, 50/100*$dh], -addexstyle =>
WS_EX_TOPMOST,);
$InputFileName = Win32::GUI::GetOpenFileName( -title => 'Select the input
file',
-directory => $InputDir, -file => "\0" . " " x 256,
-filter => ["Text files (*.txt)" => "*.txt", "All files", "*.*", ],
-text => 'text Select input file');
} # end sub Commit
$Window ->Show();
Win32::GUI::Dialog();
sub TerminateWindow {
return -1;
}
# end example script
Click the "Commit changes" button, then minimize the main window, and only
then you see the "hiding" BrowseForFolder() window.
Note that the "BrowseForFolder()" window hides behind other windows, and you
need to minimize other windows to get to it. All other Perl Win32::GUI
windows do open up at the foreground.
Furthermore, note that -addexstyle => WS_EX_TOPMOST doesn't have an effect,
while it usually does in Perl Win32::GUI windows.
Note: change the 'D:\My documents' to an existing directory.
Like I said, using the advice of: http://perlmonks.org/?node_id=995074, I
eliminated "-addexstyle => WS_EX_TOPMOST", and entered "-owner => $Window"
at the child window. That fixed it.
The role of "-owner=>" is not clear to me. Why is it necessary, and why did
it fix the problem - can you elaborate?
Here is the fixed code:
# Start example script
use strict;
use warnings;
use 5.014;
use Win32::GUI();
use Win32::GUI qw{ WS_EX_TOPMOST};
my ($InputDir, $TopDir, $InputFileName, $dw, $dh, $desktop, $Window);
$TopDir = 'D:\My documents'; # Change this to an existing direcotry of yours
$desktop = Win32::GUI::GetDesktopWindow();
$dw = Win32::GUI::Width($desktop);
$dh = Win32::GUI::Height($desktop);
$Window = Win32::GUI::Window->new( -name => 'main', -text => 'Main window',
-pos => [20/100*$dw, 20/100*$dh], -size => [50/100*$dw, 60/100*$dh],
-onTerminate => \&TerminateWindow,
-dialogui => 1, -tabstop => 1, -cancel => 1, );
$Window -> AddButton ( -name => 'ButtonCommit', -pos => [10,10],
-size =>[16/100*$dw,3.5/100*$dh], -text => 'Commit changes', -onClick =>
\&Commit);
sub Commit {
$InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefiles =>
1,
-title => 'Select directory for parameter file',
-text =>'Selext directory for parameter file',
-size => [50/100*$dw, 50/100*$dh], -owner => $Window);
$InputFileName = Win32::GUI::GetOpenFileName( -title => 'Select the input
file',
-directory => $InputDir, -file => "\0" . " " x 256,
-filter => ["Text files (*.txt)" => "*.txt", "All files", "*.*", ],
-text => 'text Select input file');
TerminateWindow();
return -1;
} # end sub Commit
$Window ->Show();
Win32::GUI::Dialog();
sub TerminateWindow {
return -1;
}
# end example script
----- Original Message -----
From: Richard Hitchins To: Gail Hardmann Sent: Friday, 21 September, 2012
17:36
Subject: Re: [perl-win32-gui-users] How to get Win32::GUI::BrowseForFolder()
to the foreground at open?
Hi Gail
Strange, I would expect the file browser to be on top. Can you post any
more code so I can see the snippet in context?
If not, then a less than ideal way would be to minimize or hide the other
windows just before you call the file browser and then reinstate them
afterwards.
Richard
On 21/09/2012 12:29, Gail Hardmann wrote:
Hi Perl Win32::GUI users!
When calling Win32::GUI::BrowseForFolder(), the desktop (naturally) has
several earlier windows on it. The BrowseForFolder() window hides behind
those windows. This can be confusing and annoying, because sometimes you
don't realize the program is asking you for a folder name, and you may think
there is a bug.
(This is in difference from Win32::GUI::GetOpenFileName() or
GetSaveFileName(), which do pop up in the foreground!).
My question is: how to make BrowseForFolder() come to the foreground?
One possibility is to find its handle, and then raise it to the foreground.
Can anyone suggest how to do it?
Note that
-addexstyle => WS_EX_TOPMOST
doesn't have any effect (see below).
Many TIA
Helen
Code snippet:
$InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefiles =>
1,
-title => 'Select directory for parameter file',
-text =>'text Selext directory for parameter file',
-size => [50/100*$dw, 50/100*$dh], -addexstyle =>
WS_EX_TOPMOST,);
_______________________________________________
Perl-Win32-GUI-Users mailing list Per...@li...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
|