Most common quiestion is:

Is there any C++ GUI API?

My answer is MANY.

There are many API's for making GUI applications.
Here are some.

1. WinAPI: (C based)(MFC is C++ based)
Its a great API and the best solution if you are windows programmer. First code will look a bit difficult, but later (after making few apps.) you will see its not so rusty. I like it, because you can do almost everything with it (in windows). The only bad thing is, that you cannot make applications for Linux with it.
2. Qt4 / Qt3 (C++ based)
This is a nice API, for making GUI applications. It works under Linux, Windows and Mac OS X. Its really easy to learn and use. But, until you dont buy licenced version, you will need to add tons of -dll s, to run your application. Qt compiler doesnt work in Vista. And, Qt4 API has a bit complicated way, to get buttons to work, if button holds some more complicated operations(actually you have to make your own SLOT's).
3.GTK+ (C based)
Sorry, but I never tryed it, so Google might help you.

Some examples:

Simple message box:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
    LPSTR lpCmdLine, int nCmdShow)
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;

Simple window:

#include <windows.h>

const char g_szClassName[] = "myWindowClass";

// Step 4: the Window Procedure
        case WM_CLOSE:
        case WM_DESTROY:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    return 0;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    HWND hwnd;
    MSG Msg;

    //Step 1: Registering the Window Class
    wc.cbSize        = sizeof(WNDCLASSEX);         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

        MessageBox(NULL, "Window Registration Failed!", "Error!",
        return 0;

    // Step 2: Creating the Window
    hwnd = CreateWindowEx(
        "The title of my window",
        NULL, NULL, hInstance, NULL);

    if(hwnd == NULL)
        MessageBox(NULL, "Window Creation Failed!", "Error!",
        return 0;

    ShowWindow(hwnd, nCmdShow);

    // Step 3: The Message Loop
    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    return Msg.wParam;

Simple Message Box:

#include <QApplication>
 #include <QPushButton>

 int main(int argc, char *argv[])
     QApplication app(argc, argv);

     QPushButto *hello = new QPushButton("This is a simple button");
     hello.resize(100, 30);;
     return app.exec();

Note: Use MsgBox for making message boxes

Simple Window:

#include <QApplication>
 #include <QLabel>

 int main(int argc, char *argv[])
     QApplication app(argc, argv);

     QLabel *hello = new QLabel("This is a simple window");
     hello.resize(100, 30);;
     return app.exec();


Simple window:

#include <gtk/gtk.h>

/* This is a callback function. The data arguments are ignored
 * in this example. More on callbacks below. */
static void hello( GtkWidget *widget,
                   gpointer   data )
    g_print ("Hello World\n");

static gboolean delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer   data )
    /* If you return FALSE in the "delete_event" signal handler,
     * GTK will emit the "destroy" signal. Returning TRUE means
     * you don't want the window to be destroyed.
     * This is useful for popping up 'are you sure you want to quit?'
     * type dialogs. */

    g_print ("delete event occurred\n");

    /* Change TRUE to FALSE and the main window will be destroyed with
     * a "delete_event". */

    return TRUE;

/* Another callback */
static void destroy( GtkWidget *widget,
                     gpointer   data )
    gtk_main_quit ();

int main( int   argc,
          char *argv[] )
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;
    GtkWidget *button;
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init (&argc, &argv);
    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    /* When the window is given the "delete_event" signal (this is given
     * by the window manager, usually by the "close" option, or on the
     * titlebar), we ask it to call the delete_event () function
     * as defined above. The data passed to the callback
     * function is NULL and is ignored in the callback function. */
    g_signal_connect (G_OBJECT (window), "delete_event",
              G_CALLBACK (delete_event), NULL);
    /* Here we connect the "destroy" event to a signal handler.  
     * This event occurs when we call gtk_widget_destroy() on the window,
     * or if we return FALSE in the "delete_event" callback. */
    g_signal_connect (G_OBJECT (window), "destroy",
              G_CALLBACK (destroy), NULL);
    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    /* Creates a new button with the label "Hello World". */
    button = gtk_button_new_with_label ("Hello World");
    /* When the button receives the "clicked" signal, it will call the
     * function hello() passing it NULL as its argument.  The hello()
     * function is defined above. */
    g_signal_connect (G_OBJECT (button), "clicked",
              G_CALLBACK (hello), NULL);
    /* This will cause the window to be destroyed by calling
     * gtk_widget_destroy(window) when "clicked".  Again, the destroy
     * signal could come from here, or the window manager. */
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
                  G_CALLBACK (gtk_widget_destroy),
                              G_OBJECT (window));
    /* This packs the button into the window (a gtk container). */
    gtk_container_add (GTK_CONTAINER (window), button);
    /* The final step is to display this newly created widget. */
    gtk_widget_show (button);
    /* and the window */
    gtk_widget_show (window);
    /* All GTK applications must have a gtk_main(). Control ends here
     * and waits for an event to occur (like a key press or
     * mouse event). */
    gtk_main ();
    return 0;

I hope this post will help anyone!

I also think newbies dont know for C++ IDE's. (Developing Enviroviment).

I will make a short description of some

1. Visual Studio 2005 (Visual C++)
This is a beautiful IDE for making console and win32 GUI applications. You can also compile DirectX10 or 9 projects as well. I didn't test it for compiling Qt or GTK+ applications yet.
Affcourse as a Microsoft product isn't free, but it seems to be really safe and stable IDE for Windows Applications.
I really like it, and I recommend it to everyone.

More info HERE

2. Code::Blocks
Great for compiling WinAPI, Qt, GTK+, WXWidgets, Ogre, D, C++ console, C console and other projects. I found some bugs, and sometimes there are problems to compile.
It's one of the best FREE IDE's.

Information and download HERE

3. Dev-C++
This IDE, written in Delphi is the right place for beginners. It isn't perfect and it allows you "holes" and "bugs" in your program.Thats why its good for beginners. VS2005 wouldnt compile most of the code, which Dev-C++ does.

Information and Download HERE

-Anjuta IDE

Ah, and dont take care about all off my opinions. I prefer VS2005, but If you dont have a money, than choose Code::Blocks or Dev-C++.

I hope moderators will make this topic sticky (read me)

I hope this helps

BTW: Sorry for my grammatic mistakes.


devcpp is crap...

#include <gtk/gtk.h>

we are getting error saying that the above library is not defined, Is it not a default library present in CPPP

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.