VS2019 C++ multi Windows Form application.

I’m posting this to inform others of the problems that I have been facing while converting a Windows 7 C++ multi Form VS2008 project to Windows 10 C++ VS2019.

Problem 1: From what I have gathered, Microsoft dropped support for C++ WinForm application in VS2010 and VS2008 does not run on Windows 10. After some research I clicked on “Extensions”, manage extensions on the top line of VS2019, searched for “C++ Windows Forms”, then downloaded and installed the “C++/CLR Windows Forms for Visual Studio 2019” extension.

My project did not directly compile, but after some small modification I did get the main Form to compile, display, and function properly.

Problem 2: This extension, and I believe VS2019 in general, does not support multiple forms. When you right click the project, Add, New Item; the list under Visual C++ does not include the UI (User Interface) option, so you can’t create a second form for the project.

My project monitors a large list of items, with a smaller list that I am interested in. The main form can display the entire list (scrollable), or just the items I am interested in. The VS2008 version also allows me to pop up a “Watch Menu” where I can Watch a smaller list with various background colors. I can then display the combination of items that I am interested in and/or watching. BUT, VS2019 does not allow a second Form in one project. My initial solution was to create a second project with a second exe file for the Watch Menu and the code that called it in the main project was:

private: System::Void WatchButton_Click(System::Object^ sender, System::EventArgs^ e)
{
ClearWatchList();
system("Watch.exe");
LoadWatchList(0);
if (RebuildPage(0)) RefreshThePage();
}

Since the Watch process can not directly change the data in the main form process: step one was to clear out the watch list in the main form, then execute the second form project and wait for it to exit, then reload the watch list, rebuild the display with the new list, and if there was a change, refresh the main form screen.

Problem 3: The system call create a large command prompt window that hides a large portion of the primary screen. Yes, you can minimize the prompt window, but that takes extra steps. So, I changed the system call from Watch.exe to Watch.bat and created a batch file as:

powershell -window minimized -command ""
Watch.exe

The prompt window now display for only a split second and then automatically disappears before the secondary form pops up.

Any question? Feel free to ask.
Last edited on
Topic archived. No new replies allowed.