|
You're going to have to implements some remote call to tell App A to refresh itself. You can do this either using .NET Remoting (deprecated after .NET 2.0) or Windows Communication Foundation (.NET 3.0 and above).
|
|
|
|
|
Not sure if I'm heading in the right direction but I have an application that when minimized it goes into the system tray, but then when the user double clicks the the application icon a second time it opens another instance of the application I would like it to activate the instance already running in the system tray. I can use Process.GetProcesses() to find if the process is currently running, but not sure what comes next I will list below what I have got so far... This application requires the user to login so I use a sub main to login then run app and when not used it is minimized don't want users logging in multiple instance...
Any help would be Greatly Appreciated
VB.net VS2005
---------------------------
Public Sub Main()
Dim localAll As Process() = Process.GetProcesses()
Dim x As Integer
For x = 0 To localAll.Length - 1
If InStr(localAll(x).ToString, "MyApp") Then
'Activate the running app ' <-- Need Help Here
Else
Dim dlg As New LoginForm1
If dlg.ShowDialog() = DialogResult.OK Then
Application.Run(Form1)
End If
End If
Next
End Sub
dotnetme2
|
|
|
|
|
For a single instance app, all you have to do is Enable the Application Framework in your "My Project" item in the Solution Explorer.
What do you mean by "Activate"?? Are you trying to show the main form of your app?? EXACTLY how is this form hidden from the user??
|
|
|
|
|
What I mean by activate is basically maximize the application in the system tray rather then start a new instance...
Thanks for the tip But.... if I check the "Enabled application framework" check box in "My Project" it says that I must use a "Form" as my "Startup object" and I have "Sub Main" in Module as my startup so I had to uncheck it. I'm sure there is another way to launch "sub main" but I not sure just how to do it...
Is there another to either make it a single instance??? The reason I used a module was instead of a form was so I can call the login form have the user login then close the login form and launch the main form of the app.
Thanks for any help...
dotnetme2
|
|
|
|
|
dotnetme2 wrote: Is there another to either make it a single instance???
It's been discussed and rehashed countless times for years. All you have to do is Google for "VB.NET single instance application". Here's[^] a good one, since it even has the "show main window" functionality you were looking for.
|
|
|
|
|
Perfect Thanks...
dotnetme2
|
|
|
|
|
Forgive me please if this is the wrong place but it is probably a VB question.
I need to know if it is possible to create a macro in VB under Excel so that under a push of a button a new worksheet can be created and named after the contents of a cell.
That is, one would insert a name into a cell and hit a "Create New Sheet" button link to a macro that would do it.
I have tried looking at the manuals and the help screens, but my knowledge of VB is weak, and although my Excel isn't bad, it is not something I have had a requirement to do before.
If it is at all possible I would be immensely grateful!
------------------------------------
I try to appear cooler,
by calling him Euler.
|
|
|
|
|
Sure. It would probably look something like:
Dim newSheet As Worksheet
Set newSheet = Sheets.Add()
newSheet.Name = Sheet1.Range("someCellAddress").Value
|
|
|
|
|
Thanks for that, I shall go and check it out!
(It may make it look as though I know what I am on about )
I knew it was possible, but for the life of me I couldn't figure it out.
Thanks
------------------------------------
I try to appear cooler,
by calling him Euler.
|
|
|
|
|
I currently have a program that loads window forms. How do I change this program if I don't want the forms to show. How do I change my program to run from a sub main procedure? My Reason: My program communicates with a 3rd party device. Currently I can run my programs in windows and interact with it. But, on another project my program can be used for communicating but does not need to be viewed. I want to have my program run in the background (still doing the communicating). What is the best way of doing this? I would like to set a property. When this property is check the program runs as a stand alone program. When not checked I see all windows forms.
|
|
|
|
|
Put a Sub Main in either a module or your current startup form. In this code, chekc the command line parameters to see if an option that you define is there, telling the code how to launch itself.
You'll probably have to reorganize your code, seperating the work classes from the form code (User Interface code). All of the work code should have nothing to do with updating controls, getting input from the user, nothing. It should be able to run completely on its own without any UI concerns whatsoever.
A Sub Main would looks something like:
Public Class Form1
Inherits System.Windows.Forms.Form
Private RunUnattended As Boolean = False
<STAThread()> _
Shared Sub Main(ByVal cmdArgs() As String)
For Each cmd As String In cmdArgs
If cmd = "myOption" Then
RunUnattended = True
End If
Next
If RunUnattended Then
' Run your work code here...
Else
Application.Run(New Form1)
End If
...
|
|
|
|
|
i want to make am editor like MS Word, where show tool bar and menu in mdi form and when open child documents same as in word. but unfortunatly when i am opening child document then its disturbing the tool bar in mdi menu by changing the tool bar position of mdi form.
I want to open child document but don't want any physicaaly movement in mdi toolbar.
here i attached sample that may help you to understand the problem. my objective that mdi form still remains same when open any child form. same as in ms word editor.
Regareds
Salman
I am Using following code but its not working properly, here i tried to apply two techiques but every one changing the mdi menu shape
Public Class Form1
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Dim frm As New frmChild
frm.MdiParent = Me
'frm.Height = Me.Height - 40
'frm.Width = Me.Width - 20
frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
With frm
.WindowState = FormWindowState.Maximized
End With
FormBorderStyle = Windows.Forms.FormBorderStyle.None
MaximizeBox = False
MinimizeBox = False
ShowIcon = False
ShowInTaskbar = False
SizeGripStyle = Windows.Forms.SizeGripStyle.Hide
frm.Show()
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
MessageBox.Show("Please note the Toolstrip Position, and then open child form, then toolstrip location relocated" & Chr(13) & "I like to stick tool strip at fixed position")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WindowState = FormWindowState.Maximized
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
ControlBox = False
FormBorderStyle = Windows.Forms.FormBorderStyle.None
' Locked = True
MaximizeBox = False
MinimizeBox = False
ShowIcon = False
ShowInTaskbar = False
SizeGripStyle = Windows.Forms.SizeGripStyle.Hide
WindowState = FormWindowState.Normal
Dim frm As New frmSecond
frm.MdiParent = Me
frm.Height = Me.Height - 87
frm.Width = Me.Width - 15
frm.Show()
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
Me.Close()
End Sub
End Class
|
|
|
|
|
I can't duplicate the problem. Which version of VB.NET are you using?? Have you put any Menu's or ToolsBars on the child forms??
|
|
|
|
|
I am using vb.net 2005, and i have not put any tool bar or menu bar in child form. its just like a ms word editor where i want to manage documents.
Salman
|
|
|
|
|
OK. I still can't duplicate your problem at all. I can't intentionally break the code to make it do what you're describing. There's some piece of information you've left out that's critical to the problem, but I have no idea what it is. I'd need to see the project to figure it out.
|
|
|
|
|
visual studio 2003:
how can i find out, how much free space is left on a disc?
|
|
|
|
|
You'll have to use WMI to get the freespace in .NET 1.1. The DriveInfo class doesn't show up until .NET 2.0.
I believe you're looking for the Win32_LogicalDisk WMI class. Google results for "Win32_LogicalDisk[^]"
|
|
|
|
|
thanks dave. that's what i am looking for.
|
|
|
|
|
hi.
i m shahid, software engineer working digitalbook inc. i m developing a web browser. i m using webbrowser control. all i need is wen a page contains errors my browser displays an error messagebox while internet explorer just display 'Error on page' in status bar. i don't wana see that error messagebox. how can i do this?? thx in advance.
[ one more thing errors are of javascript]
King
|
|
|
|
|
Have you looked into the ScriptErrorsSupressed property of the WebBrowser control? (Only available in .NET 2.0 and above!)
|
|
|
|
|
Hello there,
I tried a couple of ways and made a lot of changes, however if I run this in debugging mode it works, it stops the timer and display msgbox.
But if I run this outside it does not stop timer and does not display msgbox..
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick<br />
<br />
Timer1.Start()<br />
<br />
Label1.Text = formatDigits(Now.Hour) & ":" & formatDigits(Now.Minute) & ":" & formatDigits(Now.Second)<br />
<br />
Shutdown()<br />
<br />
End Sub<br />
<br />
Private Sub Shutdown()<br />
<br />
Dim myTime As Date = Format(Now(), "hh:mm:ss tt")<br />
Dim StartHour, StartMinute As Integer<br />
Dim EndHour, EndMinute As Integer<br />
Dim StartTime As String<br />
Dim EndTime As String<br />
<br />
StartHour = 6<br />
StartMinute = 0<br />
EndHour = 11<br />
EndMinute = 16<br />
StartTime = TimeValue(StartHour & ":" & StartMinute)<br />
EndTime = TimeValue(EndHour & ":" & EndMinute)<br />
<br />
If myTime >= StartTime And myTime < EndTime Then<br />
<br />
If String.Compare(Now.Hour.ToString, EndHour.ToString) = 0 Then<br />
If String.Compare(Now.Minute.ToString, EndMinute.ToString) = 0 Then<br />
Timer1.Stop()<br />
MsgBox("1st piece")<br />
End If<br />
End If<br />
<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Timer1.Enabled = True<br />
Timer1.Start()<br />
<br />
End Sub<br />
<br />
Private Function formatDigits(ByVal Value As Integer) As String<br />
<br />
Dim newValue As String<br />
Dim len As Integer = Value.ToString.Length<br />
<br />
If len = 1 Then<br />
newValue = "0" + Value.ToString<br />
Return newValue<br />
Else<br />
Return Value.ToString<br />
End If<br />
<br />
End Function
I looked at several possibilities and no luck any ideas why this might be?
thanks
|
|
|
|
|
It obvious you don't know how datatype work, or how DateTime works, or how If statements work in the .NET Framework. I would strongly suggest picking up a book on VB.NET for beginners. I lost count of the number of things wrong with this code. But, here are a few of the major problems.
First, In the Timer1_Tick handler, you do NOT nee to call Timer1.Start. It's already started.
The Shutdown method is doing all kinds of thing it does not need to do, if you only understood how Date/Time works in VB.NET, you could reduce this down to a few lines of code.
In the Button1_Click handler, you set Timer1.Enabled to True, then you call Timer1.Start, which does the exact same thing. You only need one of these lines.
FormatDigits isn't even required. The same thing can be accomplished just by specifying the correct formating string where needed.
Your (shortened) code might look something like:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = DateTime.Now().ToString("HH:mm:ss")
Shutdown()
End Sub
Private Sub Shutdown()
' This can be rewritten even shorter, but this is of a level that you should easily understand.
Dim StartTime As New DateTime(Now.Year, Now.Month, Now.Day, 6, 0, 0)
Dim EndTime As New DateTime(Now.Year, Now.Month, Now.Day, 11, 16, 0)
If StartTime <= Now() AndAlso Now() <= EndTime Then
Timer1.Stop()
MsgBox("1st piece")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
|
|
|
|
|
Thanks for pointing out the errors in my code.
As a matter of fact you're right when you suggest me starting from scratch as I only done my first 2 week course in vb.net 3 months ago
So what do you start coding when finished with "hello world" messages. Maybe one day I'll be as good a coder as you helping others on their way..
I made a change to this line in your code because it fires all the time
If StartTime <= Now() AndAlso Now() <= EndTime Then
to this
If Now() <= StartTime Or Now() >= EndTime Then
to have the event fired outside my start and end times
If I want this code to run in the background while other applications are running, will this affect other resources?
thanks Chris
|
|
|
|
|
Xooku wrote: So what do you start coding when finished with "hello world" messages.
You start reading the documentation on the .NET Framework and start writing small apps that let you test and see what various classes do and how to work with them.
Xooku wrote: I made a change to this line in your code because it fires all the time
If StartTime <= Now() AndAlso Now() <= EndTime Then
"Fires all the time"?? What did you set the Interval property on the Timer to?? This code will run every x number of milliseconds because the Timer Tick event is being called every x number of milliseconds.
Xooku wrote: If I want this code to run in the background while other applications are running, will this affect other resources?
Depends on that Timer and what your code is really doing. The faster the Timer Ticks, the more CPU is going to be taken up by whatever code is in the Tick event.
|
|
|
|
|
I've set the timer interval to "1000" for second intervals.
And made the change to this
If Now() <= StartTime Or Now() >= EndTime Then
because ie. startime "10H00" to endtime "18H00", the event must fire any time between "18H00" to the next morning "10H00".
In my previous reply I used a timer. Would this be the correct way then to use threading?
Public Class Form5<br />
Dim t As System.Threading.Thread = Nothing<br />
<br />
Private Sub Shutdown()<br />
<br />
Do<br />
System.Threading.Thread.Sleep(1000)<br />
Dim StartTime As New DateTime(Now.Year, Now.Month, Now.Day, 6, 0, 0)<br />
Dim EndTime As New DateTime(Now.Year, Now.Month, Now.Day, 11, 56, 0)<br />
<br />
If Now() <= StartTime Or Now() >= EndTime Then<br />
MsgBox("1st piece")<br />
t.Abort()<br />
End If<br />
Loop<br />
<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
t = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf Shutdown))<br />
t.Start()<br />
<br />
End Sub<br />
End Class
thankyou Chris
|
|
|
|