Here is the situtation:
1 exe (acting like main menu) that launches 1-N dlls where each dll is
seperate application. The exe and dlls all are sharing the same memory for
the environment. We have a business requirement that if one of the
applications is showing a dialog box, it cannot lock up the other running
applications-ugly work around but we have accomplished this. Because N number
of windows can be running at once there is a feature called, clever enough,
"Show Open Windows" which when shows disables all the running forms so that
the user must get rid of showopen windows before they can do anything else.
While this action was not a problem, if any of those forms where showing
dialogboxes then the dialog boxes were still enabled allowing the user to
interact with them. I created an extension to the form to use a custom
ShowDialog routine that setup an event that if the calling form's enabled
problem changed then change the enabled property within the dialog box works
fine.
The problem is if the parent form(one that showed the dialog) is disabled by
the "show open windows" call, when it is reenabled by the showopenwindows
going away, the dialog remains on top of the calling form but you can
interact with the calling form - changing it's context etc. This is easily
repeatable including if you use a msgbox.
CanFocus is the problem where it is set to false when a dialogbox is shown.
When my showopenwindows disables the calling form and then reenables it,
CanFocus is set to true even though there is a dialog box still being shown.
Is there a way (api or whatever) to reset this flag to be accurate again
and now allow focus?
Example of the code to make this behavior happen:
'note #1: the first timer was used to check the enabled property for it's
state
'note #2: the second timer disables the form 5 seconds after you click on
the button to show the messagebox. 5 seconds after that the form will
reenable allowing you to interact with it even though the message box is
still showing.
Public Class Form1
Private _timer As Timer
Private _timerdisable As Timer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
_timer = New Timer(500)
_timer.AutoReset = True
AddHandler _timer.Elapsed, AddressOf Timer_Elapsed
_timer.Enabled = True
_timerdisable = New Timer(5000)
_timerdisable.AutoReset = True
AddHandler _timerdisable.Elapsed, AddressOf TimerDisable_Elapsed
End Sub
Private Sub Timer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs)
If Me.InvokeRequired Then
Me.Invoke(New Action(Of Object, System.Timers.ElapsedEventArgs)(AddressOf
Timer_Elapsed), Nothing, Nothing)
Exit Sub
End If
Me.Text = Me.Enabled.ToString & "::" & Now.ToString
End Sub
Private Sub TimerDisable_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs)
If Me.InvokeRequired Then
Me.Invoke(New Action(Of Object, System.Timers.ElapsedEventArgs)(AddressOf
TimerDisable_Elapsed), Nothing, Nothing)
Exit Sub
End If
'----
'stop the timer so it doesn't disable the form again.
If Not Me.Enabled Then _timerdisable.Enabled = False
'-----
Me.Enabled = Not Me.Enabled
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
_timerdisable.Enabled = True
MsgBox("HEY")
End Sub
End Class
after form is disabled and then enabled you can now grab the title bar of
the calling form and move it around.
--
Thank you...Nathan - GBIS
This is a VB6 and earlier group(VB Classic). VB.Net and all dotnet groups
have either "dotnet" or "vsnet" in the group name. Please use the following
group instead:
news://msnews.microsoft.com/microsoft.public.dotnet.languages.vb