Site hosted by Angelfire.com: Build your free website today!
DelphiZeus
Developing Delphi programs in Windows API
without the Forms unit

   Welcome to the DelphiZeus web pages    
by Wes Turner


Here you will find help with the computer programing platform of Delphi, a Pascal language development application. The focus here is programing and developing code without Delphi's Visual Component Library using Windows 32-bit "Application Programming Interface" (API) fuctions to create applications without the Forms.pas unit, resulting in knowledge of the windows programming interface and smaller executable's file size. There are always a variety of ways to code things, these pages are meant to help those delphi coders that did not learn the windows API functions for window creation and messaging that are not covered in Delphi Rapid Application Development (RAD) instuctions.

                   

At DelphiZeus you can see some instructions, Code and Tips about making programs without the "Forms" and "Controls" units or any of the Component Library. You will be shown how to create windows Classes and the windows, then use the "Message Loop" to pass messages to the WndProc message handling function. Delphi 5 was used for the examples here, but since this is API, many of the delphi versions can use this code. Versions of 32-bit Delphi before 4, (in versions 2 and 3), have their Integer type as a 16-bit type, so it will be nessary to change the "Integer type" here to 32-bit LongInt type, and change the 16-bit "Cardinal type" to 32-bit DWORD. Also those versions do not automaticaly dereference pointers.

Intro
Delphi is an excelent Rapid Application Developement (RAD) tool and can produce outstanding programs. Delphi users will notice that most of the API window creation code is hidden from them, and handled in the background in the "Forms" and "Controls" units. Many Delphi developers think they are programing in a "Windows" environment, when they are really working in a "Delphi" environment with Object Oriented delphi code "wrappers" for the windows API functions. When you need more programing options than is offered in the Object Inspector or Component Methods, it becomes neccessary to use Windows API to accomplish these options. As your programing goals become more specialized you may find that the click and double click ease of the Delphi VCL will not have the variety and creativity needed for unique methods and visual display, requiring your API knowledge for a lager variety of programming tools.
The file size of a RAD Delphi 5 App is at least 250 Kb, due to the "Forms" unit, which will include alot of code that may not be needed. Here the "Forms" unit will Not be used, developinging in API means that you will be coding all of the windows creation and message handling, I will first show you how to program in the project file   .DPR   (program) of your application. There will not be a usable Object Inspector or any components, this is NOT  RAD, it is slow and there is no visual "Form" to see during developement. But by learning how to do this you will begin to see how the Windows OS operates and uses window creation options and windows "messages" to do things. Which is very useful in Delphi RAD with the VCL, and almost essential for VCL WinControl Component development. If you can find the time and patients to learn windows creation and message methods, you will greatly increase your ability to use Delphi, even if you don't use only API and program with the VCL.

Since this about using API and coding without the VCL, I start with a lesson about using the delphi "Project file", with the   .dpr   extention. This gives some examples of programs that use API but do not have a Graphic User Interface, and no windows are created. Then in Lesson 2 there are examples for creating windows and some explanation for the many options in this creation. Also there is some explanation of the convoluted workings of the window's "Message" operations and methods. Then more lessons follow about graphic operations, using fonts, pens and brushes on a Device Context. In the Buttons and Edit Controls lesson there's more about creating and using Controls (buttons, edit and static). Some pages are still under constuction.

To use these pages, it would be good if you are familiar with general Pascal coding methods (for loops, typecasting, case statements, ect) and some experience with Delphi, this may be tough for a Delphi programming Beginner.

BE WARNED - - the windows API is a very large subject, requiring time and effort (trial and error) to learn and use.

Email comments, sugestions, code correction, questions, or improvement ideas, to
       

please include the word -  DelphiZeus   in the subject line of your EMail, or it may be deleted with the spam.

Contents

1. -     Creating a .dpr program
              Explains using only the Program (.dpr) unit to create an application

    1a. -   Reading the C code in Win32 API Help
              Tips for Pascal coders to help read the Microsoft C-Code in the API Help.

2. -     Making a API window and message loop program
              Shows how to create a Windows GUI program with windows and a message loop

3. -     More Messages and Changing Windows Properties
              Explores changing the message parameters, and a window's properties.

    3a. -   SmallUtils Unit an Alternative to SysUtil
              A utilities unit so you don't have to use SysUtils and add 20 Kb to your program

4. -     PChar, it's a Pointer
              Gives some examples for using the PChar in API parameters

5. -     Fonts and using HDC
              Explains some basic graphical concepts, the Device Context and Font creation

6. -     Brushes and Pens, with intro to timers
              More examples of DC Drawing functions with Brushes and Pens and a Timer

7. -     Buttons and Edit Controls
              Shows how to use options and subclassing to get Buttons and Edits to do more

8. -     Using Dialogs
              Instructions for creating REAL dialogs in delphi, using the DIALOG resource creation

9. -     Non-Modal Dialogs and Scroll Bars
              Outlines the creation of Non-Modal Dialogs and shows how to use Scroll Bars.

10. -     Menus and Listboxes
              Gives information about creating and using Menus and Listboxes

11. -     Code In Units, Combo Boxes
             A program that divides the code into Units, and uses Combo Boxes.

12. -     Programs with XP Themes
             How to have your programs use the XP Theme Control Drawing.

13. -     MakeApp a Universal Unit
             The MakeApp.pas is a Reusable Code Unit, that can be used in many programs.

     13a. -     Example code for MakeApp Unit
             Code Examples for the MakeApp Unit and do Drag and Drop with DragAcceptFiles.

     13b. -     A Visual "Graphic" Control Unit
             The GrafCtrl.pas Unit has code for making Non-Windowed "image only" controls.

     13c. -     Example code for GrafCtrl Unit
             Code Examples for the GrafCtrl Unit using the G Controls.

14. -     Using System Open and Save Dialogs
             How to create and use the standard system Open and Save Dialog Boxs.

15. -     Reading and Writing Disk Files
             How to Create and Access Files on Disk to Read and Write File Data.

     15a. -     Program Code for Using Files
             Code for the UseFiles Program, to show methods to use Disk Files.

16. -     More Top Level "PopUp" Windows
             How to create and use Pop-Up windows, methods for docking and animation.

     16A. -     A Unit for Modal Message Windows
             Methods to have pop-up Modal Windows that block code progression.

17. -     Tray Icons in your Program
             A program that places a Tray Icon in the task bar's status area.

18. -     a Text Editing Program (like Notepad)
              A compleate text editing program like Notepad, with Registry data and printing

19. -     A Note Posting Program with List Box
              A program that displays a yellow Post Note and shows how to use List Boxes

20. -     Using MuliMedia and Thread Timers
              An Animation program that displays text scrolling and a moving ball



The next pages are for things not directly related to API programming instruction.

21. -     A Delphi Unit used to save Icons to file
              Has functions to save Icon files in 256 and Full Color Formats

22. -     Builing Custom Files with TFileStream
              Tells you how to create files with TFileStream that contain several different Data segments

23. -     Creating HTML Dialog Boxes
              Shows you how to produce an IE Browser Window Dialog Box.

23. -     Web Links to Delphi Sites



Search for a word here -
This is a limited word search of this site
Search for:
Case-sensitive - yes
exact, find only these charaters
fuzzy, find whatever is close

    fuzzy results are often fuzzy ( not useful )

       
This web site was inspired when I was trying to build an API program, and searching for information about API programing for Delphi, and only finding simple "Hello World" type programs (many of those containing bad or incorrect coding practices). There are sites and information for windows API programming in C and C++, but few, if any, for Delphi Pascal.