|
-
Aug 21st, 2007, 04:42 PM
#1
Thread Starter
Hyperactive Member
(Resolved) Problem with single instance application
I have a application set as a single instance and have set the event handler like this:
vb Code:
Namespace My
Partial Friend Class MyApplication
Private Sub MyApplication_StartupNextInstance( _
ByVal sender As Object, _
ByVal e As Microsoft.VisualBasic.ApplicationServices. _
StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
MessageBox.Show("Application is already open", _
"Error Opening Form", MessageBoxButtons.OK)
e.BringToForeground = True
End Sub
End Class
End Namespace
Everything seems to work ok as long is my applications isn't hidden (I hide the app to an icon in the system tray). When it is hidden the application is brought to the foreground but it doesn't show up on the screen and only shows as an application in the toolbar. Clicking on it doesn't do any thing to show it either. Is there something else I need to do to make this work correctly?
Last edited by FastEddie; Aug 21st, 2007 at 10:59 PM.
-
Aug 21st, 2007, 05:32 PM
#2
Re: Problem with single instance application
It sounds like your app is going from hidden to visible but minimized. If you click on the app in the toolbar, does it show up, or is it utterly unattainable?
Also, when it comes back from being hidden, is it just sitting there, or is it running some code that would block paint messages from reaching the main window?
My usual boring signature: Nothing
 
-
Aug 21st, 2007, 06:21 PM
#3
Thread Starter
Hyperactive Member
Re: Problem with single instance application
I did get it to open once by right clicking it on the tool bar and maxmizing it but have not been able to do that again. It just gives me the move and close and size options (maximize is grayed out) when I right click on it.
I did just disable all the code the runs when the form is maximized and got the same results so the only thing happening is the unhiding of the form:
vb Code:
#Region "Timer & Notifier"
Private Sub notCSA_BalloonTipClicked( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles notCSA.BalloonTipClicked
'btRefresh.PerformClick()
Me.Visible = True
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
notCSA.Visible = False
End Sub
Private Sub notCSA_MouseDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles notCSA.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Visible = True
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
notCSA.Visible = False
End If
End Sub
-
Aug 21st, 2007, 08:10 PM
#4
Re: Problem with single instance application
Try putting this in your StartupNextInstance event handler:
-
Aug 21st, 2007, 10:58 PM
#5
Thread Starter
Hyperactive Member
Re: Problem with single instance application
Thanks . That seemed to do the trick.
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
|