What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Problems with file dialogs

Problems with file dialogs
Author: Message:
blessedguy
Skinning Contest Winner
*****


Posts: 1762
Reputation: 25
31 / Male / Flag
Joined: Jan 2008
O.P. Problems with file dialogs
Hi there.
Guess what happens when you move from skinning to scripting? Things crash! :zippy:

Anyways, I'm using that old dialog Choli posted some time ago, but my script crashes messenger if I close the original window, open the file dialog, and open a new window after choosing the file (or just canceling it). I mean, this:
JScript code:
//variables declared way back
function OnBkdWndEvent_CtrlClicked(Wnd, ControlId) {
    BkdWnd = Wnd;
    if (ControlId == "BkdWnd_MAINBKD") {
        Bkd_ConvoWnd = BkdWnd.GetControlText("BkdWnd_CONVOBKD");
        if (DebugInfo == true) {
            Debug.Trace("\"" + Bkd_ConvoWnd + "\"" + " saved to Bkd_ConvoWnd variable");
        }
        BkdWnd.Close(2);        if (DebugClick == true) {
            Debug.Trace("BkdWnd_MAINBKD clicked");
        }
        if (DebugInfo == true) {
            Debug.Trace("Closing BkdWnd and opening File Dialog");
        }
        OpenFileName = Interop.Allocate(88);
        with (OpenFileName) {
            WriteDWORD(0, Size); // lStructSize
            WriteDWORD(4, 0); // hwndOwner
            WriteDWORD(8, 0); // hInstance
            filter = "Image Files (*.png)|*.png|Image files (*.jpg)|*.jpg||";
            s_filter = Interop.Allocate(2 * (filter.length + 1));
            WriteMultiStringW(s_filter, filter);
            WriteDWORD(12, s_filter.DataPtr); // lpstrFilter
            WriteDWORD(16, 0); // lpstrCustomFilter
            WriteDWORD(20, 0); // nMaxCustomFilter
            WriteDWORD(24, 1); // nFilterIndex
            file = "" + Space(256);
            s_file = Interop.Allocate(2 * (file.length + 1));
            s_file.WriteString(0, file);
            WriteDWORD(28, s_file.DataPtr); // lpstrFile
            WriteDWORD(32, file.length); // nMaxFile
            WriteDWORD(36, 0); // lpstrFileTitle
            WriteDWORD(40, 0); // nMaxFileTitle
            WriteDWORD(44, 0); // lpstrInitialDir
            title = "Choose a Contact List background";
            s_title = Interop.Allocate(2 * (title.length + 1));
            s_title.WriteString(0, title);
            WriteDWORD(48, s_title.DataPtr); // lpstrTitle
            WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST); // flags
            WriteWORD(56, 0); // nFileOffset
            WriteWORD(58, 0); // nFileExtension
            WriteDWORD(60, 0); // lpstrDefExt
            WriteDWORD(64, 0); // lCustData
            WriteDWORD(68, 0); // lpfnHook
            WriteDWORD(72, 0); // lpTemplateName
            WriteDWORD(76, 0); // pvReserved
            WriteDWORD(80, 0); // dwReserved
            WriteDWORD(84, 0); // FlagsEx
        }
        with (OpenFileName) {
            ret = Interop.Call("comdlg32.dll", "GetOpenFileNameW", OpenFileName);
        }
        BkdWnd = MsgPlus.CreateWnd("AgaetiCompanion.xml", "BkdWnd");        if (DebugInfo == true) {
            Debug.Trace("Opening BkdWnd");
        }
        if (ret == 0) {
            if (DebugClick == true) {
                Debug.Trace("Cancel clicked");
            }
            if (DebugInfo == true) {
                Debug.Trace("Closing File Dialog");
            }
            return;
        }
        else {
            BkdWnd.SetControlText("BkdWnd_MAINBKD", "Main: " + s_file.ReadString(0).substring(s_file.ReadString(0).lastIndexOf("\\") + 1));
            if (DebugInfo == true) {
                Debug.Trace("BkdWnd_MAINBKD set to " + s_file.ReadString(0).substring(s_file.ReadString(0).lastIndexOf("\\") + 1));
            }
            BkdWnd.SetControlText("BkdWnd_CONVOBKD", Bkd_ConvoWnd);
            if (DebugInfo == true) {
                Debug.Trace("BkdWnd_CONVOBKD set to " + Bkd_ConvoWnd);
            }
            Bkd_MainWnd = s_file.ReadString(0);
            if (DebugInfo == true) {
                Debug.Trace("Main Window background file: " + Bkd_MainWnd);
            }
        }  
    }
}


now, if I comment out the highlighted lines, it won't crash. any guesses? [and yes, I prefer having the window closed and then opened again :3 I tried creating the window under a different variable, but still crashed]

I've attached the script itself here, so you can take a look at whatever you want or need. and yes, it's not near finished, but I just restarted it from scratch :zippy:

thanks in advance :)

.zip File Attachment: Agaeti Companion.zip (15.7 KB)
This file has been downloaded 69 time(s).
[Image: Empty.png]
04-10-2011 08:04 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Problems with file dialogs
Take a look in my beta script... I use the same function and as far as I can tell it works in that situation.

Rather than using GetOpenFileName, I return the path from the function the comdlg is defined in.

<Eljay> "Problems encountered: shit blew up" :zippy:
04-10-2011 08:51 PM
Profile PM Find Quote Report
blessedguy
Skinning Contest Winner
*****


Posts: 1762
Reputation: 25
31 / Male / Flag
Joined: Jan 2008
O.P. RE: Problems with file dialogs
I'll try that, thanks :)
[Image: Empty.png]
04-10-2011 08:55 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Problems with file dialogs
I'm trying it now, I'll send it in a min
<Eljay> "Problems encountered: shit blew up" :zippy:
04-10-2011 09:01 PM
Profile PM 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