制作非模态窗口模态 [英] Make A Non-Modal Window Modal

查看:76
本文介绍了制作非模态窗口模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个桌面应用程序,当我需要引起用户注意时会弹出一个通知窗口.

问题在于可能有多个通知(在包含要显示的信息的List上运行foreach),而我正在使用的类对此无效.

我正在使用任务栏通知程序 [ ^ ]作为我的弹出窗口,但内部使用ShowWindow显示表单,所以我不能使用ShowDialog来调用它.

如果我可以使用ShowDialog,则List上的foreach将一直等到每个弹出窗口都显示完后再继续下一个.现在,只能看到最后一个弹出窗口...它们全部堆叠在一起.

无论如何,有没有任何外部"方式来模制非模态窗口?

I''m making a desktop app that pops up a notification window when I need to catch the user''s attention.

The problem is there may be multiple notifications (running a foreach on a List containing the info to be presented) and the class I''m using isn''t working for that.

I''m using Taskbar Notifier[^] as my popup, but internally it uses ShowWindow to display the form so I can''t use ShowDialog to call it.

If I could use ShowDialog, the foreach on the List would wait until each popup was done displaying before going on to the next. As it is now, only the last popup is seen...they''re all stacked on top of each other.

Anyway, is there any "external" way of modalizing a non-modal window?

推荐答案

仔细检查了clas的源代码之后,我想出了为什么他使用ShowWindow显示窗口.它带有参数;其中之一确定窗口的显示方式.

在这种情况下,为"NOACTIVATE".

天啊我可以使用CreateParams进行其他操作.

我用ShowDialog替换了内部的ShowWindow,现在一切正常. (然后将Hide()更改为Close(),这样,窗口消失时实际上就会关闭.)
After careful examination of the claas'' source code, I figured out why he used ShowWindow to show the window. It takes parameters; one of which determines how the window is displayed.

In this case, "NOACTIVATE".

D''oh. I can do that another way using CreateParams.

I replaced the internal ShowWindow with ShowDialog, and all is right with the world now. (And changed the Hide() to Close() so the window actually closes when it disappears.)


据我所知,我不认为模块化可以为您提供帮助情况.模块化是ShowDialog.而仅看到最后一个弹出窗口"和彼此叠放"是模态行为的内在属性,没有这些模态行为应被视为滥用(或不被认为是模态行为,无论您喜欢哪种,但不是模态真的很难看).顺便说一句,堆叠在彼此之上"是典型的,但最好避免. Microsoft在旧版实用程序中做了很多事情,但是淘汰了.而且,如果您能注意到的话,那就不用模范范式了.

因此,我想到了无模态UI设计,这是很有可能的.有没有想过?将Visual Studio中的C ++项目与C#项目进行比较.与C#相比,由于C ++项目更多的是传统项目,因此它们具有更多的模态窗口-几乎没有模态窗口(我不算标准文件对话框-它们是可以容忍的).

—SA
It does not look to me that modalizing could help you, as far as I understand your situation. Modularizing is ShowDialog. And "only the last popup is seen" and "stacked on top of each other" are intrinsic attributes of modal behavior, without those the modal behavior should be considered abused (or not considered modal, whatever you prefer, but that kind of non-modal would be really ugly). By the way, "stacked on top of each other" is typical, but best avoided. Microsoft does a lot of it in legacy utilities, but goes out of it. And out of modal paradigm, if you could notice that.

So, I would think of modal-free UI design, which is quite possible. Ever thought about it? Compare C++ project in Visual Studio with C# projects. As C++ projects are more of the legacy, they have way more modal windows compared to C# — almost nothing is modal (I don''t count standard file dialogs — they are tolerable).

—SA


这篇关于制作非模态窗口模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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