确定 Windows 窗体是否被遮挡

发布于 2024-09-06 22:44:40 字数 1112 浏览 9 评论 0原文

是否可以在.Net(或通过pinvoke)中确定窗口窗体是否被遮挡(即其他窗口已移至其上方,因此无法看到)?我正在做的是检查表单是否最小化,然后在任务栏上闪烁窗口(如果是)。然而问题是,如果它没有最小化,而是只是移动到后台,我还想通过在任务栏上闪烁窗口来通知用户。我不想将窗口自动移动到前台(即使没有激活)。我希望他们单击​​它以最大化和/或显示表单。有想法吗?

这是一些代码:

                    // See if we already have a conversation going with this person
                    var frm = theApp.GetConversationByUID(fromuid);
                    if (frm == null)
                    {
                        frm = theApp.NewConversation(fromuid, fromname);
                    }
                    else
                    {
                        bool withinView = frm.WindowState != FormWindowState.Minimized;
                        if (withinView)
                        {
                            // Determine if window is just obstructed
                            //TODO
                        }

                        // If the conversation window is not within view, then flash it
                        if (!withinView)
                        {
                            FlashWindow.Flash(frm);
                        }
                    }

Is it possible in .Net (or thru pinvoke) to determine if a windows form is obstructed from view (i.e. other windows have been moved over top of it, so it cannot be seen)? What I am doing is checking if the form is minimized, then flashing the window on the taskbar if it is. However the problem is if it is NOT minimized, but just moved to the background, I also want to notify the user by flashing the window on the taskbar. I do not want to move the window to the foreground automatically (even without activation). I want them to click on it to maximize and/or show the form. Ideas?

Here's some code:

                    // See if we already have a conversation going with this person
                    var frm = theApp.GetConversationByUID(fromuid);
                    if (frm == null)
                    {
                        frm = theApp.NewConversation(fromuid, fromname);
                    }
                    else
                    {
                        bool withinView = frm.WindowState != FormWindowState.Minimized;
                        if (withinView)
                        {
                            // Determine if window is just obstructed
                            //TODO
                        }

                        // If the conversation window is not within view, then flash it
                        if (!withinView)
                        {
                            FlashWindow.Flash(frm);
                        }
                    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文