如何确定用户是在关闭表单还是来自应用程序? [英] How to find out if a user is closing the Form or if it coming from within the Application ?

查看:101
本文介绍了如何确定用户是在关闭表单还是来自应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB中有一个程序,其中有一个


Form_QueryUnload(取消为整数,UnloadMode为整数)


当表格被关闭时会被调用。 UnloadMode用于查明Fomr是否被用户关闭 - 在这种情况下该事件将被取消 - 如果它来自应用程序内,那么它将关闭应用程序。

在.NET中,等效函数是


Form_Closing(ByVal eventSender As System.Object,ByVal eventArgs As System.ComponentModel.CancelEventArgs)处理MyBase.Closing


,其中存在上述VB函数中的'Cancel''等效,但不存在''UnloadMode''。我想知道的是,我现在如何确定表格是否被用户关闭,或者是否来自应用程序?


提前谢谢。

There is a program in VB , in which, there is a

Form_QueryUnload( Cancel as Integer, UnloadMode as Integer)

which would be called when the form is being closed. The UnloadMode is used to find out if the Fomr is being closed by the user - in which case this event is to be cancelled - and if it is coming from within the application, then it would close the application.
In .NET, the equivalent Function is

Form_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

in which the ''Cancel'' Equivalent in the above VB function exists, but not the ''UnloadMode''. What i wanted to know is, how do i now find out if the Form s being closed by the user, or if it is coming from with in the application ?

Thanks in advance.

推荐答案

你好Bande,


我总是遇到和你一样的问题。


现在我使用MyBase.Closing。活动

我已经没有问题了,


但是我不知道是不是因为我对VB.net的了解有所改善

这是因为我现在使用2003和Net 1.1,因为在过去,我总是和它一起玩b



Cor
Hi Bande,

I always had the same problems as you.

Now I use the "MyBase.Closing" event
I have no problems anymore with it,

But I don''t know if it is because my knowledge of VB.net is improved or that
it is because I use 2003 and Net 1.1 now, because in past, I was always
strugling with it.

Cor


----- Cor写道:-----


嗨Bande,


我总是遇到和你一样的问题。


现在我使用MyBase.Closing。活动

我已经没有问题了,


但是我不知道是不是因为我对VB.net的了解有所改善

这是因为我现在使用2003和Net 1.1,因为在过去,我总是和它一起玩b



Cor



你能否告诉我你是如何使用MyBase.Closing的?活动?


Bande
----- Cor wrote: -----

Hi Bande,

I always had the same problems as you.

Now I use the "MyBase.Closing" event
I have no problems anymore with it,

But I don''t know if it is because my knowledge of VB.net is improved or that
it is because I use 2003 and Net 1.1 now, because in past, I was always
strugling with it.

Cor

Can you please tell me how you used the "MyBase.Closing" Event ?

Bande


*" =?Utf-8?B?QmFuZGU =?=" <一个******* @ discussions.microsoft.com> scripsit:
* "=?Utf-8?B?QmFuZGU=?=" <an*******@discussions.microsoft.com> scripsit:
Form_Closing(ByVal eventSender As System.Object,ByVal eventArgs As System.ComponentModel.CancelEventArgs)处理MyBase.Closing

其中取消等效于上面的VB函数存在,但不是''UnloadMode''。我想知道的是,我现在如何确定表格是否被用户关闭,或者是否来自应用程序?
Form_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

in which the ''Cancel'' Equivalent in the above VB function exists, but not the ''UnloadMode''. What i wanted to know is, how do i now find out if the Form s being closed by the user, or if it is coming from with in the application ?




在通过代码关闭应用程序之前设置标志。然后你可以查看

这个标志。


-

Herfried K. Wagner

MVP ·VB Classic,VB.NET

< http://www.mvps.org/dotnet>


改善你的报价风格:

< http://learn.to/quote>

< http://www.plig.net/nnq/nquote.html>



Set a flag before closing the application by code. Then you can check
this flag.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>


这篇关于如何确定用户是在关闭表单还是来自应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆