C++: Hello World Graphical

Bjarne-stroustrup
 

In this User Output task, the goal is to display the string “Goodbye, World!” on a GUI object (alert box, plain window, text area, etc.).

Library: GTK

#include <gtkmm.h>
int main(int argc, char *argv[])
{
	Gtk::Main app(argc, argv);
	Gtk::MessageDialog msg("Goodbye, World!");
	msg.run();
}
Library: Win32

All Win32 APIs work in C++ the same way as they do in C. See the C example.

Library: MFC

Where pWnd is a pointer to a CWnd object corresponding to a valid window in the application.

#include "afx.h"
void ShowGoodbyeWorld(CWnd* pWnd)
{
	pWnd->SetWindowText(_T("Goodbye, World!"));
}

Library: FLTK

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main(int argc, char **argv) {
	Fl_Window *window = new Fl_Window(300,180);
	Fl_Box *box = new Fl_Box(20,40,260,100,"Goodbye, World!");
	box->box(FL_UP_BOX);
	box->labelsize(36);
	box->labelfont(FL_BOLD+FL_ITALIC);
	box->labeltype(FL_SHADOW_LABEL);
	window->end();
	window->show(argc, argv);
	return Fl::run();
}

SOURCE

Content is available under GNU Free Documentation License 1.2.