Posted by LuckyBoy in SWF Studio V3 on Mar 28 2016, 09:23 am

Hi,

I have a little issue with ssCore.App.showFolderBrowser:
The folder browser window always appears at the center of the screen and not at the center of SWF STUDIO application window like ssCore.App.showFileOpen or ssCore.App.showFileSave.
It's very inconvenient in multiple monitor configuration: the folder browser window appears in between of my two screens!

Is there's an easy way to fix that?


Posted by northcode in SWF Studio V3 on Mar 28 2016, 02:23 pm

The App.showFolderBrowser function uses the application window as its parent and centers itself on that window. If you're seeing it show up in the center of the screen then something's gone wonky.

Is the call to App.showFolderBrowser the first thing your app does? If so, make sure to call Win.show to make sure your app is visible before you try to open the folder browser.

If that doesn't work, I've attached a copy of a "Tools" plugin with a function you can use to move a window if you know its HWND. I've assumed the Tools plugin is just in the same folder as your app and called it using Plugin.loadFromFolder but you can also drop it in the SWF Studio plugins folder with the default plugins and the use it like any other plugin.

You can get the HWND of the folder browser dialog using the App.setNotify function and the onDialog event.

NOTE: You will want to check captionDialog to make sure it's the folder browser before you just call Tools.MoveWindow or you will move ALL child dialogs. I've left a "todo:" in the code where you want to add that check.

Also note that Tools.MoveWindow is being called asynchronously. If you leave out the {sync:false} then your app will hang when you try to call the DLL from insde the onDialog callback.



ssCore.Plugin.loadFromFolder({plugin:"Tools", alias:"Tools", path:"startdir://"});

ssCore.App.setNotify({event:"onDialog"}, {callback:onDialog});

function onDialog(result_obj, callback_obj, error_obj)
{
    var a = result_obj.result.split(",");

    var hwndDialog = a[0];
    var isChild = a[1];
    var captionDialog = a[2];
    var captionParent = a[3];

    if (isChild == "TRUE")
    {
   // todo: make sure captionDialog is the folder browser you're looking for
   ssDebug.trace(captionDialog + " " + hwndDialog);
   ssCore.Tools.moveWindow({hwnd:hwndDialog, x:0, y:0}, {sync:false});
    }


ssCore.Win.show({});
ssCore.App.showFolderBrowser({title:"Select a folder", path:"startdir://"});

attachments: tools.v3.zip  


Posted by LuckyBoy in SWF Studio V3 on Mar 29 2016, 05:24 am

Hi,

This will allow me to complete my project.

The call to App.showFolderBrowser is not the first thing my app do. I always call Win.show before calling any dialog window. I think there's an issue with App.showFolderBrowser.
I had not really paid attention before because I wasn't using it on multiple screens.

As I said, ssCore.App.showFileOpen or ssCore.App.showFileSave are working fine.

Thanks for your help and long live to SWF Studio.