What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Save File As Dialog

Save File As Dialog
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Save File As Dialog
Therefore, you need some changes. The s_filter can contain multiple filters and therefore you'll need to write multiple strings into the databloc. Luckily, Choli made a nice function for doing that. :)

I've edited Matty's code to use WriteMultiStringW and removed the OFN_FILEMUSTEXIST flag because that can't be used on a Save As dialog! ;)

code:
function SaveFileAs(sTitle, sInitialDir){
    if (typeof(sTitle) === 'undefined') sTitle = '';
    if (typeof(sInitialDir) === 'undefined') sInitialDir = 'C:\\';
    var OpenFileName = Interop.Allocate(88);

    with (OpenFileName){
        WriteDWORD(0, 88); // Dodgy Microsoft, why can't you figure out the size of the struct yourself...
        var filter = 'JPEG (*.jpg;*.jpeg)|*.JPEG;*.JPG|All Files (*.*)|*.*||'; // This string will be used to generate an s_filter databloc
        var s_filter = Interop.Allocate(512);
        WriteMultiStringW(s_filter, filter);
            WriteDWORD(12, s_filter.DataPtr);
        WriteDWORD(24, 1);
        s_file = Interop.Allocate(512);
        // s_file.WriteString(0, '*.*');
            WriteDWORD(28, s_file.DataPtr);
        WriteDWORD(32, 255);
        var sTmp = Interop.Allocate((254+1)*2);
        WriteDWORD(36, sTmp.DataPtr);
        WriteDWORD(40, 255);
        var s_initdir = Interop.Allocate((sInitialDir.length+1)*2);
        s_initdir.WriteString(0, sInitialDir);
            WriteDWORD(44, s_initdir.DataPtr);
        s_title = Interop.Allocate((sTitle.length+1)*2);
            WriteDWORD(48, s_title.DataPtr);
        WriteDWORD(52, 0x800000 /* OFN_ENABLESIZING */ | 0x80000 /* OFN_EXPLORER */ | 0x4 /* OFN_HIDEREADONLY */ | 0x200000 /* OFN_LONGNAMES */ | 0x800 /* OFN_PATHMUSTEXIST */ | 0x1000 /* OFN_OVERWRITEPROMPT */);
    }
    return Interop.Call('comdlg32', 'GetSaveFileNameW', OpenFileName) !== 0 ? s_file.ReadString(0) : false;

    function WriteMultiStringW (datablock, string) {
        var pos = 0;
        datablock.WriteString(0, string);
        pos = string.indexOf("|", pos);
        while (pos != -1) {
            datablock.WriteWORD(2 * pos, 0);
            pos = string.indexOf("|", pos + 1);
        }
    }
}

Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-17-2007 04:06 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Save File As Dialog - by davidpolitis on 08-17-2007 at 12:49 PM
RE: Save File As Dialog - by matty on 08-17-2007 at 01:02 PM
RE: RE: Save File As Dialog - by TheSteve on 08-20-2007 at 12:22 AM
RE: Save File As Dialog - by davidpolitis on 08-17-2007 at 01:03 PM
RE: Save File As Dialog - by Matti on 08-17-2007 at 04:06 PM
RE: Save File As Dialog - by matty on 08-17-2007 at 04:26 PM
RE: Save File As Dialog - by davidpolitis on 08-17-2007 at 10:15 PM
RE: Save File As Dialog - by Spunky on 08-18-2007 at 08:07 AM
RE: Save File As Dialog - by davidpolitis on 08-18-2007 at 12:18 PM
RE: Save File As Dialog - by MeEtc on 08-18-2007 at 12:33 PM
RE: Save File As Dialog - by markee on 08-20-2007 at 03:06 AM
RE: Save File As Dialog - by davidpolitis on 08-20-2007 at 11:41 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