Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange ActiveForm behaviour
Message
From
16/12/1998 06:32:56
Jody Cairns
OAO Technology Solutions
Moncton, New Brunswick, Canada
 
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00167658
Message ID:
00167967
Views:
27
>F1 and F2 are at the beginning unloaded.
>MDI form is loaded.
>
>(In F1_Activate, there is F1.Enabled = False)
>
>F1.Show
>F2.Show
>MsgBox Screen.ActiveForm.Name
>
>We obtain... F1. Interesting not ?

I didn't obtain F1. I got F2. Where did you put the above three lines of code? I put in in the MDI form's Load event. Since F2 is the last Shown, it makes sense it is the ActiveForm.

However, I think I know where you're going with this. I did the following:

I have this in my main MDI form's Load event
Private Sub MDIForm_Load()
  f1.Show
  f2.Show
  MsgBox Screen.ActiveForm.Name
End Sub
So at startup you see two forms, with F2 being the Active one.

In form F1 I have
Private Sub Form_Activate()
  f2.SetFocus
  f1.Enabled = False
End Sub
And on form F2 I have a button with this code:
Private Sub Command1_Click()
  MsgBox Screen.ActiveForm.Name
  f1.Enabled = True
  f1.SetFocus
End Sub
Now, when the program starts up and I click F1 (which was in the background because F2 is my active form), F2 is made Active and F1 is disabled. Makes sense. However, when I know press the command button on F2, the messagebox displays F1. That is interesting. This appears to be a bug, which is documented at Microsoft at:

http://support.microsoft.com/support/kb/articles/q174/2/12.asp?FR=0

But, I did achieve the modal-like behaviour you wanted, I think.

What'cha think?

jody
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform