code:
var OFN_ENABLESIZING = 0x800000;
var OFN_EXPLORER = 0x80000;
var OFN_FILEMUSTEXIST = 0x1000;
var OFN_HIDEREADONLY = 0x4;
var OFN_LONGNAMES = 0x200000;
var OFN_PATHMUSTEXIST = 0x800;
var OFN_OVERWRITEPROMPT = 0x00000002;
function BrowseForFile(sTitle){
var OpenFileName = Interop.Allocate(88);
var filter = '*';
var s_filter;
var s_file;
var file = '*.*';
var title;
var s_title;
var ret;
var initdir = 'c:\\';
var s_initdir = Interop.Allocate((initdir.length+1)*2);
s_initdir.WriteString(0, initdir);
with (OpenFileName){
WriteDWORD(0, Size);
s_filter = Interop.Allocate((filter.length+1)*2);
s_filter.WriteString(0, filter);
WriteDWORD(12, s_filter.DataPtr);
WriteDWORD(24, 1);
s_file = Interop.Allocate((255+1)*2);
s_file.WriteString(0, file)
WriteDWORD(28, s_file.DataPtr);
WriteDWORD(32, 255);
var sTmp = Interop.Allocate((254+1)*2);
WriteDWORD(36, sTmp.DataPtr);
WriteDWORD(40, 255);
WriteDWORD(44, s_initdir.DataPtr);
s_title = Interop.Allocate((sTitle.length+1)*2);
WriteDWORD(48, s_title.DataPtr);
WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT);
}
ret = Interop.Call('comdlg32.dll', 'GetSaveFileNameW', OpenFileName);
if (ret != 0) {
return s_file.ReadString(0);
}
}
//Usage
Debug.Trace(BrowseForFolder('Pick a file'));
quote:
Originally posted by tylertyler
Also is there a way to get the file path into the EditControl?
Use the SetControlText function of the Window. So when you create the window you use the code
code:
var mWnd = MsgPlus.CreateWnd('...', '...');
To set the controltext you use
code:
mWnd.SetControlText('EditControlName', 'New Text');