locked
Looking for good C++/CLI WinForms example code RRS feed

  • Question

  • Hi

    My interest is to develop a C++/CLI WinForms application.

    I am working through Stephen Fraser's Apress book on C++/CLI for .NET 3.5. It has looks of good example code but I want a serious WinForms code example to see how an entire application should be constructed. For example, what should be the correct response to clicking an OK button in a Window (to exit it), or how should one structure code without putting it all in Form1.h?

    Can anyone please point me to a substantial, well structured, WinForms example coded in C++/CLI?

    Thanks

    David
    David
    • Changed type DavidTM Monday, January 11, 2010 9:22 AM
    Thursday, January 7, 2010 9:11 PM

Answers

  • You are going to find many more examples of WinForms in C#, and you should be able to easily translate them to C++/CLI.

    In fact, Microsoft is no longer promoting C++/CLI as a means of writing GUI applications, just for wrapping of native code.

    In a large application you may want to follow the usual practice of splitting the code into .h and .cpp files. In fact, this is sometimes necessary in order to avoid circular #include statements. Unfortunately, the WinForms wizard does not do this for you (as the MFC one does). This is just one of the reasons you are better off using C# for WinForms. C# has a different compilation model that does not require #include statements.

    If this is a question, please change the thread type to Ask a Question .

    David Wilkinson | Visual C++ MVP
    • Edited by davewilk Friday, January 8, 2010 2:41 PM (note added)
    • Marked as answer by DavidTM Monday, January 11, 2010 9:25 AM
    Friday, January 8, 2010 1:42 PM

All replies

  • You are going to find many more examples of WinForms in C#, and you should be able to easily translate them to C++/CLI.

    In fact, Microsoft is no longer promoting C++/CLI as a means of writing GUI applications, just for wrapping of native code.

    In a large application you may want to follow the usual practice of splitting the code into .h and .cpp files. In fact, this is sometimes necessary in order to avoid circular #include statements. Unfortunately, the WinForms wizard does not do this for you (as the MFC one does). This is just one of the reasons you are better off using C# for WinForms. C# has a different compilation model that does not require #include statements.

    If this is a question, please change the thread type to Ask a Question .

    David Wilkinson | Visual C++ MVP
    • Edited by davewilk Friday, January 8, 2010 2:41 PM (note added)
    • Marked as answer by DavidTM Monday, January 11, 2010 9:25 AM
    Friday, January 8, 2010 1:42 PM
  • Hi David

    Thanks for your reply. Soon after starting off on the C++/CLI learning curve I learned that it has been deprecated for new / GUI applications. I have now decided to switch to learning C#, which actually seems to have a simpler syntax for .NET.

    Best regards
    David
    Monday, January 11, 2010 9:25 AM