Closing the MDI CHILD Form by pressing CTRL+F4 Keys
Hi all,
I want to Close AMD CHILD Form by pressing CTRL+F4 keys. Any idea how to do that. I've used Form_KeyPress event but its not working bcoz i have different controls on my form and those controls grabs the focus, so Form_KeyPress never executes...
Re: Closing the MDI CHILD Form by pressing CTRL+F4 Keys
Quote:
Originally posted by aks_1610
Hi all,
I want to Close AMD CHILD Form by pressing CTRL+F4 keys. Any idea how to do that. I've used Form_KeyPress event but its not working bcoz i have different controls on my form and those controls grabs the focus, so Form_KeyPress never executes...
I do not know what you are talking about pal, but you do not have to code for that. Pressing Ctrl + F4 automatically closes the active MDI child form.
Re: Closing the MDI CHILD Form by pressing CTRL+F4 Keys
Quote:
Originally posted by aks_1610
Hi all,
I want to Close AMD CHILD Form by pressing CTRL+F4 keys. Any idea how to do that. I've used Form_KeyPress event but its not working bcoz i have different controls on my form and those controls grabs the focus, so Form_KeyPress never executes...
MDI form doesn'r respond to any key event and since your child form is borderless you'd need to use a Timer (on the MDI form, Interval = 100) and some Windows API:
VB Code:
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_CONTROL = &H11
Private Const VK_F4 = &H73
Private Sub Timer1_Timer()
GetAsyncKeyState(VK_F4) Then
If GetAsyncKeyState(VK_CONTROL) Then
Unload Form1 'assuming that Form1 is that child you need to unload
End If
End If
End Sub
Note: in order for this sample to work your borderless form will have to be the topmost at the moment.