|
-
Jan 28th, 2012, 02:37 AM
#1
Thread Starter
Junior Member
[RESOLVED] Design Question
Hi 
I have a design issue which I'm unsure how best to resolve and would really appreciate any help.
My app has a main form (it's the startup form). It includes a number of menu items which typically open modal sub forms. However there are 2 menu items which just need to open an Outlook Explorer calendar for the user to manipulate appointments.
My VB6 version used hidden sub forms to do this and handle the subsequent interaction between the user and the Outlook objects in the Calendar. I need to stop the user interacting with the main form while the Outlook Explorer is open, ie as if the Explorer window were a modal sub-form to the main form. So I manually disable the main form while the Outlook activity is going on, then (try to) enable it when the user closes the Outlook Explorer window. Problem is I can't seem to get a reference to the main form from the sub form to do this, nor pick up an event in the main form which I could use to trigger the enabling of the main form.
An alternative might be to delete the hidden sub forms & put all the code in the main form, but this would be quite ugly; I think I would need to maintain two parallel sets of Outlook objects at the top level in the main form for each of the two functions (a number of the Outlook objects are declared With Events). I would have to have for example mobjOutlookExplorerFunction1 and mobjOutlookExplorerFunction2.
So - I'm wondering what is the neat elegant solution to this that must be out there?
Thanks!
-
Jan 28th, 2012, 05:14 AM
#2
Re: Design Question
When you create a form, you must be doing something like this:
Code:
Dim Thing As New SubFormThatDoesOutlookStuff
Thing.GoDoOutlookStuff
You can just pass in a reference for the main form, just make sure you have a method to re-enable it!:
Code:
Dim Thing As New SubFormThatDoesOutlookStuff
Thing.GoDoOutlookStuff(Me)
-
Jan 28th, 2012, 06:09 PM
#3
Thread Starter
Junior Member
Re: Design Question
Thanks for responding! This does sound blindingly obvious when you put it like that :-) however when I try what I think you are saying it doesn't work.
I am starting the sub form from the main form like this:
Code:
Dim frmModAssessAppt As New frmModAssessAppt
frmModAssessAppt.Start(Me)
Have added a sub to the main form to do the enabling:
Code:
Public Sub enableMe()
Me.Enabled = True
End Sub
The modified sub form:
Code:
Private mMainForm As New frmMain
Public Sub Start(ByRef MainForm As frmMain)
mMainForm = MainForm
...outlook code
End Sub
Private Sub myExplorer_Close() Handles myExplorer.Close
... tidy up outlook objects
mMainForm.enableMe()
Me.Close()
End Sub
The enableMe sub gets called and the Me.Enabled = True line is executed, but the execution seems to stop there, and the Main Form while no longer greyed out is not responding to keyboard or mouse... Any idea what I have wrong? Thank you for your patience!
-
Jan 28th, 2012, 06:25 PM
#4
Re: Design Question
Private mMainForm As New frmMain
You do realise this creates a second copy of the main form? Also, you do not need to pass the argument ByRef.
-
Jan 29th, 2012, 10:32 AM
#5
Thread Starter
Junior Member
Re: Design Question
Yes OK I now have
Code:
Private mMainForm As frmMain
, but same result, the main form is not greyed out but does not respond to keyboard or mouse. Grrrr.
Think this is something to do with the Outlook integration, because if I comment out the code which instantiates the Outlook objects, displays the Explorer and tidies up at the end, ie I just go straight from my sub form Start function to an Explorer_Close() function which just enables the main form, it works fine.
Feels a bit like a problem I had before with stuff running on different threads which I resolved by testing for InvokeRequired...?
-
Jan 29th, 2012, 10:46 AM
#6
Thread Starter
Junior Member
Re: Design Question
Yep fixed it, it needed an InvokeRequired check in the enableMe function in the Main Form.
Thanks for your support Grimfort
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
|