代码实现了用户是否从程序外部关闭了特定窗口 [英] code realize if the user closed a specific window from out side the program

查看:60
本文介绍了代码实现了用户是否从程序外部关闭了特定窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我写了一个代码,里面有一个按钮,可以通过openfiledialog打开powerpoint文件.
如果用户通过该按钮打开了一个文件,然后关闭了该文件,则我需要在用户关闭该文件时就意识到的代码.

hi all

i wrote a code that have a button to open power point file by openfiledialog.
if the user opened a file by that button, and then closed this file,i need the code that realize whenever the user closed that file.

推荐答案

如果创建了使用互操作的演示文稿,您可以使用 EApplication_Event.PresentationClose [ ^ ]事件以在演示文稿关闭之前获得通知.
If you create the presentation using interop, you can use EApplication_Event.PresentationClose[^] event to get a notification before the presentation is closed.


启动流程时,请处理Process.Exited事件-只要启用Process.EnableRaisingEvents在外部应用结束时获取事件:
When you start the process, handle the Process.Exited event - as long as you enable the Process.EnableRaisingEvents you will get an event when the external app ends:
    Process p = new Process();
    ProcessStartInfo psi = new ProcessStartInfo(@"D:\Temp\myLargeTextFile.txt");
    p.EnableRaisingEvents = true;
    p.StartInfo = psi;
    p.Exited += new EventHandler(process_Exited);
    p.Start();
    ...

void process_Exited(object sender, EventArgs e)
    {
    MessageBox.Show("It closed");
    }


这篇关于代码实现了用户是否从程序外部关闭了特定窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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