Posts

Multi Threading in Delphi

Image
What are threads? and why we use them? Earlier days of programming all programs were single threaded and single tasking in which your program will ran exclusively on the machine  or not at all. With increasingly sophisticated applications and increasing demands on personal computers, now multiprocessing and multithreading  operating systems are available. Multithreading on computer programming was mainly required for better performance and usability. So first lets go about Process , Process is a program that runs on a system and uses system resources like CPU, Memory etc. And every process has  a main thread. In a Process many actions can be performed one by one on fast in fast perform order. And Thread is generally used to perform several  set of actions at once in situations like some actions may cause a considerable delay  but during that period the program should be able to perform other actions too. For an example in windows explorer we are copying ...

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...