What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Creating file dialog in Vista

Creating file dialog in Vista
Author: Message:
tribbium
Junior Member
**


Posts: 34
Reputation: 3
– / Male / Flag
Joined: Jul 2008
O.P. Creating file dialog in Vista
For some reason, i'm getting reports that the following code for creating file dialogs doesn't work in Vista. This was taken from MPScripts.net and replaced some old code using the windows API. Can anyone confirm this error as my whole house is full of XPs.

code:
function browseForFile (){
    var BrowseFilter = "Text Files (*.txt)|*.txt|All Files|*.*";
    var BrowseDialog = new ActiveXObject("UserAccounts.CommonDialog");
    BrowseDialog.Filter = BrowseFilter;
    BrowseDialog.Flags = "&H4";
    BrowseDialog.ShowOpen()
    return BrowseDialog.FileName;
}
Are you and your friends trivia enthusiasts? Download Tribbium! http://www.msgpluslive.net/scripts/view/427-Tribb...ia-Gaming-System)/

Download questions for Tribbium here:
http://www.tribbium.tk
08-13-2009 01:40 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Creating file dialog in Vista
Those ActiveXObjects are very system-dependent, Vista and above no longer support those. You're much better off using native Win32 functions, as those are kept throughout many versions of Windows.

In the case of an open file dialog, you'll have to create an OPENFILENAME memory structure and then call GetOpenFileName to open the dialog and receive the results.

Luckily for you, there is already an implementation of this available for Plus! Live, so go have a look at Matti's reply to CommonDialog help! Here is an example of your code, written for the BrowseForFile() function.
js code:
function MyBrowseForFile() {
    return BrowseForFile(
        "Select a file to open",                    //Dialog title
        "C:\\",                                        //Start directory
        "Text Files (*.txt)|*.txt|All Files|*.*||",    //Filters
        false                                         //True = save, false = open
    ); //Returns the selected path, or false if the dialog was canceled
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-13-2009 07:45 AM
Profile E-Mail PM Web Find Quote Report
tribbium
Junior Member
**


Posts: 34
Reputation: 3
– / Male / Flag
Joined: Jul 2008
O.P. RE: Creating file dialog in Vista
thanks for confirming it! I guess I'll just go and do a code revert =P
Are you and your friends trivia enthusiasts? Download Tribbium! http://www.msgpluslive.net/scripts/view/427-Tribb...ia-Gaming-System)/

Download questions for Tribbium here:
http://www.tribbium.tk
08-13-2009 09:45 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On