Creating a Windows GUI .exe application

12,074

There's a number of different options. First we have the microsoft-supported libraries:

  • MFC - The most heavy-weight library for the windows api.
  • ATL - A somewhat smaller, lightweight library.
  • Windows API - Use the Windows API directly.

Beyond that there's a number of third party GUI toolkits, notably:

  • GTK+
  • WxWidgets

If you want to make it as small as compact as possible and avoid external DLLs, you should use the Windows API directly or possibly ATL. This also gives you additional flexibility, but it's a bit more complicated. Take a look at for example theForger's tutorial. It's a bit old, but the api has remained more or less the same for the last ten years anyway.

Here's some additional pointers for using the API directly:

  • What is usually known as controls is called "windows" and are created using CreateWindowEx(). This function creates different things depending on the specified "window class", such as edit, button and static (described below). You create a regular window by registering a custom class.
  • You can use a function called GetOpenFileName() to invoke an open dialog.
  • The common text box is known as the edit control in the API.
  • Buttons are simply called button controls.
  • Labels are called static controls.
  • If it's enough for your purposes, you can also create a dialog window using CreateDialog(). This is possibly a bit easier, since dialogs can be designed using the resource editor, while you have to create all the controls in a regular window programmatically.
Share:
12,074
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I have a C/C++ algorithm that I want to create a GUI application for. I would prefer a .exe application that I can pass around to people. I would preferably want to create a dll of my c/c++ algorithm and then bundle it into the Windows GUI application which is basically just a wrapper around the main c/c++ application. How can I create this GUI in VC++ all with a couple of buttons, a text box and a file chooser/browser/opener?

    Can someone throw some light on this problem?

    Thanks,

    Abhishek

  • rerun
    rerun over 13 years
    Sure you can you just use the windows forms and .net
  • Emil H
    Emil H over 13 years
    Ah. C++/CLI. I thought you were talking about something else. I omitted that because it isn't standard C++ but a super set that runs in the CLR, and also because I'm only vaguely aware of it. It's of course easier than the other options though, since you have access to windows forms.
  • Admin
    Admin over 13 years
    Hi guys, I did understand the part where I create a Windows Form Application in Visual Studio and layout the UI components on the form. My question is, how do I bundle a dll (of my existing C/C++ algorithm) into this Form application? On the click of a button, I only need to pass to a function in the dll, the file path that I choose from the File Browser. The function then does the rest once it gets the file path. So in short, I want to create a GUI around my code which is working fine from the command prompt console. Thanks, Abhishek