Menu

Using Windows Forms from OWLNext applications

Using Windows Forms from OWLNext applications

Interoparating between different frameworks is usually tricky. At first glance, making use of Windows Forms controls inside an OWLNext application looks not easy to do, because one is managed C# code, and the other one is unmanaged C++ code.

Fortunately, this article describes a way to show a modeless WinForms form from a C++ or MFC application.
In short, there is a separate C++/CLI wrapper DLL, which on one hand can directly access the managed C# WinForms code, and on the other hand, expose a standard "C" DLL interface that can be called from the C++ code.

Based on that article, here is an OWLNext example that can show two different forms inside TWindow-derived objects. Some modifications to the original code include:

  • The example is an OWLNext MDI application.
  • The DLL wrapper can handle multiple forms. There are two example forms provided, one with 3 buttons and label, and the other one containing a Windows Forms DataGridView.
  • The child forms have their border style set to None, so they do not have borders or captions.
  • The TWindow-derived class handles WM_SIZE messages and calls SetBounds so that the forms always occupy the parent window client area and resize with it.
  • Two different callback methods are provided, one that passes an integer from the form, and the other passes a string.




Trouble-shooting

Applications that depend on DLL modules using the .NET framework may run into DLL load order and initialisation issues. See [discussion:d9c10601a1].


Related

Discussion: d9c10601a1
Discussion: OWLNext 7 and Windows 7
Wiki: Frequently_Asked_Questions
Wiki: Knowledge_Base

Discussion

  • Ognyan Chernokozhev

    Example code

     
  • Vidar Hasfjord

    Vidar Hasfjord - 2020-02-17

    Cool! I've added links to this article in the FAQ.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.