Jump to content
  • Advertisement
Sign in to follow this  
MasterInsanO

Unity [.net] Message Loops in C++ .NET

This topic is 3909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a project which requires me to interface my DirectX-powered engine with a premade Windows Forms GUI. This, however, isn't the hard part. The hard part for me has been figuring out how to take control of the message pump away from Application::Run. Unfortunately, I'm completely new to the whole "managed" C++ thing. As a result, all of the solutions I've come across, including the popular one from Tom Miller (seen here), don't really make any sense to me. I'm pretty sure that the aforementioned popular example isn't in C++, but rather C#, which would explain some of the difficulties I'm having in porting it. A post from this very forum (by Shinkage) indicates that the idea isn't too far off from a Win32 approach. However, I don't understand how to implement this example for two reasons: 1) I still don't know how to gain control of the WndProc, and 2) I was under the impression that in order for my forms to run, I need to call Application::Run at some time or another. Basically, what I'm asking for is someone to help fill in the missing gaps in my knowledge. If you need any information about my program, just ask. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
You don't have to use Application.Run. You can also call Application.DoEvents each loop or use the PeekMessage method. So long as SOMETHING is catching the messages, that's all that matters.

Share this post


Link to post
Share on other sites
You can override Control.WndProc (remember that Form inherits from Control).

As for Windows GUI apps, the only requirement is that somewhere a message loop runs. Deep in the bowels of Application::Run there is a message loop. If you implement the message loop yourself you can eliminate Application::Run (assuming it doesn't do other important work necessary for winforms).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!