Posts

Showing posts from 2016

List of files generated by in a Delphi Application

Image
Delphi produces various files for each project, and we should know what they are and how they are named.  Basically, two elements have an impact on how files are named: the names you give to a project and its units,  and the predefined file extensions used by Delphi. You will find the files in the directory where a Delphi project resides. Following table shows the extensions of the files and when or under what circumstances these files are created and their importance for future compilations.

Delphi Compiler Version symbols or constants used with IFDEF - ENDIF

Image
If you plan on writing Delphi code that should work with several versions of the Delphi compiler then we first need to know under which versions our code gets compiled.  Suppose you are writing your own (commercial) custom component. Users of your component might have different Delphi versions than you have.  If they try to recompile the component's code - they might be in trouble! What if you were using default parameters in your  functions and the user has Delphi 3? These are symbols that can be used in $IFDEF /$ENDIF conditional compilation directives. {$IFDEF VER40}  - Turbo pascal 4 {$IFDEF VER50}  - Turbo pascal 5 {$IFDEF VER55}  - Turbo pascal 5.5 {$IFDEF VER60}  - Turbo pascal 6 {$IFDEF VER70}  - Borland pascal 7 (And turbo pascal 1.5 for windows) {$IFDEF VER80}  - Delphi 1 {$IFDEF VER90}  - Delphi 2 {$IFDEF VER100} - Delphi 3 {$IFDEF VER120} - Delphi 4 {$IFDEF VER130} - Delphi 5 {$IFDEF VER140} - ...

Hints or Tool Tips in Delphi Application

Image
Hints, we also call Tool Tips are used to show some information related to an action for Users. By default it displays in a separate yellow color window  when we move mouse on buttons, menus etc. But we can create our own customized Hint also. So in this blog I will give a brief idea about use of Hints  in our Delphi application. We will also check how to customize or create a new Hint as per our requirement. Display Hint for individual Controls In Delphi every run time visible component/control and form has 2 main properties Hint and ShowHint which are used to display Hints.  Hint property is Sting type used to set the Hint text.  ShowHint is Boolean type used to whether display hint or not. Here I created a form and put some controls on that. And I set Hint and Showhint property for Button at design time. Now at run time we can see the hint when we move mouse on button as follow We can set the same properties for other controls in code als...

Memory allocation in a Delphi Application

Memory in a Delphi Application When we run our Delphi Application it acquires some memory to store variables, constants, parameters that we have used. And during runtime several  times we create and free objects in our application so accordingly memory is occupied and freed. And those freed memories can be used to store other  values.  So how those memories are managed by a Delphi application, we will see in this blog.  So at first what memory is? in short, computer memories are row of bytes.  One could also say a byte is the smallest addressable piece of memory.  A byte is a small storage unit that can contain 256 separate values (0 up to 255).  In current 32 bit Delphi, memory can be seen as an array of maximum 2 gigabytes in size (231 bytes).  The index of a byte in this huge array is called its address.  What these bytes contain, depends on how they are used like t he value of 97 can mean a byte of value 97, as well as the charact...

Pointers In Delphi

Every data we use in an application is stored somewhere in the computer's memory. And a Pointer is a variable that stores a address of memory piece  where we store data, like in Delphi "a string is really just a pointer" or "an object is really just a pointer" or "event  handler such as OnClick is actually a pointer to a procedure". They allow direct access to memory, enabling complex data structures to be built and navigated. The advantages are: We can set that memory size as per our requirement In case of copy value of a variable from one to another we just need to change a pointer to point to a different address of memory which saved lots of time When we use Pointers The most common use for pointers in Delphi is when calling Windows APIs. Windows API functions use a number of data types that may be unfamiliar to the Delphi programmer. Most of the parameters in calling API functions are pointers to some data type.  Most of the t...

Class Helper in Delphi. Is it useful or not ?

Class Helper Class Helper is a Type that associated with another Class, generally used to extend a class without using inheritance.  We can introduce new functionalities with additional methods and properties which can be used with members of associated class.  To declare a Class Helper we have to state a Helper name with associated Class name. The syntax for declaring a class helper is: type    TMyClassHelper =  class helper for TMyClass       memberList end; Example... // my Class // type     TMyClass = class        procedure MyProc;        function  MyFunc: Integer;     end;       ...      procedure TMyClass.MyProc;     var X: Integer;     begin        X := MyFunc;     end;     function TMyClass.MyFunc: Integer;     begin         .....

Send Email with HTML body format in Delphi

Sometime we need to send Email with HTML body format. So here I have explained two approach to send HTML Email by using Delphi. 1. By using  TIDText object With Indy components we can use same TIDSMTP and TIDMessage components to send a Email with normal Text body or HTML body in Delphi. But we also need to initiate a TIDText object so that we can set its   ContentType = text/html to allow HTML body format. And if we need an Image in HTML body then we also need to attach that image to mail body. So for that we need to create a  TIdAttachment object also. Here are the code details how to use TIDText.  And for this example I assume that we have already put TIDSMTP and TIDMessage component on form and also set required properties. For more information how to use TIDSMTP and TIDMessage visit my following blog. How to send Email in Delphi? lSMTP    : TIdSMTP; lMessage: TIdMessage; procedure TFormEmail.HTMLEmailSendClick(Sender: TO...