What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [HELP] Browsing to save a file

[HELP] Browsing to save a file
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [HELP] Browsing to save a file
quote:
Originally posted by SmokingCookie
I don't understand those flags etc., but here's the code anyway:
Looking at the MSDN documentation for a structure is always a wise idea: http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx

code:
function BrowseFile(filter, title, file) {
    var _SAVEFILENAME = Interop.Allocate(88);
    var s_filter;
    var s_file;
    var s_title;
    with(_SAVEFILENAME) {
        /*Define the size of the structure; this is done because there are multiple sizes of the structure */
        WriteDWORD(0, Size);
       
        /*Use this portion to force the Dialog to show ontop of another window */
        WriteDWORD(4, 0);
       
        /*Define the file filter */
        s_filter = Interop.Allocate(2 * filter.length + 1);
        WriteMultiStringW(s_filter, filter);
        WriteDWORD(12, s_filter.DataPtr);
       
        /* Set the current selected filter as the first filter in the list */
        WriteDWORD(24, 1);
       
        /* Allocate space to hold the filename */
        s_file = Interop.Allocate(512);
        s_file.WriteString(0, file);
        WriteDWORD(28, s_file.DataPtr);
       
        /* Set the maximum size of the file path */
        WriteDWORD(32, 512);
       
        /* Set the title of the dialog */
        s_title = Interop.Allocate(2 * title.length + 1);
        s_title.WriteString(0, title);
        WriteDWORD(48, s_title.DataPtr);
       
        /* Set the flags for the dialog style */
        WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST);
    }
    /* Call the function */
    var ret = Interop.Call('comdlg32', 'GetSaveFileNameW', _SAVEFILENAME);
    //return
            // if ret = 0
                       // since ret == 0 is true return '__none'
                                  // since ret != 0 then return the filename

    return ret === 0 ? '__none' : s_file.ReadString(0);
}

This is untested code. You need to learn to start doing things yourself.

This post was edited on 05-25-2008 at 04:30 PM by matty.
05-21-2008 12:29 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[HELP] Browsing to save a file - by SmokingCookie on 05-20-2008 at 02:56 PM
RE: [HELP] Browsing to save a file - by Matti on 05-20-2008 at 03:48 PM
RE: [HELP] Browsing to save a file - by SmokingCookie on 05-20-2008 at 04:04 PM
RE: [HELP] Browsing to save a file - by matty on 05-20-2008 at 07:41 PM
RE: [HELP] Browsing to save a file - by SmokingCookie on 05-20-2008 at 07:44 PM
RE: [HELP] Browsing to save a file - by roflmao456 on 05-20-2008 at 07:52 PM
RE: [HELP] Browsing to save a file - by Spunky on 05-20-2008 at 09:43 PM
RE: [HELP] Browsing to save a file - by matty on 05-21-2008 at 12:29 AM


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