Other roads to GUI development
CS 321 2007 Lecture, Dr. Lawlor
Writing bare win32 code is pretty slow going. For example, adding a button to a dialog box requires:
- A modified resource DIALOG object.
- A new button ID, in the resource header file.
- A modified wndProc to handle the WM_COMMAND to accept the button's changed value.
This can be done, but it's painful.
By contrast, there are lots of systems where it's way easier to make new buttons.
GLUI
My recent favorite GUI toolkit is GLUI.
It's built on top of OpenGL, and hence is quite fast and completely
cross-platform. Adding a checkbox requires exactly one line of
code:
new GLUI_Checkbox( glui, "Thingify", &enable_thingy);
Here, "enable_thingy" is just an "int" that gets set to 1 or 0 as
controlled by the checkbox. It can be a global, a class variable,
static, and so on. The nice part is this makes most of the GUI
"fire and forget"--you don't have to keep track of where the thing is
onscreen, draw it, respond to clicks, and so on. The checkbox
sets one of your globals. Easy!
See lots of example programs using GLUI at my cs481 homepage.
Visual Basic
Another very easy way to build GUIs is in Visual Basic. Unlike
"Visual C++" (which isn't "visual" in any way), "Visual Basic" lets you
just click-and-drag together an entire, functioning GUI. To make
a button, you grab the button tool and drag out its boundaries.
To write the Basic code to execute when the button is clicked, just
double-click the button in the editor. It's extremely easy to
slap together a quick little application in under 10 minutes.
For example, try some Basic code like:
Shell("cmd.exe")
or
MsgBox("Sup?")
Visual Basic stole this idea directly from Mac HyperCard. I don't know where HyperCard stole it from, though...
GUI Designers
Many people have
written drag-and-drop code to build GUIs, like Visual Basic, but
talking to any number of languages. These tend to be called "GUI
Designer" or "RAD" (Rapid Application Development) tools. See Glade (for GTK), Qt GUI Designer (for Qt), Windows Forms Designer (part of Visual Studio.NET), NetBeans or many similar tools for Java, and so on.
JavaScript and CGI Programming
It's also possible to shove most GUI work off into a web browser.
Realize this: a web browser automatically gives you cross-platform
operation, text layout (via HTML), buttons, textboxes, checkboxes, and
so on (via HTML forms), a scrollbar, printing, and Unicode support, all wrapped up in an interface people are comfortable using.
The downside is that you have to talk to the web browser somehow, and
your options are pretty limited. You can write JavaScript that
runs inside the web browser, but is not nice or easy at the
moment. Like NetRun, you can do all your processing on the server
and send the browser only HTML, but this limits what sorts of
applications you can build. Browsers will never give pages
control over the menu bar, "back" button, and "save", so you just can't
build some things that should be easy.