简体   繁体   English

窗体激活停止在同一编译exe中的工作

[英]Form activation stops work in same compilation exe

I've winfoms window this.Activate(); 我在winfoms窗口中this.Activate(); in Form1_MouseHover event: Form1_MouseHover事件中:

private void Form1_MouseHover(object sender, EventArgs e) 
{ 
       this.Activate();
}

I've build project exe from studio, form activation works with MouseHover . 我已经从Studio构建了项目exe ,可以通过MouseHover激活MouseHover

Then I closed VS, and open exe from bin folder, activation works same way. 然后我关闭VS,并从bin文件夹中打开exe ,激活的方式相同。

I did not make any changes and did not recompiled exe, I've opened exe second time, activation works, but somehow slower, I've closed it and open once again, activation just does not works. 我没有做任何更改,也没有重新编译exe,我已经第二次打开exe,激活有效,但是以某种方式较慢,我将其关闭并再次打开,激活不起作用。

First I was think, that's my Visual Studio-15 does not compiles updated code, but seems like it something different, because change in functionality happens with same, not recompiled exe , and also I've added additional code, first of all to check if update exist in compilation, and also to fire particular event. 首先,我想这是我的Visual Studio-15无法编译更新的代码,但看起来有些不同,因为功能更改是通过相同的代码而不是重新编译的exe ,而且我还添加了其他代码,首先要检查如果更新存在于编译中,并且还会触发特定事件。 Program was updated, and event exist. 程序被更新,并且事件存在。 With first or several opening of form, activation stops to work, but always works after build from VS 第一次或多次打开表单时,激活停止工作,但始终在从VS构建后起作用

The documentation for Form.Activate says this: Form.Activate的文档说:

Activating a form brings it to the front if this is the active application, or it flashes the window caption if this is not the active application. 如果这是活动的应用程序,则激活它会使其位于最前面;如果这不是活动的应用程序,则它会闪烁显示窗口标题。

I would assume that as you're in VS when you first run it the application is considered the active application but when you run it from explorer it's not the active window. 我假设您在VS中时,首次运行该应用程序时将其视为活动应用程序,但从资源管理器中运行该应用程序时,它不是活动窗口。

I did a quick test, ran it in VS and it worked as you said, switched focus. 我做了一个快速测试,在VS中运行了它,并且按您所说的那样工作,切换了焦点。 When I ran it from Explorer it just flashed the taskbar. 当我从资源管理器中运行它时,它只是刷新了任务栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM