Shoutbox

UserAccounts.CommonDialog alternative for Vista - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: UserAccounts.CommonDialog alternative for Vista (/showthread.php?tid=88579)

UserAccounts.CommonDialog alternative for Vista by Guena on 01-19-2009 at 11:21 PM

First of all my Script is made to allow anybody to add his own picture to backgrounds available in my Skin "Avalon Concept 2009"

I use the following code to browse for a file: (come from the script "Backround Adder" and used with authorisation)

code:
function OnBackgroundWndenEvent_CtrlClicked(pPlusWnd, sControlId) {
    var FSO = new ActiveXObject("Scripting.FileSystemObject");
    var sourceFile = pPlusWnd.GetControlText('EdtFrom').replace(/(^\s*)|(\s*$)/g, '');
    switch (sControlId) {
        case 'BtnLoc':
            var oOpenDlg = new ActiveXObject('UserAccounts.CommonDialog');
            oOpenDlg.FileName = sourceFile;
            oOpenDlg.Filter =    'All Pictures|*.BMP;*.DIB;*.EMF;*.GIF;*.ICO;*.JPG;*.JPEG;*.JPE;*.JFIF;*.JIF;*.PNG;*.RLE;*.TIF;*.TIFF;*.WMF;|'
                        +    'All Files (*.*)|*.*|'
                        +    'Bitmaps (*.BMP)|*.BMP|'
                        +    'JPEG (*.JPG;*.JPEG)|*.JPG;*.JPEG|'
                        +    'Portable Network Graphics (*.PNG)|*.PNG|';
            oOpenDlg.FilterIndex = (oOpenDlg.FileName === '' || oOpenDlg.Filter.indexOf("." + FSO.GetExtensionName(oOpenDlg.FileName).toUpperCase() + ';') !== -1) ? 1 : 2;
            oOpenDlg.Flags = 0x1000 | 0x800 | 0x4;
            oOpenDlg.ShowOpen();
            pPlusWnd.SetControlText('EdtFrom', (oOpenDlg.FileName === '') ? '' : FSO.GetAbsolutePathName(oOpenDlg.FileName));
            break;
        case 'BtnOk':
            AddBackground(sourceFile);   
            pPlusWnd.Close(1);
            break;
        case 'BtnAbout':
            MsgPlus.CreateWnd('BackgroundAdder.xml', 'AboutWnden');
            pPlusWnd.Close(1);
            break;
    }
}

but it works only on XP not on vista, could someone please help me?

Thanks

RE: UserAccounts.CommonDialog alternative for Vista by ArkaneArkade on 01-20-2009 at 08:32 PM

Would actually quite like to know this myself.  Seems quite a few scripts don't work on vista anymore because of this (well, work, but with obvious failures).

Is there any alternative method that will either work on both XP and Vista, or else just a vista alternative so that some scripts could be updated.

- I'd settle for any pointers of a script with it, happy to learn through another.


RE: UserAccounts.CommonDialog alternative for Vista by matty on 01-20-2009 at 09:01 PM

Don't use ActiveXObjects as they can be system dependent?!?

Use GetOpenFileName and the structure OPENFILENAME

[edit]

Yay for searching the forums...

Matti's reply to CommonDialog help

[/edit]


RE: RE: UserAccounts.CommonDialog alternative for Vista by Guena on 01-22-2009 at 12:11 AM

quote:
Originally posted by matty
Don't use ActiveXObjects as they can be system dependent?!?

Use GetOpenFileName and the structure OPENFILENAME

[edit]

Yay for searching the forums...

Matti's reply to CommonDialog help

[/edit]

Thank you very much, it should be OK for me now
RE: UserAccounts.CommonDialog alternative for Vista by CookieRevised on 11-07-2009 at 03:55 PM

The UserAccounts.CommonDialog ActiveX does not work anymore in Vista. You have two choices:

Either replace it with MSComDlg.CommonDialog. But the MSComDlg.CommonDialog ActiveX will only work if you have a design license for it (you'll have that when you have installed stuff like MSOffice, Visual Studio, VB, ...). So it usually will work, but it might not on all systems.

Or do as Matty suggested and use the GetOpenFileName API.
(recommended method)