Results 1 to 4 of 4

Thread: Need help with Visual C++

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Need help with Visual C++

    I just installed Visual Studio community edition and am trying to learn the language and write a simple Hello World program.

    But, it looks quite strange.
    I come from a VB6 background, and I intend to write a similar program (a form with some command buttons, textboxes, etc. on it).
    So, I tried to open a new project, chose the C++ language, then selected the Windows Desktop application because it says it is GUI.

    Now, it is quite unfamiliar.
    I go to the Project menu and there are an Add module and Add Class menu items but no Add Form.

    Also, I go to View menu -> Toolbox and in there there is no control (no textbox, no command button, etc.)

    The tutorials that I found show how to create a Console program which is (I think) a commandline program.
    For example this one:
    https://docs.microsoft.com/en-us/cpp...?view=msvc-160

    But I need to write a GUI program just similar to VB6

    Can you please show me a link to a really good tutorial?

    Thanks.

  2. #2
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need help with Visual C++

    Standard C++ doesn't support gui - it only supports console programming. To use gui with standard C++ you need to use a 3rd party library or for Windows use the WIN32 API gui functions. However gui WIN32 API's are quite complicated and not recommended. For a simple example of gui 'Hello World' see https://github.com/microsoft/Windows...d/cpp/main.cpp

    There is also ms mfc for gui development. See https://docs.microsoft.com/en-us/cpp...?view=msvc-160

    There is also MS c++/cli which is c++ with .net. See https://docs.microsoft.com/en-us/cpp...?view=msvc-160

    If you use Stroustrup's C++ book Programming: Principles and Practice using C++, that uses FLTK for gui.

    Apart from WIN32 API gui, you need a good understanding of C++ (especially classes) before you start.

    Once you know C++, then you need to determine which 3rd party library you're going to use. Then you find a tutorial for that library.

    A common 3rd party x-plat gui library is qt. This may be an overkill for what you require.

    For a list of some 3rd party gui libraries, see the gui section of https://en.cppreference.com/w/cpp/links/libs
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Need help with Visual C++

    Quote Originally Posted by 2kaud View Post
    Standard C++ doesn't support gui - it only supports console programming. To use gui with standard C++ you need to use a 3rd party library or for Windows use the WIN32 API gui functions. However gui WIN32 API's are quite complicated and not recommended. For a simple example of gui 'Hello World' see https://github.com/microsoft/Windows...d/cpp/main.cpp

    There is also ms mfc for gui development. See https://docs.microsoft.com/en-us/cpp...?view=msvc-160

    There is also MS c++/cli which is c++ with .net. See https://docs.microsoft.com/en-us/cpp...?view=msvc-160

    If you use Stroustrup's C++ book Programming: Principles and Practice using C++, that uses FLTK for gui.

    Apart from WIN32 API gui, you need a good understanding of C++ (especially classes) before you start.

    Once you know C++, then you need to determine which 3rd party library you're going to use. Then you find a tutorial for that library.

    A common 3rd party x-plat gui library is qt. This may be an overkill for what you require.

    For a list of some 3rd party gui libraries, see the gui section of https://en.cppreference.com/w/cpp/links/libs
    Thanks for your help.
    But, I am completely lost.
    It is not your fault. It is my fault.

    For example the first link that you have provided (https://github.com/microsoft/Windows...d/cpp/main.cpp) contains only code, but doesn't tell me where to put that code.

    My problem is how to open Visual Studio and navigate through it to begin coding. (I also need to learn the syntax as well, but that is second. First is how to open Visual Studio !!!)

    Let me clarify with this example:
    I found this page:
    https://www.bogotobogo.com/cplusplus...tudio_2013.php
    It tries to walk the reader through a simple project, and the first step that it says is this:
    1- Select Visual C++ CLR and CLR Empty Project
    But, I am stuck even there.
    Please see this:
    https://i.imgur.com/44FATXe.jpeg
    and then this:
    https://i.imgur.com/GGQV0FE.jpeg

    Now, let's say I choose "Windows Desktop Application" (the second selection in that list).
    The second thing to do is this:
    2- Project->Add New Item... Then Select UI under Visual C++.
    But, that is not possible either, because that option doesn't exist:
    https://i.imgur.com/Rd0VOCm.jpeg

    I am so badly stuck!
    Please help
    Thanks.

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Need help with Visual C++

    If you want something along the lines of the learning curve of VB6, and with relatively simple GUI implementation, then I would think you would pick C# over C++. And if you wanted a syntax closer to VB6, the you would chose VB.Net over C#.

    I prefer VB.Net, but C# has more respect and the C# language is still evolving, while VB.Net is static. VB.Net can make use of newer .Net libraries, but the language itself is currently fixed. For the cross platform capabilities of the newer .Net universe, C# would be the best bet for GUI development.

    As for C++, if you really want to go that route, then as mentioned earlier, C++ doesn't include GUI development as part of the language, you have to choose how you want to do GUI and include and interface with the proper libraries.

    Choosing to do a C++ project with CLI GUI won't work out of the box. The needed CLI libraries for C++ are not installed automatically, so if you didn't choose to install them when you did your install they aren't there which is why you are probably not seeing the options you need when selecting projects of that type.

    So, you will need install those libraries.
    Perhaps refer to https://docs.microsoft.com/en-us/cpp...?view=msvc-160 which tells you how to install C++/CLI support after you've already installed Visual Studio, to get yourself started.

    Of course, if you really want to use CLR, which is much older than CLI, then you would have to install that. I haven't used either, but I assume that using CLI would be more relevant these days and may be simpler.

    Back when I did GUI development many years ago in C++, I used QT3, which is at least a couple of generations behind the current versions of QT. I never worked with QT4 or QT5.
    Last edited by passel; Oct 31st, 2021 at 11:36 PM.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width