窗口没有最大化/进入托盘后没有被带到前面,为什么?/帮助
我用一些复杂的代码编写了一个闹钟应用程序,我现在不想分解来用作示例。我有一个计时器,每 10 分钟左右检查一次在线状态,并在某些情况下我的应用程序会提醒我。在 form_load 上,我将计时器设置为 10 分钟,当它触发并且条件为真时,我调用一个包含此函数的函数。
{
this.WindowState = FormWindowState.Maximized;
this.TopMost = true;
this.Activate();
}
当我启动应用程序时,我通常会将其最小化并执行任何操作。今天我注意到它不起作用。在我的初始测试中,我在拉出状态并调用 form_load 上的 func 后调用代码,它总是会显示它,但现在我正在做其他事情并且窗口已最小化,我注意到它不起作用。我该如何解决这个问题?
I wrote an alarm app with some complex code i dont feel like breaking up right now to use as an example. I have a timer checking every 10 or so minutes about a state online and on certain conditions my app alerts me. On form_load i set the timer to 10mins and when it triggers and the condition is true i call a function with this in it.
{
this.WindowState = FormWindowState.Maximized;
this.TopMost = true;
this.Activate();
}
When i start the app i typically minimize it and do whatever. Today i notice it isnt working. On my initial test i call the code after pulling the states and calling the func on form_load which always brought it up but now that i am doing other things and the window has been minimized i notice it did not work. How do i fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你隐藏表格了吗?在这种情况下,请尝试使用
this.Show()
。Are you hiding the form? In which case try
this.Show()
instead.此外,form_load(通常)运行一次。你想要 form_activated。无论是否最小化,表单都在内存中(已加载)。
并且,在 form_load 事件中包含对 activate 事件的调用是多余的。
Additionally, form_load runs once (usually). You want form_activated. The form is in memory (loaded) whether or not it's minimized.
And, including a call to the activate event in your form_load event is redundant.