The code piece was just a code snippet, to illustrate the problem. Obviously in the OP it was not intended as a complete program. (See new code example below).

To recall the two problems:

1. The "BrowseForFolder()" window does not show up at the foreground, while all other windows do. This is disturbing and annoying, and can lead to many problems.

Here is a complete (compileable and running) code example. (5.014 is not essential)

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 win +dow', -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', -onCl +ick => \&Commit); sub Commit { $InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefil +es => 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 i +nput 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; }

Click the "Commit changes" button, then minimize the main 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 of yours.

2. How does one find the desktop windows handles? If we could find BrowseForFolder()'s handle, we could raise it to the foreground (how?)

Many TIA

Helen


In reply to Re^4: Win32::GUI: how to find BrowseForFolder()'s handle? by HelenCr
in thread Win32::GUI: how to find BrowseForFolder()'s handle? by HelenCr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.