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...
A man with nothing to live for has everything to fight for...
Re: Closing the MDI CHILD Form by pressing CTRL+F4 Keys
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.
Originally posted by aks_1610 i have done every thing. Removed the code but it did not Unload.
At last i tried unloading the form thr. coding that did work but CTRL+F4 is not working even if i use this code.
VB Code:
'Closing the form if user presses F4 Key
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF4 And Shift = 2 Then Unload Me
End Sub
What are you guys doing ????
You do not need no code for this. Just open MDI open some child form and press Ctrl + F4, it will close the child form. It closes on my machine. I am running win 2K.
Originally posted by aks_1610 Please see the attached file:
Got the problem !
Its not closing the form because you have set its borderstyle property to 0-None. You cannot close forms with Ctrl + F4 if there's borderstyle is 0. Change it to 1 or 2 and it will close the form on Ctrl + F4.
What are you two nutty kids doing with this easy thing. Why do you not put a command button on the form, set its cancel property to true and hide it behind any other control. Do it on every form. On this command_click event unload me. That way user can just press ESC and unload the form.
Re: Closing the MDI CHILD Form by pressing CTRL+F4 Keys
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.
Originally posted by techyspecy What are you two nutty kids doing with this easy thing. Why do you not put a command button on the form, set its cancel property to true and hide it behind any other control. Do it on every form. On this command_click event unload me. That way user can just press ESC and unload the form.
Originally posted by McGenius Are you always this cocky?
I am not cocky, i'm a fun guy. I do not mind cracking jokes/sarcasm on others and always open for someone cracking joke/sarcasm on me.
Anyway forget about me, was just looking at your previous post, how can you even suggest such a pathetic and lousy solution .. , i'm still wondering about it. *burnt*
And it's "a pathetic and lousy" because ... Do you mind to provide more argumented reply or otherwise don't bother. I belive I've mentioned that to you once before.
Originally posted by McGenius And it's "a pathetic and lousy" because ... Do you mind to provide more argumented reply or otherwise don't bother. I belive I've mentioned that to you once before.
because for the sake of one damn key, you're gonna make him put a timer on the MDI which is gonna fire every 100 milliseconds for no good reason .... ( system resources after all are expensive, specially on users machines )
BTW - you never mentioned that before - I'll note it down somewhere now .. hmm .. * looking for notepad *
Yep, that's what I thought you'd say. Let me guess techy: you must be 15-16, may be 18 yo - at least your brain isn't any older. I have no intension to discuss anything with you any farther what-so-ever.
Also, go find that Notepad and make a note: learn some manners - you'll need'm time to time.
Originally posted by McGenius Yep, that's what I thought you'd say. Let me guess techy: you must be 15-16, may be 18 yo - at least your brain isn't any older. I have no intension to discuss anything with you any farther what-so-ever.
Also, go find that Notepad and make a note: learn some manners - you'll need'm time to time.
Is this Argumentative ????? Looking at this .. you need manners more than i do ..
Make a note for yourself:
Only say what you mean, and always do what you say.