阻止用户关闭应用程序

阻止用户关闭应用程序

本文介绍了阻止用户关闭应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的应用程序执行了一些过程,应用程序无法在中途关闭。因此

我希望能够阻止任何用户关闭应用程序的尝试,例如点击关闭(交叉)或Alt-F4并且应用程序完成后点击

做什么

它正在关闭。换句话说,我需要优雅地关闭应用程序。怎么

我可以实现这个目标吗?


谢谢


问候

Hi

My app does a few processes and the app can not be closes mid way. Therefore
I want to be able to block any attempt of closing app by user such as by
clicking on close (cross) or Alt-F4 and once the app is finished doing what
it is doing to close. In other words I need to close the app gracefully. How
can I achieve this?

Thanks

Regards

推荐答案



如果应用程序有一个主窗口:处理FormClosing事件并设置

e.Cancel = true;


否则处理windows消息并检查

WM_QUERYENDSESSION:

WM_QUIT:

WM_CLOSE:

干杯,

Udo

If the app has a main window: handle the FormClosing event and set
e.Cancel = true;

Otherwise handle the windows messages and check for
WM_QUERYENDSESSION: http://msdn.microsoft.com/en-us/library/aa376890.aspx
WM_QUIT: http://msdn.microsoft.com/en-us/libr...41(VS.85).aspx
WM_CLOSE: http://msdn.microsoft.com/en-us/libr...17(VS.85).aspx
Cheers,
Udo





这篇关于阻止用户关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 11:05