Home All Groups Group Topic Archive Search About

Dropping folder on desk top icon

Author
30 Nov 2006 3:27 AM
al jones
Normally I have some idea of where in the MSDN to start looking but on this
one I have absolutely no idea.

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??

//al

(( Cor, I'm working of the question .... ))

Author
30 Nov 2006 3:51 AM
Lucian Wischik
al jones <alfredmjo***@shotmail.com> wrote:
>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

--
Lucian
Author
30 Nov 2006 4:38 AM
al jones
On Wed, 29 Nov 2006 19:51:36 -0800, Lucian Wischik wrote:

Show quoteHide quote
> al jones <alfredmjo***@shotmail.com> wrote:
>>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

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
Author
30 Nov 2006 6:06 AM
al jones
On Wed, 29 Nov 2006 19:51:36 -0800, Lucian Wischik wrote:

Show quoteHide quote
> al jones <alfredmjo***@shotmail.com> wrote:
>>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

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
Author
30 Nov 2006 6:43 PM
Mythran
Show quote Hide quote
"al jones" <alfredmjo***@shotmail.com> wrote in message
news:1lwte88yjzjsn$.eygq4tgtm4gz.dlg@40tude.net...
> On Wed, 29 Nov 2006 19:51:36 -0800, Lucian Wischik wrote:
>
>> al jones <alfredmjo***@shotmail.com> wrote:
>>>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
>
> 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

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
Author
30 Nov 2006 9:33 PM
al jones
On Thu, 30 Nov 2006 10:43:44 -0800, Mythran wrote:

Show quoteHide quote
> "al jones" <alfredmjo***@shotmail.com> wrote in message
> news:1lwte88yjzjsn$.eygq4tgtm4gz.dlg@40tude.net...
>> On Wed, 29 Nov 2006 19:51:36 -0800, Lucian Wischik wrote:
>>
>>> al jones <alfredmjo***@shotmail.com> wrote:
>>>>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
>>
>> 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
>
> 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
>
>

Thanks Mythran for the step by step; now to go and see if I understand what
I think you said.

//al