mIRC Homepage
Posted By: coolspot Open Dialog using COM - 10/06/03 08:26 PM
I found you can access the Shell.Application connection to then access the BrowseForFolder() method. The problem I have is not getting the Open Dialog to appear, but, the value it returns from the directory I choose is a numeric value. Heres what I mean:

alias open_dialog {
.comopen odlg Shell.Application
if ($comerr) { echo -a error | return }
var %dlg = $com(odlg,BrowseForFolder,3,0,Open File,0)
echo -a %dlg
}

this successfully opens a Open File dialog. Problem is when calling the BrowseForFolder method, the return value of %dlg is a interger similar to 654403. MSDN states that the BrowseForFolder method will create a new Folder object in which I can just use Folder.Title to get the name of the folder selected. Does anyone know how to do this using mirc since DISPATCH/UNKNOWN doesnt seem to work as it should? (maybe it does but I cant get it to)... thanks
Posted By: codemastr Re: Open Dialog using COM - 10/06/03 08:52 PM
* Invalid parameters: $com (line 4, script21.mrc)

Thats what I get when I try that script.
Posted By: Poltergeist Re: Open Dialog using COM - 10/06/03 09:18 PM
Quote:
* Invalid parameters: $com (line 4, script21.mrc)

Thats what I get when I try that script.


same here...
Posted By: coolspot Re: Open Dialog using COM - 10/06/03 09:33 PM
oooops, try this line instead:

$com(odlg,BrowseForFolder,3,int,0,string,Open Dialog,int,0)

sorry about that...
Posted By: Online Re: Open Dialog using COM - 11/06/03 12:56 AM
Not only you are asking this question... the help file is very unclear regarding dispatch/unknown. Please inform us if you get it to work.
Posted By: coolspot Re: Open Dialog using COM - 11/06/03 01:59 AM
not sure if I can, I've tried (in previous COM scripts) to use it in 100's of various ways without success, but I'll continue to try smile
Posted By: coolspot Re: Open Dialog using COM - 11/06/03 02:33 AM
Only thing Im getting close with is using $com(odlg).dispatch which lets me know there IS in fact a pointer in the $com() connection im trying to use. However .unknown is showing false, so my next objective is to see which item is in fact a pointer, and retrieve that so that the object is create successfully by BrowseForFolder()...I think I may be onto something...
Posted By: Online Re: Open Dialog using COM - 11/06/03 02:38 AM
Good luck smile but don't be disappointed if there's no success. I hope the next version will reveal more.
Posted By: coolspot Re: Open Dialog using COM - 11/06/03 03:01 AM
Well, I managed to get it working, using dispatch, and it does create a new com object named folder which returns a value. However, if I close the com connection and then try to do it again mirc has some memory errors and crashes, try this out for size:

alias cdlg {
comopen odlg Shell.Application
if ($comerr) {
echo comopen failed
comclose odlg
halt
}
var %dlg = $com(odlg,BrowseForFolder,3,int,0,string,Testing,uint,BIF_BROWSEINCLUDEFILES,dispatch*vfolder,odlg)
echo -a $com(odlg,vfolder)
comclose odlg
}

Just run /cdlg, pick a folder, and click ok, vfolder will return the result. Then run it again, pick a folder, it ok and BOOM memory errors.
Posted By: KingTomato Re: Open Dialog using COM - 11/06/03 03:27 AM
im not one to fool with com's but whouldn't u have a second $comerr check after the second open? maybe that would catch it before mirc gets the short end of the stick?
Posted By: codemastr Re: Open Dialog using COM - 11/06/03 03:29 AM
Well it didn't crash here (WinME), but it also didn't work. The first run I got the output of:

6128440

When I ran in the second time, after picking the folder I got:
* Invalid parameters: $com (line 8, script3.mrc)

Seems rather weird that mIRC had no problem with it the first time, then running it again it gives a syntax error...
Posted By: coolspot Re: Open Dialog using COM - 11/06/03 03:31 AM
ok I got it working but without crashing, and vfolder is now a usable object (that stores 6583xx) as a value...at least we're getting somewhere. Now to try and use its methods and properties. Try this on for size:

alias cdlg {
comopen odlg Shell.Application
if ($comerr) {
echo comopen failed
comclose odlg
halt
}
var %dlg = $com(odlg,BrowseForFolder,3,int,0,string,Testing,uint,BIF_BROWSEINCLUDEFILES)
var %test = $com(odlg,Folder,3,dispatch*vfolder,odlg)
echo -a $com(odlg,vfolder)
comclose odlg
}


Now vfolder is a usable $com() object. Now we need to use vfolder and call I believe its Folder.Title or maybe just title since its auto assumed to be a folder object.
Posted By: codemastr Re: Open Dialog using COM - 11/06/03 03:32 AM
Wait, correction, when I went to close mIRC it then crashed smile
© mIRC Discussion Forums