Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Win32::GUI: how to find BrowseForFolder()'s handle?

by HelenCr (Monk)
on Sep 21, 2012 at 06:15 UTC ( [id://994815]=perlquestion: print w/replies, xml ) Need Help??

HelenCr has asked for the wisdom of the Perl Monks concerning the following question:

Dear esteemed PerlMonks

I had asked this question earlier here, and haven't received an answer. I am posting it here with a more accurate focus:

When calling Win32::GUI::BrowseForFolder(), the desktop (naturally) has several earlier windows on it. The BrowseForFolder window hides behind those windows. This is sometimes 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 an effect (see below).

Many TIA

Helen

Code example:

$InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefil +es => 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,);

Replies are listed 'Best First'.
Re: Win32::GUI: how to find BrowseForFolder()'s handle?
by Anonymous Monk on Sep 21, 2012 at 06:35 UTC

    My question is: how to make BrowseForFolder() come to the foreground?

    I have a sneaking suspicion that you simply don't :) I read about it a long time ago on MSDN and I don't recall the details very well :| you might search if you're interested, but I find MFC/Win32 very tiresome :)

    But basically you can only ask the desktop to raise the window, but you can't force it, you can't steal the focus / force it upon a user -- users don't like surprises (all of a sudden you're typing a letter and BLAMMO, you're selecting OK on some evil button)

    Code example:

    I can tell just by looking that doesn't compile

      But basically you can only ask the desktop to raise the window, but you can't force it,

      Not correct. Like I said in the OP, GetOpenFileName() and GetSaveFileName(), for example, pop up and show at the foreground, on top of all other existing windows. So why should BrowseForFolder() be different? It's the same type of window/interaction.

      I can tell just by looking that doesn't compile

      Not correct. That code compiles fine.

        Not correct.

        How do you know?

        Like I said in the OP, GetOpenFileName() and GetSaveFileName(), for example, pop up and show at the foreground, on top of all other existing windows. So why should BrowseForFolder() be different? It's the same type of window/interaction.

        It isn't. Neither one will pop up if they (the parent, the app) don't have focus (aka permission ) to pop up -- they simply flash on the taskbar

        Not correct. That code compiles fine.

        Oh really?

        $ perl $InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefil +es => 1, -title => 'Select directory fo +r parameter file', -text =>'text Selext directory + for parameter file', -size => [50/100*$dw, 50/100*$ +dh], -addexstyle => WS_EX_TOPMOST,); ^Z Undefined subroutine &Win32::GUI::BrowseForFolder called at - line 1.

        Really?

        use Win32::GUI; use warnings; $InputDir = Win32::GUI::BrowseForFolder( -root => $TopDir, -includefil +es => 1, -title => 'Select directory fo +r parameter file', -text =>'text Selext directory + for parameter file', -size => [50/100*$dw, 50/100*$ +dh], -addexstyle => WS_EX_TOPMOST,); __END__ Name "main::dh" used only once: possible typo at - line 6. Name "main::InputDir" used only once: possible typo at - line 3. Name "main::dw" used only once: possible typo at - line 6. Name "main::TopDir" used only once: possible typo at - line 3. Use of uninitialized value $dw in multiplication (*) at - line 3. Use of uninitialized value $dh in multiplication (*) at - line 3. Use of uninitialized value in subroutine entry at - line 3.

        How do I post a question effectively? , Basic debugging checklist , How (Not) To Ask A Question

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://994815]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-19 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found