Fog Creek Software
Discussion Board

Code snippet of tedious GUI programming with SDK?

I want to impress upon someone the power of using a drag/drop GUI builder tool like VB (vs handcoding a GUI, as was done until the early 90's). 

For example, I would like to contrast simply dragging a cmdButton onto a form with the screeen of code early 90's API SDK code that would have been required to do the same thing.    (or an Xwindows code snippet)

Does anyone have a code snippet that would reflect this ?  Greatly apprecaited.

Monday, September 08, 2003

Like this?

CreateWindow("button", "Click on this big button", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 10, 7, 403, 238, hwnd, HMENU(ID_BUTTON), hInstance, NULL);

Personally I find that to be less tedious than dragging a button, sizing it, and individually clicking and setting 6 or 7 different properties.

There are also two mis-conceptions in your original post. First, that style of coding is widely used today in API programming, as in shrink-wrap software. Second, it's always been possible, even in the "early 90's", even when writing C code, to visually drag-and-drop your controls. In the Windows 3.1 days this was done using MSVC's "App Studio". In later times, this functionality has been integrated into Visual Studio.

Nate Silva
Monday, September 08, 2003

Was early Visual C++ a drap and drop GUI builder?
Or just a C++ compiler/IDE ?

Back then, I was coding pure C on AT&T SystemV Unix.  (Had to fight long and hard to finally get a job working with SQL and GUI's...where the real money was)

Monday, September 08, 2003

It was not based around a drag-and-drop editor, but it had tools to make dialog boxes graphically.

For something VB-like you could have a dialog-based application (similar to a lot of VB apps) and controls could be linked with events using MFC. You could select a control and double-click to add or edit its event handlers.

Or, you could code directly to the API.

I tended to use a combination of the two -- drag-and-drop for most dialogs and API for more complicated stuff.

Nate Silva
Monday, September 08, 2003

Not the like of what you mention, but I recently did develop a small application where in you could drag icons from the left and drop them over a canvas and then resize them, add text to them and print out the canvas and stuff. If you'd want to take a look, there are two snapshots here.

This was a small part of a larger application and was triggered by a menu item in the larger application. This application was built in VB6 with extensive use of the API. It's got nothing more than an MDI form and a single child form. No picture boxes, no image controls. It is very light-weight and also synchronizes its designs with the head office computer of the client on a winsock.

Sathyaish Chakravarthy
Monday, September 08, 2003

Check out:

...for downloadable sample code. I think you'll find what you want here. Petzold was *the* most-read Windows development author at one point.

Now, an editorial: ;-)

Visual C++ and the SDK weren't really WYSIWYG. "App Studio" was an elaborate graphical wrapping of an editor that allowed you to create dialog box resources. (A "resource" being binary data in a certain format attached to a Window EXE.)

At run time, the application code could create a modal dialog box or a modeless form whose layout was based on the dialog box layouts in the associated resources.

The programmer had to work really hard to make sure that every control on a form layout in the resources was associated (by a control ID) with code that attached a "button" or "edit" object to it.  It was a clunky, primitive, confusing mixture of different ways of looking at the same things that Visual C++ never really improved upon. 

At least in C++ specific controls could be controlled by unique object types of certain classes. In C, the developer would simply hook the window procedure for the entire window and handle all the control transitions and updates from there. But MFC development and C based SDK development really looked pretty much the same and required almost exactly the same skills at the OS level.

And lots of stupid PhBs and managerial types worshipped the ground that MFC walked upon as a "standard" even though using it amounted to strapping lead weights to a sprinter's feet...

Borland Delphi wrapped the Windows environment *really* nicely in a way far superior to SDK and MFC level programming, but most ensconced  MS developers never really "got it".

Bored Bystander
Monday, September 08, 2003

Having used Delphi I have to say that anot only did I "get it" I rather wished I had not. Delphi was much betterthan VB but simply didn't have the transparency of VC++. And don't get me started on the use of "with". Blech.

Tuesday, September 09, 2003

>Having used Delphi I have to say that anot only did
>I "get it" I rather wished I had not. Delphi was much
>betterthan VB but simply didn't have the transparency
>of VC++.  And don't get me started on the use
>of "with". Blech.

I don't understand what you're saying here but I find it curious.  What do you mean by "doesn't have the transparency of VC++"?  Care to elaborate?

Matt Foley
Tuesday, September 09, 2003

Going from memory only (it has been a loooong time...):

Everything is hidden behind properties that you have to click, as I recall, rather than just being code which you can see (almost) all at once.

The layout of dialogs is visible in VC++ directly or as text (as someone else said), and the later can be a real help when your customer wants you to "move that control 1 pixel to the left".

Too much reliance on controls. Even non-visual things seemed to be based around controls. I was doing networking FFS, I didn't need no steenking controls (I just wanted a class I could use as an interface)!

There were a couple of other things as well, which occured to me when I used it but now don't recall.

Tuesday, September 09, 2003

You can just create any control on the fly in Delphi. That they happen to be available as controls is really a minor thing, it just lets you set properties graphically rather than programatically.

With Delphi version 5 (I think) and later, the form sources are all stored as XML files, so you can very easily use an external editor and line up the controls exactly as you want them. Or you can create the controls manually, as I mentioned.

Delphi is a pretty amazing tool, you can get under the hood with it if you want. It's not VB at all. It's like the ease of VB with the power of Visual C++, but better than both in many areas, in my opinion.

Of course Borland couldn't market their way out of a wet paper bag. With .NET soon to take over and Microsoft's environment for that being "good enough", I don't see much future in it.

Sum Dum Gai
Tuesday, September 09, 2003

The Delphi form files are stored as text but it's not XML.

John Topley (
Tuesday, September 09, 2003

I found delphi extremely transparent, and controls extremely useful; I have to admit I did make most of my forms in code, but that is just the way I am.

"with" was cool too; think we had a thread about that a while ago.. everyone said 'yuck' until Joel said 'great' and then everyone seemed to convert ;-)

i like i
Tuesday, September 09, 2003

I didn't :-)  I hated it then and I hate it now!

Tuesday, September 09, 2003

I believe it's the project files that are now XML.

Paulo Caetano
Tuesday, September 09, 2003

The market failure of Delphi against Visual Basic portends very bad things for any software company going against Microsoft -- I don't believe that it's a religious or biased statement to say that Delphi absolutely trounced Visual Basic in virtually every single way that they could be compared (and I say this as a Visual C++ who went kicking and screaming when forced to do a project in Delphi for the first time -- I didn't, and partly still don't, believe that RAD tools offer the presumed advantages in a real project through a whole SDLC iteration).  From speed of application (i.e. RAD capabilities), to generated code (Delphi's code generation is extraordinarily good), to third party tools and components (tens of thousands of "native" Delphi components, and a full ability to use COM components as well, so therefore all of the components that VB has), to language (VB's historic language quite simply was a joke compared to Object Pascal), to an ability to utilize all of the Win32 platform. Given that COM was the "lingua franca" by which subprojects and components interoperated (and hence there shouldn't have been as much of a "network effect"), it really was baffling how people, such as Joel, would choose Visual Basic. I think it's a fair question to ask anyone who historically chose to develop applications in Visual Basic to explain their choice: Was there a credible reason, or was it just a blind lemming safety choice.

Having said all of that, Delphi is a dead-program walking. Their cross-platform initiatives (such as Kylix) have been of limited technical and market value (which is surprizing given the ascent of Linux), and now with Visual Studio.NET offering a tremendous, Delphi-like environment (with C# taking a lot from object Pascal), Delphi has lost its niche--- If it couldn't compete against such an incompetent adversary before, how will it fare against a credible one?

Dennis Forbes
Tuesday, September 09, 2003

Anyone remember the 3 pages of "Hello World" code from Inside Macintosh Vol. I?

Just me (Sir to you)
Tuesday, September 09, 2003

Microsofts hiring away key Borland employees was one strategy to keep Delphi down. Anders Hjelsberg is the father of Turbo Pascal/Delphi and c#.

As for gui tools, How many people still code html by hand?

fool for python
Tuesday, September 09, 2003

A note to Delphi haters: don't pull made-up stuff out of your arses, please. You can hand-edit anything you want in Delphi. You want to position a button with code? Open your DFM, it's just text.

(And about the "with" keyword: come on, one can say a couple of things about certain VB ways to do stuff, like return values from functions or exception management.)

Leonardo Herrera
Tuesday, September 09, 2003

> As for gui tools, How many people still code
> html by hand?

I bet _every_ professional web designer.

Leonardo Herrera
Tuesday, September 09, 2003

The failure of Kylix isnt that surprising given the failure of Linux on the desktop. And the first version was very rushed.

John Topley (
Tuesday, September 09, 2003

I just monkey wrenched and subverted this entire thread by mentioning Delphi.

I am so proud...!!! ;-)

PS: I hope Bella got his source code.

Bored Bystander
Tuesday, September 09, 2003

Ow, Delphi hurts.

Leonardo Herrera
Wednesday, September 10, 2003

*  Recent Topics

*  Fog Creek Home