5 replies
Add a child form to your project, keep the visible status to "False" for this form. Load this form in the form load event of MDI Form.
Handle the Keypress even of this from, check for the keyasccii corresponding to vbKeyEscape and issue a Unload Statement.
When any other form in the application will be called, focus will be the new window, hence pressing the Escape key will not fire the events of the invisibile window, check this out, if face any problems, tell me i will send u the sample code !!
by ohjani
by sl-campbell
Drop the following into the declarations setion of the MDI:
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Add a Timer control to the MDI
In the MDI Load, activate the timer.
In the Timer control, do something like the following (Out of my head so please be patient if it doesn't work the first time):
If Vb.Forms.Count = 1 then
If GetAsyncKeyState(vbKeyEscape) < 0 Then Unload Me
end if
This uses the VB Forms collection - it will only unload the MDI if the MDI is the only form left open. If have any other forms that are always open but hidden, then you may need to change the Count from 1 to X.
Instead of:
If Vb.Forms.Count = 1 then
you could use:
If myMDIForm.ActiveForm Is Nothing Then
by ohjani
by ohjani
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending