>A fellow who uses my 'toy' asked if would be possible to drop a folder of
>files / folders to be processed onto the desktop icon ( well, of course it
>would ;) ) My question is how do I detect that in a vb 2005 program??
When the windows shell has items dropped on an executable (or shortcut
to an executable), then it launches the executable and passes the
names of those items as command-line arguments. So:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
For Each fn As String In My.Application.CommandLineArgs
TextBox1.AppendText(fn & vbCrLf)
Next
End Sub

Signature
Lucian
al jones - 30 Nov 2006 04:38 GMT
>>A fellow who uses my 'toy' asked if would be possible to drop a folder of
>>files / folders to be processed onto the desktop icon ( well, of course it
[quoted text clipped - 10 lines]
> Next
> End Sub
Ah, okay, thanks. That prompts "what happens to any command line switched
that I might already have set", but I can deal with that.
Thank you sir //al
al jones - 30 Nov 2006 06:06 GMT
>>A fellow who uses my 'toy' asked if would be possible to drop a folder of
>>files / folders to be processed onto the desktop icon ( well, of course it
[quoted text clipped - 10 lines]
> Next
> End Sub
Okay, Lucian, you got me into this.... :)
I was already checking for some command line arguements of my own so making
this addition was easy - once I knew where to look.
But now for the dumb logic portion of this - I process the command
arguments in formload. What I want is to bypass the 'Run' button if they
drop a folder on the program icon, just take the existing options, use this
folder and go from there.
No, not being reasonable (I deleted my first attempt here) I'd like to
display the form as I do have progress bars, etc on it. But I'd also like
it set so that they don't have to click on anything - they've already given
me what I need - so I'd just like to load everything and pretend they
clicked 'Run'.
aside: I should probably move the command line processing to a seperate
function (it's beginning to get to be unwieldly) but I still have to return
to form load which will expect input .... suggestions???
//al
Mythran - 30 Nov 2006 18:43 GMT
>>>A fellow who uses my 'toy' asked if would be possible to drop a folder of
>>>files / folders to be processed onto the desktop icon ( well, of course
[quoted text clipped - 36 lines]
>
> //al
1.) Before loading your form, in the apps Main method, parse all of your
command-line switches (and yes, I would break this out into a separate
method or even class if it is getting larger).
2.) Create a new constructor for your form that accepts the argument(s) that
are passed from the command-line. Initialize any members to these arguments
if required.
3.) Instead of having your processing code in the "Start" buttons event
handler, move this logic into a separate method.
4.) In your "Start" buttons event handler, call the method created in step
3.
5.) In your forms load event handler, check to see if all the required
values are present via members/properties set in step #2. If they are set,
call the form's Show method and then call the method created in step 3.
This should help get ya started to allow drag-n-drop onto the exec as well
as using the gui to specify required arguments.
HTH,
Mythran
al jones - 30 Nov 2006 21:33 GMT
>>>>A fellow who uses my 'toy' asked if would be possible to drop a folder of
>>>>files / folders to be processed onto the desktop icon ( well, of course
[quoted text clipped - 60 lines]
> HTH,
> Mythran
Thanks Mythran for the step by step; now to go and see if I understand what
I think you said.
//al