WIN32 API Programming
WIN32 API Programming
Introduction
WIN32 is a family of Windows which supports 32bit GUI based platform for applications. Following functions and features of WIN32 API makes it more userfriendly and powerful :
GUI platform with multithreading helps in multitasking. Various menus/popup-menus, dialog boxes and clipboard utilities. Supports various coding languages and linking between them. Manages the resource allotment to programs.
API Application Programming Interface is a source code that a program library provides in order to support request by any computer program. Helps program to interact with hardware while executing its codes. DLL Dynamic Linking Library is a shared library of executable functions or data. This mainly contains DLL, OCX (ActiveX file), DRV (driver file)
Modules
1. WIN 32 resources 2. Message and events 3. Characteristics of a Window 4. Management of different windows 5. GDI (Graphical Device Interface) 6. GDI tools 7. Bitmaps
Modules
1. WIN32 Resources :
Resources are menus, icons, cursors, dialog boxes, sounds having extension *.res (.rc for fonts). Text based resource (Keyboard accelerators) and graphics based resources. Usage : Resources can be created or imported just like a normal code. As these are mainly in graphical form so, two or more resources can be merge to create another.
Eg. Caret (the blinking line), Cursors, Icons, Keyboard accelerators etc. are the common resources.
Computer need commands to operate. OS sends messages of various constant positive integer. Every message have its unique value.
Windows Message
3. Characteristics of a Window :
An application window have different properties depending on its border type, title bar, caption, visibility style etc. WIN32 provides various functions to manipulate the application windows properties. For normal users, WIN32 provides simple drag-and-drop GUI based function to move or resize his/her window.
Therefore, each number can have a value that ranges from 0 to 255 in the decimal system. These three numbers are combined to produce a single number as follows :
Converted to decimal, this number has a value of 255 * 255 * 255 = 16581375. This means that we can have approximately 16 million colors available. Microsoft Windows considers that a color is a 32-bit numeric value. Therefore, a color is actually a combination of 32 bits:
6. GDI tools :
GDI tools are those applications by which an user can draw or create some simple textual or graphical based diagrams. Some GDI tools are :
A pen can be used to draw only simple lines of a fixed width, less than or equal to 1 pixel.
GDI Tools
GDI Interface
7. Bitmaps :
A bitmap is a series of points (bits) arranged like a map so that when put together, they produce a picture that can be written to, copied from, re-arranged, changed, manipulated, or stored as a computer file.
Bitmap can be monochrome in which each pixel have 1 bit. Color bitmap image have more than 1 bit in one pixel.
Source Code
Output
Drawing
This is a simple GDI based program where we use GDI tool Pen to sketch some raw structure without any coordinates commands to program. User decides what to draw at the time of execution.
Source Code
Output
Matching Game
This is a complete game program which is entirely based on WIN32 GUI based application where an user matches all similar types of images or diagrams present in game in form of bitmap image files. When the user finds all similar images of the game then the game displays number of attemps made by that player.
Source Code
Output
Conclusion
WIN32 APIs are being used in every field of Windows programming. It is widely being used in approximately every application to make it user friendly by using GUI technology of various APIs of Windows. We are going to implement more applications and GUI based games by integrating various modules of WIN32 API and GUI properties. We can execute our applications according to our requirements with the help of self created and modified DLL files.
References
Programming Windows - Win32 Api (Mspress, Charles Petzold, 5th Edition) Programming Windows 6th edition Inside Windows Debugging (Tarik Soulami) Internet (www.msdn.microsoft.com)
Thanks