Problems with file dialogs - 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: Problems with file dialogs (/showthread.php?tid=97338)
Problems with file dialogs by blessedguy on 04-10-2011 at 08:04 PM
Hi there.
Guess what happens when you move from skinning to scripting? Things crash!
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
thanks in advance
RE: Problems with file dialogs by Spunky on 04-10-2011 at 08:51 PM
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.
RE: Problems with file dialogs by blessedguy on 04-10-2011 at 08:55 PM
I'll try that, thanks
RE: Problems with file dialogs by Spunky on 04-10-2011 at 09:01 PM
I'm trying it now, I'll send it in a min
|