From DOS to Windows
One of the interesting things I have noticed about my customers who use EZGUI Professional, is that the ones who seem to get the most out of the product are programmers who moved from DOS Basic, like QuickBasic, (or a Console Basic for Windows) to Windows using EZGUI (and Powerbasic).
Why is that , I wonder ?
DOS programming was more of a linear (sequential) mindset and Windows programming is event based, which is one of the biggest hurdles when going from DOS to Windows. Such programmers often find languages like Visual Basic confusing. Writing software with Powerbasic using the Windows API is even more daunting for them.
So what is there about EZGUI which DOS programmers like ?
First of all, EZGUI emulates some features of DOS Basic. One is to define colors using indexes and predefining the 16 DOS colors (0 to 15). Colors 16 to 31 are pastel versions of the first 16, for a total of 32 predefined colors. You can add more colors as you need them, but DOS programmers are use to the color indexing.
EZGUI uses a unique coordinate system. It is character based, just like DOS. But you might say, Windows is not character based. Actually it is (or was). In the early days (Windows 3.1) a unique coordinate system was devised for Windows, called Dialog Units. Dialog Units are scalable, which is a nice feature. Even today, the Windows API still uses Dialog units for Dialogs. The problem with Dialog units, is that a Dialog unit often does not come out to an exact number of pixels, so conversion from Dialog units to pixels is not very accurate.
What many do not realize about Dialog units, is that they are based on Character units. Yes thats right, character units. In the old days, Dialogs used the fixed width System font by default. This font, being fixed width, every character had the same width and height. So what was the size of this character unit ?
8 x 16 pixels
So what is a Dialog unit ?
The horizontal Dialog unit was defined as 1/4 of a character units width.
So 8 / 4 = 2 pixels
The vertical Dialog unit was defined as 1/8 of a character units height.
So 16 / 8 = 2 pixels
Do you see a pattern here ?
On the old Windows, a Dialog unit was 2 pixels , both horizontally and vertically. Thats nice isn’t it.
So whats the problem ?
Later versions of Windows stopped using a fixed width font for the default system font and character units weren’t 8 x 16 pixels any more, so dialog units didn’t divide into exact pixels.
EZGUI solved this problem!
EZGUI uses the old system font for character units. When the system is set to “small fonts”, a character unit is 8 x 16 pixels. When the system is set to “large fonts”, a character unit is 10 x 20 pixels. Yes, EZGUI character units are scalable. What makes EZGUI unique, is that it defines coordinates (and sizes) in character units using floating point numbers (single precision). You see, you can have a fraction of a character unit.
For example, you can define the top/left corner coordinates of a controls position using something like (x,y) :
3.25, 1.625
No matter the size of the character units, a floating point number can represent any portion of a character unit down to an exact pixel accurately. This is why EZGUI character units are superior to dialog units and unlike pixels, they are scalable (pixels are not). EZGUI provides conversions functions between pixels and character units as well.
Now a DOS programmer, can write code like:
EZ_Text %TextID, 5, 2,20, 1.5, “Some text”, “EST”
The text control is put in position 5,2 (column 5 on row two using character units) and the control is 20 character units wide and 1.5 character units tall. This is why some of my customers, who came from a DOS basic background, can write their software’s user interface code by hand, without a visual designer. For those who like a drag and drop visual designer, EZGUI has its own designer too, so you don’t have to hand code your UI’s.
So how do you define a controls colors ?
Like this:
EZ_Color 0, 15
EZ_Text %TextID, 5, 2,20, 1.5, "Some text", "EST"
The EZ_Color command defines the colors of the text control as Black (0) text on a White (15) background. This is just like DOS Basic !
Now don’t be fooled. While EZGUI emulates a few syntaxes from DOS Basic, it is truly a graphic orientated engine (aka. GUI) with all the fun stuff of a true Windows environment. For example, EZGUI’s own Visual Designer was written using EZGUI (and Powerbasic). It is a 100% EZGUI application (meaning it does not use any Windows API’s or even the UI commands in PowerBasic). You couldn’t write that with a console compiler (or DOS Basic).
EZGUI stays away from object oriented coding styles as well. It is a set of well defined SUBs and FUNCTIONs which are easy to use, with simple syntaxes.
Another nice feature in EZGUI, which makes it easier on DOS Basic programmers, is how you reference Forms and Controls. Windows applications are made up of Forms (Dialogs) with child Controls on them (ie. text box, button, etc.). In the Windows API you reference them using window handles, which you have to store in a variable. The operating system defines those window handles, not you. You can reference controls using the syntax of:
hParentDialog&, %SomeIDNumber
where you combine the parent Forms window handle, with the ID number (user defined) you assigned the control., but still you have to store the parent forms window handle in a variable.
EZGUI uses a much easier way to references forms and controls. Let me illustrate:
A good illustration to help you appreciate how this works would be to compare Forms to Streets and Controls to Houses on those streets. No two streets can have the same name and no two houses can have the same number on the same street (but two houses on different streets can have the same number). Imagine two streets, one called Main and the other called North, both with four houses each with numbers 100, 105, 110 and 115. You know exactly which house you are referring to when you say house number 110 on Main street.
Now change the streets to Forms and houses to Controls and we have the following:
We have two Forms, one called Main and the other called North. Each form has four button controls on them, each with a unique ID number (100,105,110,115). We put the forms name in its caption bar and the button controls ID in its text above, so you can visualize this, but in a real application you would not do this. Can you see how each control has a unique ID number, even though those numbers may be reused on another form ?
So if you wanted to reference the button control with the ID 110 on the Form called Main, you would use the following parameters in an EZGUI command like this:
EZ_SetText “Main”, 110, “some text”
EZGUI uses this kind of simple syntax throughout its GUI engine, so it makes it easier for DOS programmers to learn it quickly. Add to this the power of its GUI engine and some of my customers who were DOS programmers are now writing Windows applications with better UI’s than some experienced long time Windows programmers (ie. C++). EZGUI allows a programmer to think like a DOS programmer, but write software like a Windows programmer.