|
Devraj Raut wrote: The Error is that i cannot call the load event inside ThreadStart.
You're supposed to pass it a method. An event is not a method.
Also, I don't think it's a good idea to launch a form on a different thread. Forms and their controls are not thread safe and are not supposed to interact with other forms/controls/etc. on a separate thread.
Instead, I recommend that you run your bittorrent code on a different thread. If you want it to update your form, then you should look into using BeginInvoke() to do this in a thread safe manner.
http://www.codeproject.com/csharp/begininvoke.asp[^]
|
|
|
|
|
Hi!
How can i catch a filename that was passed to my application?
for ex. I added a shell registry entry so that everytime i right click a file it opens it in my application. The registrykey is this "myApplicationPath %1" so that the file gets oppened with my application and the filename is passed along.
Now how do i catch that passed filename in my application??
Thanx
|
|
|
|
|
The file name will be passed into the 1st command line argument. You can access these command line arguments in your main function.
Shared Sub Main(ByVal args() As String)
Dim sFileName As String = String.Empty
If (args.Length >= 1) Then
sFileName = args(0)
End If
End Sub
|
|
|
|
|
thanks Joshua, i tried but i'm still in the dark here
i don't know how to use your code really...
my application is a windows app with forms, I tried putting it in form_load, but..then i tried making a new sub, but..
i'm still in my learning curve in vb.net so can you be more specific, please
thanks
|
|
|
|
|
The code I gave you assumes that your project's Startup object is set to "Sub Main". Your startup object is obviously set to your form. You can access the command line arguments in your form if you want via System.Environment.CommandLine, but this give you just 1 string and you would have to parse it out yourself.
I think switching to a Sub Main would be better. You would set this up by doing the following:
1) Go to the Solution Explorer panel.
2) Right click on your project file in the tree.
3) Select Properties on the context menu.
4) Select CommonProperties\General on the tree on the left.
5) Select "Sub Main" in the Startup Object ComboBox.
6) Click OK.
7) Add a Main function somewhere in your code. I like to put mine in a Main.vb class file. The main code should look something like this...
Public Class Main
Public Shared Sub Main(ByVal args() As String)
' Get file name to open from the command line.
Dim sFileName As String = String.Empty
If (args.Length > 0) Then
sFileName = args(0)
End If
' Do something...
' Display your main form with XP theme.
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New YourMainForm)
End Sub
End Class
|
|
|
|
|
it works!!!
i had a little trouble setting up the Startup Object to Sub Main in vs2005 but now it works
Thank you VERY much
if you don't mind i have an other question..
are there any benefits to starting your app with Sub Main rather than directly with a form (assuming you dont need to catch any passed data of course )
|
|
|
|
|
Pruck wrote: i had a little trouble setting up the Startup Object to Sub Main in vs2005 but now it works
The instructions I gave you were for VS 2003. Sorry about the mixup. I'm glad you got it working.
Pruck wrote: are there any benefits to starting your app with Sub Main rather than directly with a form
Here's some advantages. I'm sure there are others:
- Catching command line arguments of course.
- Enabling VisualStyles for WinXP theme support. Must be done before showing your form.
- Good place to check if an app instance is already running. Although VB2005 gives this to you for free now.
- Good place to do startup validation before showing a heavy form that takes a while to load up.
|
|
|
|
|
Thanks! I appreciate your help.
and now that my curiosity has been satisfied i can finally get myself same sleep
|
|
|
|
|
Hi, Microsoft ISA 2004 has the possibility to control the user that access to the internet and display the result of information relate to user activity and internet usage of specific user.
From here, i have an idea. I have a server and i want to write my own application that could control the session of the user that connect to the internet through the server. First, i want to log the session of user which access to the internet through the server in a text file. Then i want to write my own vb.net application which transfter those information into SQL server and generate a report. Does anyone have an idea, website resource or sample to do it?
|
|
|
|
|
Roath Kanel wrote: anyone have an idea, website resource or sample to do it?
This is essentially a internet proxy server. All requests, and responses, will go through your proxy. You can do what ever you want with them.
This will not be an easy project to tackle. You'll be heavily using the sockets classes and threading. You'll be writing both an HTTP Server and a client in one application. There isn't going to be any one site describing how to do this.
Start with simple sockets chat applications and work your way up. Write a Telnet client after that, then a simple Telnet server. You'll want to move up to multi-threading servers after that. A proxy server will be a glorified extension of both the Telnet client and multi-threaded server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave, thank you very much for your information.
Dave Kreskowiak wrote: Start with simple sockets chat applications and work your way up. Write a Telnet client after that, then a simple Telnet server. You'll want to move up to multi-threading servers after that. A proxy server will be a glorified extension of both the Telnet client and multi-threaded server.
Are there any resource for me to read about:
- Programming with socket chat application.
- Programming telnet.
- Multi-threading.
I prefer to learn about this step in order to do my own work.
|
|
|
|
|
|
hi all i want to know that where to place the common variables and access them in all forms in vb.net.
i vb6 there was area known as the sub main. i had made an application as windows form application.
ddd
|
|
|
|
|
tasleem143 wrote: i want to know that where to place the common variables and access them in all forms in vb.net.
Create a module and delcare your viriable as GLOBAL.
|
|
|
|
|
There's no such thing as Global variables in the .NET Framework.
You can have Shared variables in classes though...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Common practice is to place these in a class as Shared variables. But, this goes against accepted OOP practices, so try to keep this to a minimum as you learn true Object Oriented Programming practices.
Public Class Globals
Public Shared GlobalVar As Integer
End Class
You can then access this "global" anywhere in your code, simply by using:
Globals.GlobalVar = 3
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
I developed project using WINSCOK CONTROL in VB.Now i'm in need to convert it into VB.NET. I'm trying to upgrade it but i cann't pls help how to upgrade it.
subhulakshmi
|
|
|
|
|
|
It is regarding passing of complex structure consisting of double,structure to an api in vb.net. I have tried marshalling the structure as ptr and sending it to api, but it doesn't works.
could u plz throw light on it.
---Pravin.
|
|
|
|
|
pravinkgarg,
Without seeing any of your real code,
I'd guess it needs to look something like this:
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
"<Windows Form Designer generated code Removed>"
Public Declare Auto Function xyz Lib "lib1" (ByRef t1 As IntPtr) As Integer
Private Sub TestMe()
Dim retval As Integer
Dim ctest As New test
'Allocate a block of memory
Dim ctestSize As Int32 = Marshal.SizeOf(ctest)
Dim itest As IntPtr = Marshal.AllocHGlobal(ctestSize)
'Marshal data from a managed object, to an
'unmanaged block of memory
Marshal.StructureToPtr(ctest, itest, False)
'call xyz
retval = xyz(itest)
'Marshal data from a managed object, to an
'unmanaged block of memory
Marshal.StructureToPtr(ctest, itest, False)
'<<<< DO SOMTHING WITH ctest HERE >>>>>
'somthing = ctest.item1
'somthing = ctest.item2
'...ect..
'<<<< BEFORE YOU FREE MEMORY HERE >>>>>>
'Free the block of memory
Marshal.FreeHGlobal(itest)
End Sub
End Class
Public Class test
Public item1 As Integer
Public item2 As New struct2
<VBFixedArray(45)> _
Public item3() As Double
Public Sub New()
item3 = New Double(45) {}
End Sub
End Class
Public Class struct2
'
'<Public whatever is in struct2>
'
Public Sub New()
'<whatever = New of whatever Intializes struct2>
End Sub
End Class
Maybe that will help you out,
progload
|
|
|
|
|
hi every one,
i am using frames concept on my web page. on one of the
frame i am showing a gif image.i have to zoom the "particular" gif image
area where my mouse pointer is pointing.
thanx
your
peter
|
|
|
|
|
This is better asked in the ASP.NET or Web Development forums. What you what to do can't be done in ASP.NET code. ASP.NET is a server-side only technology that generates HTML for the client.
What you want would have to be done using client-size JavaScript.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I was trying to show the image in a picturebox in form 1, which when i click the image from a picturebox on the form2 then picturebox image in form 1 will be the same as selected in form2. Is there anything wrong with my code? i just cant show it.
'ps refer to the other form call PlayerSelect .
Dim ps As New PlayerSelect
ps.PictureBox1.Image = PictureBox1.Image
-- modified at 9:51 Saturday 18th February, 2006
|
|
|
|
|
pittybird wrote: Is there anything wrong with my code?
Dim ps As New PlayerSelect
ps.PictureBox1.Image = PictureBox1.Image
Yes, this is very wrong.
By doing "New PlayerSelect", you're creating a new form object, which is not the same form object as the one that is already being displayed.
Here's an easy solution (although I'd never do it this way).
You could pass a reference of form1 to form2. Form2 could then manipulate form1 directly. It would look something like this...
Dim myForm2 As New Form2<br />
myForm2.PlayerSelect = Me<br />
myForm2.ShowDialog()
I'll leave it to you to figure out the rest.
-- modified at 16:46 Saturday 18th February, 2006
|
|
|
|
|
error found ,it said form2 is not a member of playerselect.
actually the form2 i have change its name to playerselect.
i think the code u give me is the same as mine at the beginning
Dim myForm2 As New Form2 = Dim ps As New PlayerSelect
just the name different.about the
myForm2.PlayerSelect = Me
wat is it refer to? refer to the form1 become form2?
|
|
|
|