Windows Environment’s Basics
What is a window?
A window is a rectangular frame through which we can view a document .
It acts as a medium or an interface through which we can see any type of file provided it resides in memory. It is a full bit-mapped (each picture element or pixel is represented by bits stored in memory) graphics display and that is what we call the Graphical User Interface(GUI) environment.
The GUI originates as a result of research at Xerox Corporation’s Palo Alto Research Centre (PARC) in the early 1970s in order to make computer easier to use.
Writing a program in Windows ensures compatibility with a large number of peripheral devices .
An application can access more than limited 640K of memory and Windows is itself responsible for its memory management .
We also need not to worry about writing complex graphics routines .They are all part of Windows .
It can run two or more programs concurrently which is the characteristics of its multitasking environment.
Another important property is that Windows is a Object-Oriented environment .It supports two types of multitasking.
A process is a program in execution.
A thread is a dispatchable unit of executable code.
All processes have at least one thread but a Windows process may have several.
Windows Application Program Interface (API ) Interface :
The operating system services are usually provided through software interrupts. For example in DOS it is interrupt 21h.But interfacing to a full-featured multitasking operating system requires much sophisticated system-defined functions which must be capable to manage couple of processes executing simultaneously.
Sometimes called call-based interface uses a rich set of system-defined functions to access operating system features. Collectively these functions are called Application Programming Interface (API) . The API contain hundreds of functions that any application must call in order to communicate with Windows .Activities like memory allocation , formatted output , window creation etc are performed by these functions.
Windows application specifically designed to run in the Windows environment, taking full advantage of Window’s application program interface (API) which provides the features commonly associated with a graphical user interface and makes its features available to programmers of application packages.
Dynamic Link Libraries (DLLs)
Windows programs interfaces Windows through "dynamic linking". All API functions are stored in a relocatable format in dynamic link libraries (DLLs) . When an application is compiled , the linker does not add the code of the functions called by the program .Instead , it stored the names and location of the DLLs which contains the functions required by the application by constructing the table in program’s exe file . Its means every Window’s exe file contain references to various DLL files and the functions there in .
Only when a program is loaded for execution , the necessary APIs are then loaded into memory .
- Dynamic linking prevents the secondary storage space where the program’s executable file resides by discarding the code of API functions .
- Existing application programs do not need to be recompiled . Only dynamic link libraries are required to be change , if further enhancements are required to any application .
Programming in Windows environment
Developing a Windows application is much easy as compare to build it in DOS environment.
Windows applications do not directly access the hardware of graphics display devices (screen , printer) rather it include a graphics programming language called graphics device interface (GDI) that display graphics & formatted text .Windows applications run with any video or any printer and is independent of type of device.
Typically, we can write four kinds of functions in our Windows "C" program . I am refering the programming environment of "C" in Windows.
Win Main ( )
It is the main Windows interface function .It does three crucial things.
- It registers the window class for the application’s main window.It tells Windows about the characteristics of the main window e.g name of window procedure function , icon used for application , when its window is minimized , background color , menu uses etc .
- It creates application main window , issues the CreateWindow() function and display it on-screen .
- It contain the application’s main message loop which contain GetMessage() function , which request and receives data and commands from Windows . When program calls GetMessage() , Windows may decide to execute another application .
This is the main window procedure . Windows was told the name of the window procedure when the window class was registered . GetMessage() , gets a message from Window , performs necessary translation and dispatch back to Windows . WndProc() is finally invoke at this point and receive data or command for action .
Other Windows-oriented functions may be required , depending on what Windows features we use , e.g , creating , displaying and handling a dialog box , requires the use of a dialog function.
Simple helper functions may be needed to complement the program’s work . These are non-Windows functions or a user defined functions.
Under construction !
1. QUE’S Computer User’s Dictionary.
2. Using Borland C++ 4.5, Special Edition.
3. Schildt’s Windows 95 Programming in C & C++