是否有Windows窗体应用程序的消息映射? [英] Is there a message map to windows forms application?

查看:83
本文介绍了是否有Windows窗体应用程序的消息映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由Visual Studio c ++自动生成的Windows窗体应用程序代码与对话框或MFC应用程序的窗体形式非常不同。



如何向Windows窗体添加消息处理应用程序?我想启动另一个线程,听取线程完成的消息,然后做一些事情。我不知道如何开始使用以下代码:



The windows forms application code automatically generated by Visual studio c++ looks very different from those for dialog or MFC applications.

How can I add message handling to Windows forms applications? I would like to start another thread, listen for message that the thread is finished, then do something. I'm not sure how to get started from the code like:

Application::Run(gcnew Form1());





没告诉我有关消息处理机制的信息。



< b>我尝试过:



在线搜索示例代码。 Windows窗体上的MSDN文档指向.net框架。不知道我是否需要深入阅读有关我需要做的.NET框架的广泛信息。



which does not tell me about the message handling mechanism.

What I have tried:

searched online for example code. MSDN documentation on windows forms points to .net framework. Don't know whether I need to jump into reading extensive information about.net framework for what I need to do.

推荐答案

.net中的消息处理主要由使用控件注册消息功能。用于此的机制称为委托。与旧的MFC消息映射相比,这是非常优雅的。



要开始这个,只需下载C ++中的一个小GUI程序的例子之一/ CLI或C#,您将很快看到它是如何完成的。
Message handling in .net is done primarily by registering a message function with the control. The mechanism used for that is called "delegates". In comparison with the old MFC message maps this is very elegant.

To get a start on this, just download one of the many examples of a small GUI program in C++/CLI or C# and you will quickly see how it is done.


没有消息说线程已完成。当线程完成工作或者线程负责发信号通知其他关心的代码时,线程会悄然死亡。有很多方法可以做到这一点,但是听消息泵不是其中之一。
There is no message that says "a thread is finished". The thread either dies quietly when its work is done or the thread is responsible for signalling other code that cares. There are quite a number of ways to do this, but listening to the message pump is not one of them.


这篇关于是否有Windows窗体应用程序的消息映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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