The power of Windows and the WIN32
Developing EZGUI 5.0 was challenging and it demonstrates the real power of the Windows API, particularly the more functional API’s, rather than COM.
Working with API’s which are simple functions, rather than complex COM objects and classes makes coding easy in my opinion. I like simple. Similar to the concept of STL (the Standard Template Library) in C++, EZGUI was designed using simple functional API’s and its own library code was designed to work in a similar way (simple and easy to use). If you read some of the posts of this blog, you will find that I am not impressed with object oriented programming. Actually, the Windows 8 WINRT is my opinion has been made overly complex and bloated because of this over dependence upon OOP. The idea of passing objects for many key routines just adds complexity.
What few people may appreciate is that the core Windows API (commonly refered to as the WIN32) is amazingly simple in its design, yet quite powerful. The problem with WIN32 though is that too many mundane tasks are left to the programmer, which is likely why programmers found it so difficult to code apps using C and the pure WIN32. Microsoft later provided libraries like MFC, ATL to make life easier, but even there Windows coding was still complex. Why ?
I finally found the key to understanding WIN32. I started buying old used programming books which dated back to the mid 1990′s. One really good book on building custom controls dated back to WIN16 (windows 3.1) actually. I had to avoid books which used MFC too. Once I found the right, older, books, learning the WIN32 APIs and how to code GUI apps began to make sense.
Amaxingly, good old C (not C++) code was the easiest code to convert to PowerBasic. The simplicity of C, compared to C++ made things a lot easier. What made things even better, was when I started building my own code base written in PowerBasic. While WIN32 code using C is not too bad, WIN32 code written in Powerbasic is actually readable and makes a lot of sense. Now that I could tap into the WIN32 API’s (and later OpenGL which is also a well designed clean set of functional API’s), then some amazing things began to happen.
I am strong believer in building modular , reusable code. As I began to build my own GUI libraries (on top of the WIN32) I began to realize how powerful Windows really is (the WIN32′s). There are some core concepts in Windows which provides some amazing power, which sadly few programmers ever tap into themselves. I also realized that while high level libraries are important, medium level and especially low level are also vital.
For example, the DIB (Device Independent Bitmap) API’s in Windows are amazingly powerful. Direct access to bitmap data and control of the bitmap format (I use 32 bit a lot) opens up all sorts of possiblities. I tapped into the power of DIB’s in a lot of features in EZGUI.
Another really exciting feature is OwnerDraw. In essence ownerdraw allows you to create all sorts of new controls, simply be customizing existing ones by drawing the data in them yourself. Customdraw is similar, but allows you to just define fonts and colors of elements of a control (items).
The problem with WIN32 though is these powerful features, require some advanced coding which may not be easy for some. Even with my own experience I found them overly complex. So I decided to simplify much of these things, so you still had the power the API’s provide, but it could be more easily tapped into. Now things got interesting when I started to learn how to build my own custom window classes (custom controls) from scratch. My Canvas control was amazingly simple, yet powerful, one reason being that I allow you to tap into the Windows DIB engine. It was simple to impliment things like image filters for the Canvas control using DIB access.
By the time I created EZGUI 3.0, I was beginning to run out of common tasks to impliment, so I started building more complex things. I added a 2D Sprite engine to my Canvas control. I added more ownerdraw support. I started building hybrid controls via superclassing and ownerdraw combined. I started simplifying threading.
One of the problems with the WIN32 is that each new version of Windows may add some new features, so how do you support the new stuff, while maintaining backward compaitbilty with the prevsious versions ?
You see this with retail software where in each new version, the minimum version of Windows required kepy creeping up. First it had to be Windows 98. Then it had to be Windows ME. The Windows XP became the minimum version required. This is not necessary actually, because from day one (Windows 95) Windows had a core feature in the operating system which makes this unnecessary. The WIN32 provides you with the ability to load libraries (DLLs) dynamically at runtime (LoadLibrary API) and then poll the library to see of a specific function exists. If it does, then you can get the address of the function and then call the API dyanamically via its address. The PowerBasic language easily supports this too using the CALL DWORD (call by address) command. This allowed me to code features specific to more recent versions of Windows, while providing workarounds for older versions. For example in EZGUI some of the drawing commands can draw themed elements, but if theming is either off or does not exist, then it falls back to drawing a GDI version (not themed of course). PowerBasic also has a rich set of commands for handling structures, even using low level pointers to data which also allowed me to write code which was dynamic. It could use data structures specific to the version of Windows which was running.
What is really amazing is how compatible all of my library code is even with the new Windows 8 (desktop). The interesting thing about the recent versions of Windows (XP to 8) is that the look and feel has progressively changed, especially with Windows 8. Wouldn’t it be nice to write apps, which look similar on most versions of Windows. Well, EZGUI can do this because of its string support of ownerdraw and customdraw. EZGUI can override the defaults and customize a UI to any way you like. The possibilities are endless.
Windows (WIN32) is like a set of building blocks, so almost anything is possible. Why should we be stuck with a certain look and feel for our software. Even Microsoft can’t make up its mind on what is the best look and feel. In the past programmers were encouraged to copy the look and feel of Microsoft software. Now with Windows 8 basically considers all the “eye candy” of the past is considered obsolete and the new Metro Style (flat as a pancake) look and feel is in. Personally I find all this flatness distasteful. Programmers should be able to design a UI according to their own needs and preference. Some times color and 3D dimension is good. Some times a button needs to stand out in 3D rather than be a flat rectangle (how can you tell the difference between a button and a label now if they both look the same ?)
It is not a matter of using “eye candy” simply for the sake of eye candy. Some times a user interface needs 3D elements and depth to me truly natural and meaningful. I also don’t like (in Metro side) the over dependence upon the “BACK” or “PREVIOUS” button where navigation is done by clicking BACK. Navigation in a user interface can have many difference choices beyond the over simplification of Metro.
The WIN32 sadly was not fully tapped into at times, but it offers some amazing possibilities. It amazes me to see how some of my customers have used EZGUI 5.0 Professional to build some truly unique looking interfaces for their software. Also the power of Windows does not require software to be bloated either. Take for example the EZGUI 5.0 runtimes. In about 1 megabyte, the core runtimes accomplish things which may surprise you. Not only does it provide the basic UI elements of controls and forms (no OCX’s needed for controls either), but there are a number of proprietary custom controls included, a 2D sprite engine, a graphics engine, a print engine, a drag and drop engine and even OpenGL based 3D. All in one megabyte.
Now another amazing thing is because of avoidance of COM based programming (no OCX’s required), the runtimes don’t require any registration with the operating system (aka. registry). This means complex apps written using EZGUI and Powerbasic can simply be copied and run. Yes, you can put an app on a jump drive and run it from there. You can copy a folder with an app from one drive to another or even one PC to another and run. No need for an installation program. No need for registering objects with the operating system. This provides complete portability, which few apps have today.
Yet, I am not using anything which was not available in the operating system to begin with. I am using features which have been in the WIN32 (and OpenGL 1.0/2.0) API’s for many years. The key is know how to tap into what is already there.
This blog, while about programming, is also about the software I develop and why I created it the way it is. EZGUI 5.0 Professional is a tool which makes coding easier, while tapping into the power of the Windows API. Rather than limit a programmer, it provides more choices. While it has many high level features and custom controls, it is also very low level providing programmers with a variety of ways to tap into the power of Windows.