Is the common language runtime the only way to develop
graphical user interfaces in c++? That had been what I thought
until I read a gaming thread( how to develop board games in c++ ).

A dll, which i have to use, refuses to work with the clr (i am using VC++ 2005 express). I have been building console apps with c++ to work with the dll and then I invoked them from the Visual Basic GUIs. It worked reasonably well but not perfectly.

After reading that thread however I realised that there
might be alternative ways to develop GUIs? Is it possible to build complete console applications in c++ and then attach screens to them? I am open to any suggestion which can give graphical user interfaces without forcing me to use the CLR of dot net.

There is DirectX and OpenGL libraries, but I know next to nothing about them. I know DirectX makes heavy use of c++ features and the download file contains several example programs

I also wanted to create a simple 3d games, but I changed my mind very fast.

1.For making games with DX or OpenGL you MUST know WinAPI and C/C++

DirectX 9 and 10 are very difficult to learn, but powerfull.

OpenGL is a bit easyer and recommended for newbies, but you cant create a top game with it.

Conclusion: If you are a newbie to programing, without HIGH mathematics knowlege, without HARD interests and "developing team"(you probably wont create all media, textures, meshes etc. on your own) , THAN FORGET ABOUT DX AND OpenGL.

If you are a n00b, than play around with already created game engine like OGRE (object-oriented game engine)

Im telling you that from my own experiance.

i thank you for your answers but i am even more new to c++ than that. I am reasonably good at programming but i am still learning c++.

So I am actually looking for something easier. Anything which can render textboxes, command buttons and other things on-screen while C++ runs behind it.

My dll can only work with c++ otherwise I would probably have written my programs in Java or something. I am going to learn at least openGL but for now I am still battling to learn c++ itself.

how about allegro or sdl? (allegro is easier I believe but a tad less powerful)

First at all learn WinAPI (Win32). Than you can try with developing 2d games using something like MS DircetDraw or go to 3d game developing ( OpenGL, DX)

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

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.

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).
Tutorial: (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:
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;

BTW: I think that .NET sucks

thanks. i shall check them all out.

If you want to..... I recommend you WinAPI.

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.