带框架的ApplicationContext [英] ApplicationContext with Framework

查看:69
本文介绍了带框架的ApplicationContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法来拥有自定义ApplicationContext并启用应用程序框架?我正在创建一个基于系统任务栏的应用程序,并且希望这样做而不必具有不可见的形式.我还需要启用Framework,以便可以使用ApplicationEvents.我需要ApplicationEvents,因为我需要它成为一个单实例应用程序并从第二个实例获取命令行参数.我尝试了其他方法来实现命令行传递,但是我似乎找不到一种简单的方法来执行此操作.我已经尝试过使用Google搜索,但是似乎无法按正确的条件进行操作.我将衷心感谢您的帮助! :)

在此先感谢.

Is there a simple way to have a custom ApplicationContext and have application Framework enabled? I am creating a System Tray based application, and would like to do it without having to have an invisible form. I also need to have Framework Enabled so I can use ApplicationEvents. I need ApplicationEvents because I need it to be a Single Instance Application AND get the Command Line Arguments from a second Instance. I have tried other ways of achieving Command line passing, but I can''t seem to find a simple way to do this. I HAVE tried Googling this, but I can''t seem to hit on the right term. I would REALLY appreciate your help! :)

Thanks in advance.

推荐答案

由于Windows是事件驱动的,因此您需要某种形式的表单来处理进入应用程序messageloop的消息.


有一些带有一些有用信息的链接,也许您可​​以使用MessageFilter做到这一点:

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ms632599 [ ^ ]

祝你好运!
Because Windows is event driven you need somekind of form to process the messages that come into the applications messageloop.


There are some links with some usefull info and maybe a you could do it with a MessageFilter:

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx[^]

http://msdn.microsoft.com/en-us/library/ms632599[^]

Good luck!


嗯,高级代码并不完全正确.您只需要由表单自动实现的messageloop.这是因为您随后将使用由这些事件驱动的组件.控制台应用程序不监听事件,而是运行直到过程完成.如果表单应用程序不会实现messageloop来保持其占用状态,则只需完成该过程并结束该应用程序即可.您必须简单地给messageloop一个保持占用的理由,这可以使用messagefilter来完成.但是,如果仔细观察,您会发现它也是表单名称空间的一部分,因此它非常接近隐藏的表单.

然后,您也可以像下面的示例一样自己实现messageloop:

http://www.drunkenhyena.com/cgi-bin/view_net_article.pl? Chapter = 2; article = 15 [ ^ ]

祝你好运!
Well, advanced code isn''t completely right. You simply need the messageloop that is implemented by forms automatically. This is because you would then use components that are driven by these events. A console application doesn''t listen to the events but runs until the process is completed. If a forms application wouldn''t implement the messageloop to keep it occupied it would simply complete the process and end the application. You must simply give that messageloop a reason to keep occupied which can be done using a messagefilter. But if you take a close look you would see it is part of the forms namespace as well, so it''s pretty close to a hidden form.

Then you could also implement the messageloop yourself like in this example:

http://www.drunkenhyena.com/cgi-bin/view_net_article.pl?chapter=2;article=15[^]

Good luck!


这篇关于带框架的ApplicationContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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