Hello World!

Does anyone know how to position the dialog boxes from Win32::FileOp. i.e. the OpenDialog, SaveAsDialog and BrowseForFolder dialog boxes?

They seem to be relative to the console window, so that if the console is not displayed, or is not there at all (i.e. I generated an .exe file with perlapp --gui), then they appear in the top left corner of the screen, but if the console IS displayed then they appear with their top left corner close to the top left of the console.

I really want them positioned relative to my main Tk window, like I can with everything else. I have a feeling that it may be something to do with the handle option, but adding '-handle => $mw' didn't seem to make any difference.

Thanks,

Spike.

UPDATE
Thanks to eserte, the updated code below now works for positioning the OpenDialog and SaveAsDialog relative to the main Tk window. Unfortunately it doesn't work on the BrowseForFolder dialog box. If I could just find a way to get it to work for that one, I could die happy! ;-)

Short demo:

use strict; use warnings; use Tk; use Win32::FileOp; my $mw = MainWindow -> new; $mw -> withdraw; my $windowid = hex ($mw -> id); my $openbutton = $mw -> Button ( -text => 'Open', -command => \&opensub, ) -> pack; my $savebutton = $mw -> Button ( -text => 'save', -command => \&savesub, ) -> pack; my $browsebutton = $mw -> Button ( -text => 'browse', -command => \&browsesub, ) -> pack; $mw -> Popup; MainLoop; sub opensub { my $file = OpenDialog(-title => "open", -handle => $windowid); } sub savesub { my $file = SaveAsDialog(-title => "save", -handle => $windowid); } sub browsesub { my $dir = BrowseForFolder ("no handle"); my $dir1 = BrowseForFolder("with handle", -handle => $windowid); }

In reply to Win32::FileOp window positioning? by spikey_wan

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.