Programming Windows
In the life of an Engineer every thing has levels, when you write a program you can use a high level language like C/C++ or Pascal or you can use a low level language like Assembly or a very easy language like Basic.
Every
language has its advantages and disadvantages; it is your job to choose the
write language/tool for the write job.
In
many cases the Engineer makes a mix of the tools he use, as he can write a
program with C/C++ and write some functions in assembly.
In the world of Windows and
GUI (Graphical User Interface) programs the situation is the same you have many
tools Visual Basic, Visual C++, C++ Builder, Delphi, etc… and the APIs.
API
stands for Application Programming
Interface, it represents the lowest level in programming your GUI, do
not be afraid it not very hard like assembly it is just Harder!
Most
of the times you will use Rapid tools like Visual Basic, C++ Builder and Delphi
But some times you will have to use some APIs, so in this tutorial we will help
you learn APIs.
In
this tutorial we will not study Rapid tools like Visual Basic, C++ Builder and
Delphi but we will try to make a simple tour for the APIs.
Our
aim is not to study the APIs it self but to learn how it works in general
And how to use it when you
need it (while working with other tools like Visual Basic, C++ Builder) as
there are some things that we cannot do with out APIs until now!
Learning APIs will also
help us understanding how Windows works, how events and controls are managed
and what are the services that Windows provide?
So let us first talk about
some history.
When
the IBM PC was first introduced in 1981 it was running with MS-DOS (Microsoft
Disk Operating System) it only provided some command-line interface command
like DIR and TYPE and loading applications to memory and some I/O functions,
but for graphics and video display support applications had to access the hardware
directly.
At
1985 Microsoft released Windows 1.0 (the first Graphical User Interface
version) and after 2 years released version 2.0 it was so simple from the
Windows we know now, it has access to 1 MB only of memory!
Microsoft
was working also with IBM on OS/2 (and alternative to DOS and Windows) but the
conflictions between IBM and Microsoft reached a peak and they ware separated
and Microsoft continued developing Windows
At
1990 it was Windows 3.0 the first to support 16-bit mode running on Intel’s
286,386and 486 microprocessors and could access 16 MB of memory
Window 3.1 was lunched at
1992 it has many improvement like True type font (scalable fonts), multimedia
support, OLE (Object Linking and Embedding) And Common dialog boxes
Windows
NT was introduced in 1993 was the first version to support 32-mode and have
access to 32-bit flat address space.
Windows
95 was introduced at 1995 (of course!)
It was like NT but it lacked some features like high security but it
required less resources
And after that it was
Windows 98 and 2000 and millennium and XP, as you know
If
you worked with several versions of Windows you can feel how Microsoft is
interested to the GUI and the hardware support more than the Performance and
The Stability of the system, it was there Strategy and it worked and Microsoft
Windows became the most famous Operating System for PCs and they continue to
reach the top until they go down!
Enough with the history,
let’s see talk about Windows and its APIs.
Windows
is a multitasking and multithreading graphical operating system
Multitasking means that you
can run more than one program at the same time on the same operating system
Multithreading
means the same like Multitasking but at the level of the program (process), as
many jobs (threads) can run at the same time concurrently in one process.
Windows
is a graphical operating system means it has a GUI (Graphical User Interface)
also called a “visual interface” that provides many standard controls like
buttons, menus, dialog boxes, tool bars etc …
Windows
also provides also support to multimedia and networking.
All these controls and
features can be accessed throw APIs but let’s first see what APIs is exactly.
Any
system you should look at it as a Black Box that takes some inputs and produces
some outputs or do some jobs, we should talk to the system using an interface
that the system should provide, that interface should be easy!
In the world of Windows
this is the case except that the interface here (APIs) is not easy, so many
tools like (Visual Basic, C++ Builder) was released to overlap most of the APIs
work for you and make it easy to write programs for Windows, But to make these
tools easy enough they did not overlap all the APIs so some times you need to
call one or two APIs functions.
We
have to say that Microsoft it self overlapped ALL the APIs in a Collection of
C++ classes called MFC (Microsoft Foundation Class library) but it was not easy
too!
APIs
consists of a large set of functions (several thousands) that Windows provides
for you to show some GUI controls in your program or do some services like I/O
or Multimedia services, this functions are located in files called DLLs
(dynamic linking libraries) means that code for these functions is linked at
run time.
This
makes all programs running under Windows shares the same APIs and that is why
all the standard controls (buttons, menus, dialog boxes, tool bars etc) have
the same fundamental look (that look can be overlapped of course but using new
controls).
APIs
can be split into subsets: the first subset is Kernel (implemented in
kernel32.dll) which handles memory management, file I/O and tasking, second
subset called User (user32.dll) handles the user interface and contain all the controls, third subset
called the GDI (Graphics Devices Interface implemented in GDI32.dll) which is
responsible for displaying text and drawing graphics on the screen and printer,
other subsets contains other functions for Networking and multimedia and other
tasks that are beyond the scope of
this tutorial.
So in the next tutorial (Åä ÔÇÁ Çááå)
we will continue our talks about APIs and will introduce some API functions
calls and how to call them so stay tuned!
References:
1. The famous classic book:
Programming Windows Fifth Edition by Charles petzold
2. The MSDN (Microsoft
Developer Network) www.microsoft.com/msdn/
(Select Platform SDK/User Interface services)
Any comments and/or questions
don’t hesitate mail me at: