Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts

I have windows application developed in vb.net.
I am uploading a file in FTP and so it take a while to Upload.
At this time, I want to make the form look that it is doing something, and I don't want user to click on anything in the form. It is not just progress bar. It is something related to progress bar where user should not be allowed to click on the form controls. How can this be done?
Posted
Comments
MasterCodeon 19-Dec-14 14:56pm    
could you post the code you used to do the uploading to the FTP server(without the username and password)
MasterCodeon 19-Dec-14 14:58pm    
oh and does the progress bar have to move?
sudevsu 19-Dec-14 15:08pm    
I don't need progress bar to move but I just want to make the form look like "it cannot be clicked" you know how apple does little circle while updating the phone. I want the form like that.
And Yeah by the way, I didn't do much with keeping the File in Server. I just used File.Copy("sourcepath","destinationpath"). That's it.
MasterCodeon 19-Dec-14 15:12pm    
ah ok.
i have never seen an iPhone update but i do know how to disable all the controls in a from at will, would that partially solve your problem?
sudevsu 19-Dec-14 15:17pm    
Yeah that will.

1 solution

ok so what you want to do is first you want to define a variable stating weither or not the controls on the form are enabled like this(its a Boolean variable):
VB
Dim FormEnabled As Boolean

then when you want to enable or disable the form controls you just illiterate through the Controls property of Me:
VB
If FormEnabled = False Then
    For Each Item As Control In Me.Controls
        Item.Enabled = FormEnabled
    Next
Else
    For Each Item As Control In Me.Controls
        Item.Enabled = FormEnabled
     Next
End If

and then before you run this if statement you set the Boolean to either true or false like this:
VB
FormEnabled = True
''Or
FormEnabled = False

if you would like i can improve this post with this control disabling method integrated into your code if you give me your code.
Waraning: this will disable all of the controls in the application until you reenable them.
tell me if this helps,
MasterCodeon
 
Share this answer
 
v2
Comments
sudevsu 19-Dec-14 15:41pm    
Well, I tried doing this, But the form controls are enabled to true even after doing this. Moreover Form says "Not responding" till the file is properly placed in FTP and then shows as normal form once files are placed in FTP. This is weird and killing my Friday :-/
MasterCodeon 19-Dec-14 15:54pm    
and are you using the System.IO.File class?
MasterCodeon 19-Dec-14 15:51pm    
well right before the line of code that uploads your file to the server set the "FormEnabled" variable to true
sudevsu 19-Dec-14 16:02pm    
I did this way before you posted the code. I didn't get it done. I mean it goes to not responding and comes back but not the way we are thinking it should. May be it does this because There is lot of load of FTP Server. I think I need someother ways
MasterCodeon 19-Dec-14 16:07pm    
that might be it but it also might be the fact that you are doing the file copy on the same thread as the application it self.
i had that same problem when i would use the System.Speech to do Text to Speech.
the UI would freeze up until the program stopped speaking.
so i asked how to fix it here and the answer i got was that i had to use the SpeakAsync method instead of the Speak method.
this is due to the fact that SpeakAsync will run the TTS(Text To Speech) operation on a different thread than the UI(or sometimes called the Winform, Application) thread.
I looked and there is no CopyAsync methods so of you know how try running your Copy operation on a separate thread.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900