PC Review


Reply
Thread Tools Rate Thread

ALT+F4 in MDI-Applications

 
 
Michael Maes
Guest
Posts: n/a
 
      14th Oct 2003
Hello,

ALT+F4 is the shortcut to close a form.
When I use this shortcut in an MDI enviroment, the application is closed, so
obviously the shortcut applies to the 'Container' and not to the
'Childform'.
What would be the best practice to capture this event and close the active
child instead of the container (thus trying to end the application).

--
Thanks for helping,

Michael Maes

(I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)


 
Reply With Quote
 
 
 
 
EricJ
Guest
Posts: n/a
 
      14th Oct 2003
you could cancel the close event in the mdi parent and close the active
child there
if there are no childs close the main form

eric

"Michael Maes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> ALT+F4 is the shortcut to close a form.
> When I use this shortcut in an MDI enviroment, the application is closed,

so
> obviously the shortcut applies to the 'Container' and not to the
> 'Childform'.
> What would be the best practice to capture this event and close the active
> child instead of the container (thus trying to end the application).
>
> --
> Thanks for helping,
>
> Michael Maes
>
> (I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)
>
>



 
Reply With Quote
 
EricJ
Guest
Posts: n/a
 
      14th Oct 2003
its the closing event not the close event

"EricJ" <(E-Mail Removed)> wrote in message
news:3f8bbc86$0$15660$(E-Mail Removed)...
> you could cancel the close event in the mdi parent and close the active
> child there
> if there are no childs close the main form
>
> eric
>
> "Michael Maes" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > ALT+F4 is the shortcut to close a form.
> > When I use this shortcut in an MDI enviroment, the application is

closed,
> so
> > obviously the shortcut applies to the 'Container' and not to the
> > 'Childform'.
> > What would be the best practice to capture this event and close the

active
> > child instead of the container (thus trying to end the application).
> >
> > --
> > Thanks for helping,
> >
> > Michael Maes
> >
> > (I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)
> >
> >

>
>



 
Reply With Quote
 
Michael Maes
Guest
Posts: n/a
 
      14th Oct 2003
Hi Eric,

You could 'e.cancel' the 'closing-event' of the MDI-Form, but then you face
some problems:
What if you want to close the MDI-Form (close-button, menu, esc, or even
ALT+F4). (normally the user closes an application by closing the MDI, not
explicitly closing all the children first)
When you press ALT+F4 when a child has the focus, the event should happen in
the Childform, still the container closes. Does this mean the event is
captured by the containrform and does it know where the request came from
(sender). If that is the case you could cancel the event and close the
"requesting" child.

Michael

"EricJ" <(E-Mail Removed)> wrote in message
news:3f8bbc86$0$15660$(E-Mail Removed)...
| you could cancel the close event in the mdi parent and close the active
| child there
| if there are no childs close the main form
|
| eric
|
| "Michael Maes" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > Hello,
| >
| > ALT+F4 is the shortcut to close a form.
| > When I use this shortcut in an MDI enviroment, the application is
closed,
| so
| > obviously the shortcut applies to the 'Container' and not to the
| > 'Childform'.
| > What would be the best practice to capture this event and close the
active
| > child instead of the container (thus trying to end the application).
| >
| > --
| > Thanks for helping,
| >
| > Michael Maes
| >
| > (I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)
| >
| >
|
|


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      14th Oct 2003
"Michael Maes" <(E-Mail Removed)> schrieb
> Hello,
>
> ALT+F4 is the shortcut to close a form.
> When I use this shortcut in an MDI enviroment, the application is
> closed, so obviously the shortcut applies to the 'Container' and not
> to the 'Childform'.
> What would be the best practice to capture this event and close the
> active child instead of the container (thus trying to end the
> application).


To close the active child, use Ctrl+F4. That's the standard. Anything else,
IMHO, would only confuse the user.


--
Armin

 
Reply With Quote
 
Michael Maes
Guest
Posts: n/a
 
      14th Oct 2003
"Know your Shortcuts...."
Thank you Armin,

Michael


"Armin Zingler" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
| "Michael Maes" <(E-Mail Removed)> schrieb
| > Hello,
| >
| > ALT+F4 is the shortcut to close a form.
| > When I use this shortcut in an MDI enviroment, the application is
| > closed, so obviously the shortcut applies to the 'Container' and not
| > to the 'Childform'.
| > What would be the best practice to capture this event and close the
| > active child instead of the container (thus trying to end the
| > application).
|
| To close the active child, use Ctrl+F4. That's the standard. Anything
else,
| IMHO, would only confuse the user.
|
|
| --
| Armin
|


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      14th Oct 2003
* "Michael Maes" <(E-Mail Removed)> scripsit:
> ALT+F4 is the shortcut to close a form.
> When I use this shortcut in an MDI enviroment, the application is closed, so
> obviously the shortcut applies to the 'Container' and not to the
> 'Childform'.
> What would be the best practice to capture this event and close the active
> child instead of the container (thus trying to end the application).


This behavior is by design and I would not change it. You can use
Ctrl+F4 to close an MDI child.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
EricJ
Guest
Posts: n/a
 
      14th Oct 2003
the ctrl f4 that armin and herfried suggested is of cource better. but if
you really want to use alt F4 i suppose you could build a controle structure
around it to check on wat form the user issued the close command.

"Michael Maes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Eric,
>
> You could 'e.cancel' the 'closing-event' of the MDI-Form, but then you

face
> some problems:
> What if you want to close the MDI-Form (close-button, menu, esc, or even
> ALT+F4). (normally the user closes an application by closing the MDI, not
> explicitly closing all the children first)
> When you press ALT+F4 when a child has the focus, the event should happen

in
> the Childform, still the container closes. Does this mean the event is
> captured by the containrform and does it know where the request came from
> (sender). If that is the case you could cancel the event and close the
> "requesting" child.
>
> Michael
>
> "EricJ" <(E-Mail Removed)> wrote in message
> news:3f8bbc86$0$15660$(E-Mail Removed)...
> | you could cancel the close event in the mdi parent and close the active
> | child there
> | if there are no childs close the main form
> |
> | eric
> |
> | "Michael Maes" <(E-Mail Removed)> wrote in message
> | news:(E-Mail Removed)...
> | > Hello,
> | >
> | > ALT+F4 is the shortcut to close a form.
> | > When I use this shortcut in an MDI enviroment, the application is
> closed,
> | so
> | > obviously the shortcut applies to the 'Container' and not to the
> | > 'Childform'.
> | > What would be the best practice to capture this event and close the
> active
> | > child instead of the container (thus trying to end the application).
> | >
> | > --
> | > Thanks for helping,
> | >
> | > Michael Maes
> | >
> | > (I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)
> | >
> | >
> |
> |
>
>



 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      15th Oct 2003

Hi Michael,

Just as the community said, the standard keyboard shortcut is suitable for
the users. (Ctrl+F4 for child form, Alt+F4 for parent form)
If you still want to use Alt+F4 to close all the child forms before closing
the parent form, you can hook the WM_SYSKEYDOWN message.
It seems that in MDI form, when you press Alt+F4, the WM_SYSKEYDOWN message
is sent to the current Active child form, but not the parent form.
So you should subclass all the child form's wndproc and handle its
WM_SYSKEYDOWN message.
In WM_SYSKEYDOWN message, you should close this child form then jump out of
this procedure.
Something like this:

public const int WM_SYSKEYDOWN = 0x104;
public const int VK_F4 = 0x73;

protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSKEYDOWN)
{
if(m.WParam.ToInt32()==VK_F4)
{
MessageBox.Show("Alt+f4");
this.Close();
return;
}
}
base.WndProc (ref m);
}

It works well on my machine, If you have any unclear, please feel free to
let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Reply-To: "Michael Maes" <(E-Mail Removed)>
| From: "Michael Maes" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<3f8bbc86$0$15660$(E-Mail Removed)>
| Subject: Re: ALT+F4 in MDI-Applications
| Date: Tue, 14 Oct 2003 11:26:42 +0200
| Lines: 49
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 204.54-136-217.adsl.skynet.be 217.136.54.204
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:146487
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Hi Eric,
|
| You could 'e.cancel' the 'closing-event' of the MDI-Form, but then you
face
| some problems:
| What if you want to close the MDI-Form (close-button, menu, esc, or even
| ALT+F4). (normally the user closes an application by closing the MDI, not
| explicitly closing all the children first)
| When you press ALT+F4 when a child has the focus, the event should happen
in
| the Childform, still the container closes. Does this mean the event is
| captured by the containrform and does it know where the request came from
| (sender). If that is the case you could cancel the event and close the
| "requesting" child.
|
| Michael
|
| "EricJ" <(E-Mail Removed)> wrote in message
| news:3f8bbc86$0$15660$(E-Mail Removed)...
| | you could cancel the close event in the mdi parent and close the active
| | child there
| | if there are no childs close the main form
| |
| | eric
| |
| | "Michael Maes" <(E-Mail Removed)> wrote in message
| | news:(E-Mail Removed)...
| | > Hello,
| | >
| | > ALT+F4 is the shortcut to close a form.
| | > When I use this shortcut in an MDI enviroment, the application is
| closed,
| | so
| | > obviously the shortcut applies to the 'Container' and not to the
| | > 'Childform'.
| | > What would be the best practice to capture this event and close the
| active
| | > child instead of the container (thus trying to end the application).
| | >
| | > --
| | > Thanks for helping,
| | >
| | > Michael Maes
| | >
| | > (I'm using vb.NET 2003 Enterprise Architect & SQL Server 2003 SP3)
| | >
| | >
| |
| |
|
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to port windows applications to compact framework applications? miloszl@gmx.de Microsoft Dot NET Compact Framework 4 15th Jun 2005 12:18 PM
speed of VB applications versus Access VBA applications =?Utf-8?B?ZWxlb25n?= Microsoft Access Getting Started 3 19th Dec 2004 12:35 AM
Windows applications versus web applications =?Utf-8?B?QnJhZCBTaW1vbg==?= Microsoft Dot NET 3 12th Jul 2004 07:29 PM
AD migration effect on applications/applications servers dan Microsoft Windows 2000 Active Directory 1 3rd Feb 2004 03:38 PM
web applications versus. web portal applications John Davis Microsoft ASP .NET 0 21st Aug 2003 01:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.