|
-
Jul 1st, 2008, 10:00 PM
#1
Thread Starter
Hyperactive Member
[2008] com/dial up modem help
i have a dail up modem connected to COM4. i need to be able to tell how long it has been connected to the Internet using vb.net 2005. i also would like to know how to forcibly close the modem or the COM4 port. i would also like to know how to send the program the the system tray when the close button is pressed. but if there is no quick answer then i am sure i can find it in the forums someplace.
thanks in advance.
-
Jul 2nd, 2008, 06:03 AM
#2
Re: [2008] com/dial up modem help
I cant help with the COM stuff but to minimise a program to the system tray you just need to use the NotfyIcon control from the toolbox in VS. Something like this
vb Code:
Me.Visible = False
Me.ShowInTaskbar = False
MyNotifyIcon.Visible = True
Obviously that assumes that you have a notify icon on your form named MyNotifyIcon
-
Jul 2nd, 2008, 06:26 AM
#3
Re: [2008] com/dial up modem help
You could try to open the port. If it is already open, your open will fail.
-
Jul 2nd, 2008, 11:19 AM
#4
Thread Starter
Hyperactive Member
Re: [2008] com/dial up modem help
 Originally Posted by dbasnett
You could try to open the port. If it is already open, your open will fail.
if the program is running then i know that the port will be open. i really need to know how long it has been open. there has to be a way to do it becasue if you double click on the network icon in the sys tray then you can see how long you have been connected.
-
Jul 2nd, 2008, 11:28 AM
#5
Thread Starter
Hyperactive Member
Re: [2008] com/dial up modem help
 Originally Posted by chris128
I cant help with the COM stuff but to minimise a program to the system tray you just need to use the NotfyIcon control from the toolbox in VS. Something like this
vb Code:
Me.Visible = False
Me.ShowInTaskbar = False
MyNotifyIcon.Visible = True
Obviously that assumes that you have a notify icon on your form named MyNotifyIcon 
what sub does this belong in i cant seem to find a form minimize or some other related sub.
-
Jul 2nd, 2008, 12:06 PM
#6
Re: [2008] com/dial up modem help
 Originally Posted by bagstoper
if the program is running then i know that the port will be open. i really need to know how long it has been open. there has to be a way to do it becasue if you double click on the network icon in the sys tray then you can see how long you have been connected.
sorry.
-
Jul 2nd, 2008, 01:59 PM
#7
Re: [2008] com/dial up modem help
 Originally Posted by bagstoper
what sub does this belong in i cant seem to find a form minimize or some other related sub.
Well you said you wanted it to happen when the user clicks a close button... so it belongs in the click event handler for a Close button.
If you were referring to the X in the top right hand corner of the window, then you would put something like this in the FormClosing event of your form:
vb Code:
If not CanClose = True then
e.Cancel
Me.Visible = False
Me.ShowInTaskbar = False
MyNotifyIcon.Visible = True
End If
So what we are doing here is saying if the variable named CanClose is NOT set to True then we cancel the closing event (to stop your app exiting) and then just make the form invisible etc. I would advise you to declare the CanClose variable at class level in your form like so:
vb Code:
Dim CanClose As Boolean = False
Then when you DO actually want to close the program you can just set CanClose to True and then the e.Cancel line will not get called so the program will actually exit.
Hope that makes sense.
-
Jul 2nd, 2008, 06:40 PM
#8
Thread Starter
Hyperactive Member
Re: [2008] com/dial up modem help
thanks. that is a big help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|