Visual Studio 2017 - can't find Visual C++ Windows Forms
Asked Answered
G

2

11

So, I'm in awkward situation - I wanted to create Windows Form App using Visual Studio, but I can't find any place to create Visual C++ Windows Form template. I tried even to reinstall Visual C++, add other libraries and search answer online - no results.

I can of course create new Winforms in C#:

enter image description here

But not in C++:

enter image description here

Also, all possible modules in Visual Studio Update was checked:

enter image description here

I tried even add template from Online list:

enter image description here

What should I do next? I use Visual Studio 2017 Community Edition.

Gluey answered 26/6, 2017 at 21:50 Comment(9)
You need to use C++/CLI not Standard C++.Borden
And you really want to use C#, not C++/CLI. What is your motivation for using C++?Lombardy
@Captain Obvlious In MS VS C++/CLI is usually an option of the standard C++ with CLR.Educative
I'm just more familiar with C++, but I admit, it's probably easier to use C#. Ok, I found a way to make new empty project in CLR and by hand add new Form, but here I have an additional problem, how to open Designer View of my window.Gluey
@Gluey Nowdays MS has a very low reputation. In fact they usually suggest defective products.Educative
@VladfromMoscow I thought defective products are part of MS tradition ;)Gluey
Come now @Vlad ! Ever since MS axed most of their QA department, the known bug count is way, way down!Paget
@Ch3Sshire, same thing happened to me, the Designer View would not show up. How I got it to come up, is I closed my project and opened it. Crazy. I followed same procedure as this solution, but had to close/start the project so that VS could likely create all needed supporting files.Belter
Jesus, after this post I decided it would be better to learn C#. Now I am fully C# developer. Recently I had to test something in C++ WinApi... horror. The horror.Gluey
G
15

Ok, I found a working way to creating Windows Forms in Visual Studio 2017.

  1. Create new CLR Empty Project:

enter image description here

  1. Add .cpp file for main function.

  2. In project add new item from UI->Windows Forms:

enter image description here

(If we didn't add main loop before the error will occur)

  1. Now we can add new elements to form from the Toolbox to the left (i spent measurable time looking for that).

enter image description here

  1. To run application we have to declare this instead of main function:

enter image description here

Also we need to tell Visual Studio that we are making Windows Application instead of Console Application:

enter image description here

Gluey answered 27/6, 2017 at 9:21 Comment(8)
Okay done. It automatically opened deisgner view and it came up with some errors because I didn't write anything in main.cpp. I closed the designer view, setup the main function and included Form1.h. Now I cannot figure out how to open designer view :/Canzonet
I don't have the UI option in the menu you have.. You have UI,Code,DataResource.... I have Code,Data,ResourceFairlie
@Fairlie to get the UI option go to the VS installer and add the C++/CLI Windows Forms option. (Yes, you'd think they would have added this feature as part of the C++ package...)Belter
@JasonHolt I don't see an option like that i.imgur.com/DVrIGwg.pngFairlie
@Fairlie looks like you are using VS2015 Enterprise, and this Q and screens are for VS2017. That said, if you open Visual Studio Installer, you will see an install for "Desktop Development for C++". That's where you'll get the option(s) for C++/CLI development (and what you see here). I'd think you'd also see it in VS2015, so check out the separate application "Visual Studio Installer", found starting from your Windows Start button. :)Belter
@JasonHolt I don't see "visual studio installer" in my start menu i.imgur.com/WqjXWQP.pngFairlie
@Fairlie you can probably access the "modify" via the "Add Remove Programs" for VS2015 in Windows. But remember, this question was for Visual Studio 2017. Good luck.Belter
Another way to define main function is [STAThreadAttribute] int main(array<System::String ^> ^args). And then in project properties -> Linker -> Advanced set Entry Point to mainRutharuthann
B
3

WinForms designer support for C++/CLI was dropped a long time ago in VS 2012. MS suggests using C# for your WinForms code, and only use C++/CLI if you need to interop with native code.

And if you do end up using C++/CLI for interop, keep that layer as small as possible. It's a second-class citizen in the .NET world and isn't even mentioned in Microsoft's recent post on their language strategy.

Bellflower answered 27/6, 2017 at 0:39 Comment(1)
I love when IDE tells me which language I should use to program. Guess I'll install CodeBlocks or Qt Creator.Gluey

© 2022 - 2024 — McMap. All rights reserved.