Win32::FileOp::OpenOrSaveDialog() populates a Win32 data structure called an OPENFILENAME. It's a really crazy structure with a lot of seemingly unrelated data. One element is an HWND which refers to the "owner window."

I think the common file open dialog uses this field to center the dialog relative to that window, or that window's top level grandparent. If you don't populate it, the console window or the desktop itself are the only choices it would have.

If you provide a hash reference as an argument to Win32::FileOp::OpenDialog(), it will populate many parameters in the struct for you. For example, { -handle => $myDesiredHwnd } would fill that HWND parameter in the Win32 data structure. But the trick becomes figuring out the right hWnd value for that.

You'd have to look into your Windows build of Tk::MainWindow to see if it has a window handle you could retrieve.

Update: Sorry if this is greek-- the Tk::* folks want to be as generic as possible, while the Win32::* stuff tends to expose a lot of random capability like this. Exposing capability is fine, but it requires a lot more legwork to learn how it all applies or how to take advantage of it.

--
[ e d @ h a l l e y . c c ]


In reply to Re: Win32::FileOp window positioning? by halley
in thread 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.