Thread: Help to create small desktop application

  1. #1
    Registered User
    Join Date
    Oct 2019
    Posts
    2

    Help to create small desktop application

    I have mingw GCC to write C++ code and I want to create small desktop application for windows.

    i am trying to basically just make a button in my little console application which can be pressed. There will be three buttons,

    so if I press first button, hello 1 should be display screen
    if I press seconds button, hello 2 should be display on screen
    if I press third button, hello 3 should be display on screen

    I'm having trouble figuring out how to get it to work mingw

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,728
    Search for beginner's WinAPI tutorials, they'll teach you the basics.
    Devoted my life to programming...

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,157
    Another possibility is that you have already written the program but couldn't get it to compile on the MinGW port of g++. Is this the case, and if so, what did you try and what errors did you encounter?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Oct 2019
    Posts
    2
    Quote Originally Posted by laserlight View Post
    Another possibility is that you have already written the program but couldn't get it to compile on the MinGW port of g++. Is this the case, and if so, what did you try and what errors did you encounter?
    Actually I can run the program on my computer but I don't have idea how to create button ?

  5. #5
    Registered User
    Join Date
    Feb 2019
    Posts
    533
    Quote Originally Posted by microcontroller View Post
    Actually I can run the program on my computer but I don't have idea how to create button ?
    A button is a child Window, created with CreateWindowEx() with hWndParent argument set to the handle of your main window. You'll need to process the WM_CREATE, to create them and WM_COMMAND to do some action when they are clicked.

  6. #6
    Registered User
    Join Date
    May 2019
    Posts
    209
    @microcontroller,

    You are at a position I think should provoke some thought on how to proceed.

    In C, you'd do as @flp1969 suggests, which is to use the C API of Windows. It's painful, but it is the way to do that in C.

    In C++, however, you have a huge range of options. You can still write to the C API of Windows, and it will still be painful. The only correct response a C++ programmer should have to the C API of any GUI is to encapsulate, but that's still painful.

    That work has been done, many times, producing a number of GUI libraries which reduces the pain considerably. Many will support writing a GUI application portable between platforms (from Windows to MAC, Linux, etc).

    Qt is popular, while wxWidgets is similarly robust. FLTK is used in teaching, and is very light weight. Typical searches produce copious links to downloads for each library, as well as tutorials and discussion on how to build with them.

    There are some Windows specific libraries, too - MFC, ATL...but there is little advantage to building for Windows only when similar effort can build for most of them at once.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desktop application in c++
    By abhi143 in forum C++ Programming
    Replies: 1
    Last Post: 04-27-2019, 11:45 AM
  2. C Program to desktop application??
    By jacka1993 in forum Windows Programming
    Replies: 1
    Last Post: 11-08-2012, 07:52 AM
  3. Replies: 8
    Last Post: 02-19-2011, 09:04 PM
  4. A small problem spoiling my application!
    By chottachatri in forum C# Programming
    Replies: 2
    Last Post: 07-24-2009, 10:34 PM
  5. A small application of cash-register
    By daisy_polly in forum C Programming
    Replies: 8
    Last Post: 02-02-2006, 07:22 AM

Tags for this Thread