Why can't I get a Winform style GUI in VS 2013 C++?

This is my first post, and so I'd like to say HI to everyone. First thing, I have to get off my chest is THANK YOU CPLUSPLUS forum. I got banned from asking questions on StackOverflow for asking "stupid" questions. I come over to this forum, and see, WOW, a question that I wanted to ask on SO, that would be considered a bad question.

Basically I want to make a GUI interface using C++ in Visual Studio 2013. But, when I follow the instructions from a Youtube video, I go Resource File, Windows Forms, Add, it just flashes up the same friggin' window all over again.

So, here's my stupid, retarded, bannable, already asked, no good question that would irritate any expert to his very core:

HOW DO I GET A TRADITIONAL WINDOWS FORM USING C++ ON VISUAL STUDIO 2013? I can't believe that Microsoft deleted that capability. I can do it on C# just fine. Are there libraries I have to add? Why can't there be just one set up to create a desktop application? I can't believe how buried in the muck they make it.

I'd really rather use Visual Studio, not 3rd party right now. Do I have to download something extra? Am I not looking in the right place? Why have MFC or Winforms, and then there's Windows Store? Aren't they all basically the same? Do I have to pay out some money to get that capability? This is really annoying.

Thank you in advance. I was going to post this on this thread, http://www.cplusplus.com/forum/windows/175975/ but I don't really see my answer there.
They stopped support of Windows Forms with C++, to encourage more people to use C# Windows Forms (iirc). There is a way to use Windows Forms with C++, though.
http://www.bogotobogo.com/cplusplus/application_visual_studio_2013.php
closed account (z05DSL3A)
BlowingSmoke wrote:
HOW DO I GET A TRADITIONAL WINDOWS FORM USING C++ ON VISUAL STUDIO 2013? I can't believe that Microsoft deleted that capability. I can do it on C# just fine. Are there libraries I have to add? Why can't there be just one set up to create a desktop application? I can't believe how buried in the muck they make it.
Firstly Windows forms are far from being traditional. Windows forms are a .net framework thing, your 'traditional' UI technology would be via Windows API.

The second thing is that Windows forms used to be done with C++/CLI, this is a different language than C++. Yes you could use C++/CLI for Windows Forms but it was meant to be used for creating wrappers for legacy code to allow it to be used in the managed framework. You can mix C++ and C++/CLI by design however when it came to Windows forms this was often abused by the people trying to learn creating an unholy mess of code, so Microsoft took the decision (quite rightly IMHO) to stop supporting UI coding with C++/CLI.

and wrote:
Why have MFC or Winforms, and then there's Windows Store? Aren't they all basically the same?
Not really, I personally think of them as different platforms. You have Windows API (AKA WinAPI, Win32...), a managed framework (AKA .net framework), and Windows Runtime (aka WinRT).


My advice, Don't bother trying to learn Windows Forms with C++/CLI.

Integral...
When I follow that guy's advice, I go Add >> New >> Visual C++ >> UI >> Windows Form >> Add
But, it just makes the screen disappear and then show up again. There's no error message, basically it doesn't do it.

Grey Wolf...
I can't find Windows API on any of the choices when I start a new C++ template. Let me re-state my request: How do I get User Interfaces using C++ on Visual Studio 2013? I don't want to use C#, because I'm more familiar with C++. There's got to be a way to do it.

Thank you both for your time. And thanks to Cplusplus forum for allowing NOOB questions that have been asked 100 times. Like I said, I practiced due diligence before asking this question. I swear this is crazy. One of the most common languages in the world, and it's such a pain to get a GUI on Visual Studio to do it?
closed account (z05DSL3A)
See if this floats your boat...

Learn to Program for Windows in C++
https://msdn.microsoft.com/library/windows/desktop/ff381399(v=vs.85).aspx
I know I'm likely going against conventional wisdom here, and also likely against some highly skilled coders here, but I think Visual Studio is nowadays not a good place to start. I'm an experienced user of it (at least up to VS 2008 Pro), but its far easier to download Code::Blocks, choose a 'Frame Based' template from the dozen or so provided, and it even provides the start up code to create a window. All you have to do is click the compile button, then run, and you are started. It might take ten minutes to download and install, then another minute to set up a project and run their basic template, but that's all there is to it. Part of your problem is you seem fixated on Visual Studio. Way to complicated for a beginner, in my opinion. Blowing Smoke's experience is proof of that.
closed account (z05DSL3A)
freddie1, I kind of agree with you but I don't think VS is too complicated but there are a lot of options and no clear guidance on the various paths you can take.
Couple weeks ago on my work computer I decided to download the latest and greatest of Microsoft's cutting edge development environments in Express flavor. To make a long story short I couldn't get it to work. And I've been doing this stuff since Fortran on main frames in the 1970s. Might have been my fault. Not sure. I was quite careful about everything though. The box was a laptop running an x86 version of Win7 Pro. Perhaps that was the issue. Maybe requires x64 - not sure, and I didn't really read the release notes and requirements. It installed but towards the end it gave me a MsgBox that it might not work. Didn't say why. Just that it might not work. It didn't either. Anyway, stories like this intrigue me, and I pity the poor folks like BlowingSmoke that want to get started but the software won't relent. So in my next post I'm going to show how to get started writing GUIs without even a Development Environment installed. Yep! Good 'ole Command Line compiling! It still works like a charm and is easy to do. If BlowingSmoke has a working MS compiler, or can install Windows 7 SDK these directions should get him going.
Here’s how easy it is to code a Windows GUI application Blowing Smoke. You don’t even need Visual Studio, Code::Blocks, QT, wxWidgets, .NET, Windows Forms, C++/Cli or or anything else besides a compiler to translate your source code to an executable binary file, i.e., an exe. I have Microsoft’s Windows 7 SDK (free download as far as I know) installed on my wife’s Net Book – an Acer Aspire One with an Atom x64 processor. Its pretty weak, but more than enough to do the job.

When you install the Sdk you should end up with various options on your Start Menu, if you are running some version of Windows with a Start Menu. For me I chose…

 
Microsoft Windows Sdk Version 7.1  >>> Windows SDK 7.1 Command Prompt


Then a command prompt console window opens. There is a help file with the installation of my version that tells you various switches to set various options such as whether you want x86 or x64 executables, whether you want Debug or Release builds done. Lets go for broke and so x64 Release builds. The command looks like so…

 
setenv /x64 /Release


When I executed that I got this on my console screen…

1
2
3
4
5
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1
\.
Targeting Windows 7 x64 Release

C:\Program Files\Microsoft SDKs\Windows\v7.1>


Next I created a directory/folder for a Hello, World! Program. Got to admire Dennis Ritchie. If you don’t know who he is you had better look it up. Here’s the directory I created…

C:\Code\Win7Sdk\Hello

Then I executed a change directory command to move to that directory…

1
2
C:\Program Files\Microsoft SDKs\Windows\v7.1>CD\
C:\>CD C:\Code\Win7Sdk\Hello


At that point here’s what I’m seeing in my console window…

1
2
3
4
5
6
7
8
9
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1
\.
Targeting Windows 7 x64 Release

C:\Program Files\Microsoft SDKs\Windows\v7.1>cd\

C:\>CD C:\Code\Win7Sdk\Hello

C:\Code\Win7Sdk\Hello>


Now open Notepad.exe and type this in there…

1
2
3
4
5
6
7
8
9
#include <cstdio>

int main(void)
{
 printf("Hello, World!\n");
 getchar();

 return 0;
}


Save the file as Main.cpp to C:\Code\Win7Sdk\Hello\Hello.cpp, or to wherever you have created a directory on your computer for it, and have navigated to there with my directions above. I saved my file as described above and executed a dir command which reveals what’s in my folder, and here’s what my console window is showing me…

1
2
3
4
5
6
7
8
9
10
11
12
13
C:\Code\Win7Sdk\Hello>dir
 Volume in drive C is Acer
 Volume Serial Number is 1C3F-BA6D

 Directory of C:\Code\Win7Sdk\Hello

10/26/2015  07:34 PM    <DIR>          .
10/26/2015  07:34 PM    <DIR>          ..
10/26/2015  06:54 PM                97 Hello.cpp
               1 File(s)             97 bytes
               2 Dir(s)  254,879,039,488 bytes free

C:\Code\Win7Sdk\Hello>


So now I’ve a 97 byte file and am ready to test my compiler. So I type this at the command prompt…

cl Hello.cpp [ENTER]

You don’t type the [ENTER]. Just hit the key after typing cl Hello.cpp. Here’s my screen now…

1
2
3
4
5
6
7
8
9
10
11
12
C:\Code\Win7Sdk\Hello>cl Hello.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Hello.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:Hello.exe
Hello.obj

C:\Code\Win7Sdk\Hello>


If I type a dir now I’ll get this…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
C:\Code\Win7Sdk\Hello>dir
 Volume in drive C is Acer
 Volume Serial Number is 1C3F-BA6D

 Directory of C:\Code\Win7Sdk\Hello

10/26/2015  07:38 PM    <DIR>          .
10/26/2015  07:38 PM    <DIR>          ..
10/26/2015  06:54 PM                97 Hello.cpp
10/26/2015  07:38 PM            54,272 Hello.exe
10/26/2015  07:38 PM             1,027 Hello.obj
               3 File(s)         55,396 bytes
               2 Dir(s)  254,878,912,512 bytes free

C:\Code\Win7Sdk\Hello>


As you can see, it made my Hello.exe. It’s a whooping 54272 bytes. Ridiculous. With my VS 2008 VC installation I can cut that down to about 3.5 k in x64, believe it or not, and that’s with /MT static linking. But that’s another story.

Now, you wanted a GUI program. Make another directory named \Forms. Then make a directory under that named Form1. I have this…

C:\Code\Win7Sdk\Forms\Form1

Into \Form1 type this into Notepad and save it as Main.cpp…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Main.cpp
// cl Main.cpp Kernel32.lib User32.lib Gdi32.lib /O1 /Os /MT /GA /FeForm1.exe
#include <windows.h>

LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
   case WM_DESTROY:
    {
       PostQuitMessage(0);
       return 0;
    }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 char szClassName[]="Form1";
 WNDCLASSEX wc={};
 MSG messages;
 HWND hWnd;

 wc.lpszClassName = szClassName;
 wc.lpfnWndProc   = fnWndProc;
 wc.cbSize        = sizeof(WNDCLASSEX);
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
 wc.hInstance     = hInstance;
 RegisterClassEx(&wc);
 hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,200,175,320,200,HWND_DESKTOP,0,hInstance,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}


Then do a CD\ followed by another change directory to bring you to wherever you need to be. For me its…

CD C:\Code\Win7Sdk\Forms\Form1

Then type this at the command prompt…

 
cl Main.cpp Kernel32.lib User32.lib Gdi32.lib /O1 /Os /MT /GA /FeForm1.exe


Then hit [ENTER]. I then got this…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
C:\Code\Win7Sdk\Forms\Form1>cl Main.cpp Kernel32.lib User32.lib Gdi32.lib /O1 /O
s /MT /GA /FeForm1.exe
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Main.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:Form1.exe
Main.obj
Kernel32.lib
User32.lib
Gdi32.lib

C:\Code\Win7Sdk\Forms\Form1>


Then execute Form1.exe and you’ll see your first GUI program! Its that easy! I can actually cut that down to about 5k, but it takes some work!

Last edited on
Freddie1, thank you for your thought-out response that obviously took some time to prepare. Unfortunately it wasn't quite what I was looking for. It obviously works, but it's so much nitty-gritty when there has been developed software to make it easy, it's just that Microsoft is being manipulative with people's options. They have the sugar and don't want us to have it.

Anyway, for now I'm using QT.

Thank you.

If anyone has the methodology to get VS 2013 to do Winforms on C++, I'd be eternally grateful.
Topic archived. No new replies allowed.