Solved

Accessing Other Instances while MODAL win up?!?

Posted on 1999-01-21
7
147 Views
Last Modified: 2010-05-03
I have create 3 forms. The first form creates 3 instances of Form2 and displays them on screen. In Form2's Load event i tell it to create an instance of Form3 and display it as a MODAL window.  When i do this all of my Form2 instances are frozen until Form3's window is shut down. I can make Form3 modeless allowing me to have FULL access to my Form2 instances BUT i do not want ot have clickable access to ANYTHING (MODAL) on the form that popped up the Form3 instance. So, how do i have a MODAL window pop up on a specific form instance so as to not allow me to click (or have any user access to) that form that caused the MODAL window to pop up WHILE allowing me to have COMPLETE access to the other Form instances?

Here is example code on what i mean:
----------
FORM 1:

Dim x() As Form2

Private Sub Form_Load()
    ReDim x(2)
   
    Set x(0) = New Form2
    Set x(1) = New Form2
    Set x(2) = New Form2
   
   'I make it MODELESS here so i can display all instanes right away
    x(0).Show
    x(1).Show
    x(2).Show
End Sub

---------
FORM 2:

Dim x As Form3
Private Sub Form_Load()
    Set x = New Form3
   
   'For this Form instance i want to display Form 3 as a modal window (so i cant have user access to this form instance while it is up) BUT i still want to have access to the other Form 2 instances. This is the problem!
    x.Show 1
End Sub

----------
FORM 3:

Just add a Label to it with a caption = "Waiting..."
0
Comment
Question by:ljaques
7 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1469931
System modal is just that. If you want things to hold on that window, then every will *HOLD*. Sounds to me like you're trying to have it both ways. System would seem to be behaving correctly if I read your question right. Forms are independent at this level. You can't have it modal to one form and non-modal to another. If it's modal, it's modal to everyone.

M

0
 

Author Comment

by:ljaques
ID: 1469932
mark2150,
  Thanks for the info but it doesn't solve my problem. Have any suggestions to solve my dilema?
0
 

Author Comment

by:ljaques
ID: 1469933
I was just goofing around in VB right now and i notice that if i set the form's ENABLE property to = false when i pop up a MODELESS form (in this case it was FORM3) then i have complete access to the other instances (form2) while preventing user input to the form that caused the form3 instance to pop up. I thought by setting the ENABLE property to equal FALSE would prevent any events from occuring to this form but when i added the Timer control to it, the disabled form was able to receive events, which works great for me. Please let me know if this is a viable solution or does it have a nasty side-effect.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:caraf_g
ID: 1469934
Sounds good!
0
 
LVL 18

Expert Comment

by:mdougan
ID: 1469935
No, that is probably the best solution for you.  Actually, I'm surprised that you were ever able to run that code, as you are only allowed to open one modal window at a time.  In your code above, you were creating 3 instances of form2 and each one was trying to open a modal form3.  This should have caused you problems.  

Another thing you could have done is in the Deactivate event for form3 you could see which other form was now the Screen.ActiveForm and if it was form3's parent - form2 then it could beep and set the focus back on itself.  Since your form2s are dynamically created, knowing which instance of form2 was the parent of that particular instance of form3 would be a little tricky.

MD
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469936
His app was most likely halting after it created the first instance of FORM2 which chained to the Modal Form 3.

I'd solve it by restructuring my program logic. Generally, if you're getting into this type of precedence trap it's a sign that you're coming at the problem from the wrong direction. Rather than butt my head against the wall trying to circumvent the operation of the OS, I'd ask myself how else I could solve this. For example, why do you need to pop three *identical* forms? Why not pop just one and wait for that to complete (since that what the modality is requiring anyway!) before popping the next. I generally feel that it's an error to toss a window at a user that they *can't* interact with! Why show them *anything* if they're not allowed to tinker?

Just my $.02.

M

0
 
LVL 1

Accepted Solution

by:
rondeauj earned 10 total points
ID: 1469937
Private Sub Form_Load()
    ReDim x(2)
     
    Set x(0) = New Form2
    Set x(1) = New Form2
    Set x(2) = New Form2
     
   'I make it MODELESS here so i can display all instanes right away
    x(0).Show
    x(1).Show
    x(2).Show
    doevents
    form3.show modal,parentform
End Sub

do not load the form until the other form are loaded. You can't do it the way you want to.  So you must find another way to make it work.  Are you going to want to load this form3 everytime form2 is load?  if so you should check the value of the form array against the ubound() value of the array and with the use of a If....Then ......end if wait until the last form has loaded and then load form3.


form2_load

  dim numofforms as integer
  numofforms = ubound(form2array)
  if form2.index = numofforms then form3.show modal,parentwindow

end sub


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now