<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7149314580863147047</id><updated>2024-09-01T00:07:58.466-07:00</updated><category term="Programming in Delphi"/><category term="Delphi"/><category term="Facts about Delphi"/><title type='text'>Borland Delphi</title><subtitle type='html'>Borland Delphi one of the finest technologies specially designed for Windows programming is a very powerful language of its own kind. All Delphi programmers - &quot;Welcome to the world of Delphi...&quot;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-7132145229995539444</id><published>2011-07-21T11:51:00.000-07:00</published><updated>2011-07-21T11:51:24.121-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming in Delphi"/><title type='text'>Read mouse pointer aka cursor position in Delphi!</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div closure_uid_ydc3v7=&quot;121&quot;&gt;Well this seems to a problem sometimes when someone asks us how to find where my cursor is currently located. Well why to say when we can infact show where actually is our mouse cursor at given point in time. To do this we will create a simple Delphi program as follows -&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;121&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;121&quot;&gt;&lt;strong&gt;&lt;em&gt;program Project1;&lt;br /&gt;
{$APPTYPE CONSOLE}&lt;br /&gt;
uses&lt;br /&gt;
&amp;nbsp; SysUtils, Controls, Windows;&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;126&quot;&gt;&lt;strong&gt;&lt;em&gt;var&lt;br /&gt;
&amp;nbsp; MyMouse : TMouse;&lt;br /&gt;
begin&lt;br /&gt;
&amp;nbsp; MyMouse := TMouse.Create;&lt;br /&gt;
&amp;nbsp; While True do&lt;br /&gt;
&amp;nbsp; begin&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteLn(&#39;(X, y) = (&#39; + inttostr(TPoint(MyMouse.CursorPos).x) + &#39;,&#39; + inttostr(TPoint(MyMouse.CursorPos).y) + &#39;)&#39;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sleep(300);&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
end.&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;126&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;126&quot;&gt;As we can see we create a simple Mouse cursor for ourselves in this small program and simply place it in a while loop of 300 ms to trace the current position of mouse cursor in our screen.&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;126&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_ydc3v7=&quot;126&quot;&gt;Simple isn&#39;t it?&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/7132145229995539444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/7132145229995539444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7132145229995539444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7132145229995539444'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2011/07/read-mouse-pointer-aka-cursor-position.html' title='Read mouse pointer aka cursor position in Delphi!'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-244056250367286543</id><published>2011-07-21T11:38:00.000-07:00</published><updated>2011-07-21T11:38:19.164-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming in Delphi"/><title type='text'>Limit of Recursion!</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div closure_uid_c5o876=&quot;119&quot;&gt;Recently I was going through Linked in Delphi user&#39;s group and found that few programming sections in a programming site needs examples in Delphi to demonstrate the methodology of implementing solution to a problem in various languages. On visiting the site I found that there is a need of particular example to find - Limit of Recursion as implemented in the language. This is a very interesting question as we all use recursion for implementing various solutions but we rarely care to find the actual limit to which we can implement recursion. Although most of this problems answer depends on the memory available to particular systems however we still can check this limit by implementing a very basic recursive function.&lt;/div&gt;&lt;div closure_uid_c5o876=&quot;119&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_c5o876=&quot;119&quot;&gt;The idea behind this simple program is to keep on iterating and visit nest level for a recursive function till the time we go out of memory. So the limiting condition here is the draining of the memory. A simple program like the following will demonstrate this limit -&lt;/div&gt;&lt;div closure_uid_c5o876=&quot;119&quot;&gt;&lt;div closure_uid_c5o876=&quot;128&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_c5o876=&quot;128&quot;&gt;&lt;br /&gt;
&lt;div closure_uid_c5o876=&quot;134&quot;&gt;&lt;b closure_uid_c5o876=&quot;133&quot;&gt;&lt;em&gt;unit Unit1;&lt;br /&gt;
&lt;br /&gt;
interface&lt;br /&gt;
&lt;br /&gt;
uses&lt;br /&gt;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,&lt;br /&gt;
StdCtrls;&lt;br /&gt;
&lt;br /&gt;
type&lt;br /&gt;
TForm1 = class(TForm)&lt;br /&gt;
Button1: TButton;&lt;br /&gt;
procedure Button1Click(Sender: TObject);&lt;br /&gt;
private&lt;br /&gt;
{ Private declarations }&lt;br /&gt;
public&lt;br /&gt;
{ Public declarations }&lt;br /&gt;
Level : integer;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
var&lt;br /&gt;
Form1: TForm1;&lt;br /&gt;
&lt;br /&gt;
implementation&lt;br /&gt;
&lt;br /&gt;
{$R *.DFM}&lt;br /&gt;
&lt;br /&gt;
function Recursive(Level : integer) : integer;&lt;br /&gt;
begin&lt;br /&gt;
try&lt;br /&gt;
Level := Level + 1;&lt;br /&gt;
Recursive(Level);&lt;br /&gt;
except on e: Exception do&lt;br /&gt;
Result := Level;&lt;br /&gt;
end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure TForm1.Button1Click(Sender: TObject);&lt;br /&gt;
begin&lt;br /&gt;
ShowMessage(&#39;Level = &#39; + inttostr(Level));&lt;br /&gt;
ShowMessage(&#39;Level = &#39; + inttostr(Recursive(Level)));&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
end.&lt;/em&gt;&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_c5o876=&quot;119&quot;&gt;This program takes up an integer value and tries to increment the value and call the function till StackOverflow error occurs and then simply prints this value. This implementation gave the following result on my Windows Vista 64 bit computer for integer value - 4375221. The values can differ if we take int64 instead of signed integer in the above example.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/244056250367286543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/244056250367286543' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/244056250367286543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/244056250367286543'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2011/07/limit-of-recursion.html' title='Limit of Recursion!'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-2187736482304875308</id><published>2011-07-21T11:21:00.000-07:00</published><updated>2011-07-21T11:21:07.016-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming in Delphi"/><title type='text'>Recursion in Delphi!</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;Recursion is a very generically used term in computer programming. Some problem in computer programming which allow repetition of some particular task again and again with some terminating check can be implemented very easily with the help of the concept of recursion.&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;A simplest example is to find the factorial of 5. The result is derived as -&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;5! = 5 X 4 X 3 X 2 X 1&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;5! = 120&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;This simple program can be easily designed using recursion or using recursive calls to the same function again and&amp;nbsp; again. e.g. -&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;strong&gt;fact() = fact(i) X fact(i - 1)&lt;/strong&gt;&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;The above expression at each step calls the factorial function again with one value less for variable i in each call.&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;A simple Delphi program to demonstrate the recursion concept in Delphi is as follows -&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;A button click is used to trigger the recursive function -&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_uyyprj=&quot;109&quot;&gt;&lt;strong&gt;&lt;em&gt;procedure TForm1.Button1Click(Sender: TObject);&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;strong&gt;&lt;em&gt;var&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a : integer;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;begin&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;div closure_uid_uyyprj=&quot;123&quot;&gt;&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a := fact(5);&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ShowMessage(inttostr(a));&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;end;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
and the simple recursive function is -&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;function fact(i : integer) : integer;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;begin&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i = 1) then&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; begin&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fact := 1;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; begin&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fact := i * fact(i - 1);&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;end;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
As we can see in the above example &lt;strong&gt;fact&lt;/strong&gt; function calls itself till the value of i variable reaches 1 which is the terminating condition for our recursive function and no further recursions are made.&lt;br /&gt;
&lt;br /&gt;
The result returned for above example is 120.&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/2187736482304875308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/2187736482304875308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/2187736482304875308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/2187736482304875308'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2011/07/recursion-in-delphi.html' title='Recursion in Delphi!'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-8475733927532741900</id><published>2010-10-23T06:36:00.001-07:00</published><updated>2010-10-23T06:43:27.542-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Delphi"/><title type='text'>Does multiple inheritance exists in Delphi?</title><content type='html'>Sometimes it is asked - Delphi supports multiple inheritance or not?&lt;br /&gt;&lt;br /&gt;and the answer which usually comes out is - Yes via interfaces, but the problem here is can we really say that implementing an interface actually achieves multiple inheritance in real sense or is it something else. Well the answer to this confusion is that &#39;No&#39; we cannot say that implementing an interface is a way to achieve multiple inheritance because the first promise that multiple inheritance or inheritance in itself wants is that not only the declaration but also some of the behaviour should get inherited by the child class from the parent class/classes else just by suggesting a declaration of what should be achieved by a child class can never be inheritance. It is as simple as considering the analogy a child inherits some features from both mother and father but its never that a implementation is not inherited from any of the two.&lt;br /&gt;&lt;br /&gt;Using interfaces is simply a way of allowing a boundation to the inheriting class to implement certain features so that it meets certain criteria nothing more than that. So the only language to implement multiple inheritance successfully in its real sense is C++ as of now and as per my knowledge. Delphi goes the way Java or C# tried to achieve the similar functionality via interfaces.</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/8475733927532741900/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/8475733927532741900' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/8475733927532741900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/8475733927532741900'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2010/10/does-multiple-inheritance-exists-in.html' title='Does multiple inheritance exists in Delphi?'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-9165370988670937131</id><published>2010-10-23T06:28:00.000-07:00</published><updated>2010-10-23T06:35:53.442-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Delphi"/><title type='text'>Difference between Method pointers and procedural pointers</title><content type='html'>While I was having some talk with my friends we ended up into a confusion as what exactly is the difference between the method pointers and procedureal pointers in Delphi and how it can be understood well. Well for a seasoned professional may be the answer to it is quiet easy but it took sometime before we really hit on the answer.&lt;br /&gt;&lt;br /&gt;Method pointers are basically pointers to a method which is related to a class and as it is related to a class hence Delphi does pass on the &#39;Self&#39; implicitly to the method so that the object can be referred to within the method pointed to by the method pointer. In case of a procedural pointer this &#39;Self&#39; is what is missing and hence we can&#39;t have a procedural pointer refer to a class method.&lt;br /&gt;&lt;br /&gt;This could be easily remembered the way a class method is defined -&lt;br /&gt;&lt;br /&gt;MyClass.MyProcedure;&lt;br /&gt;&lt;br /&gt;In this was we can see that we actually have MyClass which suggests that MyProcedure belongs to it. A normal procedure would be defined in this way -&lt;br /&gt;&lt;br /&gt;MyProcedure;&lt;br /&gt;&lt;br /&gt;suggesting that there is no class to which it belongs and hence no &#39;Self&#39;.</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/9165370988670937131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/9165370988670937131' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/9165370988670937131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/9165370988670937131'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2010/10/difference-between-method-pointers-and.html' title='Difference between Method pointers and procedural pointers'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-8079763656974662588</id><published>2010-06-20T01:48:00.000-07:00</published><updated>2011-07-16T13:38:12.566-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facts about Delphi"/><title type='text'>Is Application Object a window in Delphi?</title><content type='html'>Often sometimes while working in Delphi I wondered whether the Application object itself is a window or not.. and if so then where exactly is this window and why is it not visible? Going through Marco Cantu&#39;s Mastering Delphi book I found that yes infact Application object in delphi is infact a window but than this fact drove me into curiosity to just see this window visibly and hence I thought of programming a bit on this fact. Though Marco suggested that the best way to see that &quot;Application object is infact a window&quot; is to&amp;nbsp;run Delphi, select &quot;New Application&quot; which creates a new windows application and gives Form1 as a default form and then simply press the &lt;strong&gt;Run&lt;/strong&gt; button. Now on looking into the task bar we are see that&amp;nbsp;the title for our new application is getting displayed as &lt;strong&gt;Project1&lt;/strong&gt; and not&amp;nbsp;&lt;strong&gt;Form1&lt;/strong&gt; which clearly suggests that there is infact a &lt;strong&gt;hidden window&lt;/strong&gt; in our newly created windows application. This hidden window is none other than very own Application window but still if we could see the window well stretched on our desktop then it would be a better confirmation to&amp;nbsp;this fact after all to see it clearly is better than mearly realising a fact... Am I Correct? So here we go..&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;div&gt;Now to start with - first here is a bit of delphi lecture - If we will look at how TApplication has been defined in Delphi then we find that the class has been inherited from TComponent class but than on going through the class definition&amp;nbsp;we find that Application object infact allows programmer to have access to its handle value.. Handle in itself is a unique 32bit (for 32 bit systems) number that windows OS assigns to each window that will be handling any sort of windows messaging.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Once while I was going through some VC++ lessons and VB programming I once read that if we have access to the handle value fo a window we can manipulate that window to the maximum extent via the&amp;nbsp;windows API&#39;s and hence I plan here to do the same to make the &quot;Application Object&quot; show its coordinates and make itself visible... &lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;em&gt;(Please note that according to Delphi standards all the visible components etc are derived from TControl or TWinControl and not from TComponent and hence if TApplication is invisible to us then it is pretty much cool with us.. but this program is just to show that a delphi program is actually having two windows running at the same time.. one the master which is TApplication and the other is the MainForm..).&lt;/em&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Now no more&amp;nbsp;lectures and we are back to work... &lt;br /&gt;
&lt;em&gt;So here is a small program to serve our purpose -&lt;/em&gt;&lt;/div&gt;&lt;div&gt;First of all lets start Delphi and create this simple form -&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&lt;strong&gt;(Please click on the image to enlarge)&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOdy8IXc80peg4HZ8y8vkXPHsmBo0oY14-Ka35zX4DpEVl8jbaJTJH5MPgOuASoqnSkRWhm-cK2PIQh_cs6pyRwMEhBMUtIFXSxiJL4RfI8kM1lubrDTfcUPyLsDPd2IJxCLeEwQIfQ8/s1600/Form1.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5484779517333783714&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOdy8IXc80peg4HZ8y8vkXPHsmBo0oY14-Ka35zX4DpEVl8jbaJTJH5MPgOuASoqnSkRWhm-cK2PIQh_cs6pyRwMEhBMUtIFXSxiJL4RfI8kM1lubrDTfcUPyLsDPd2IJxCLeEwQIfQ8/s320/Form1.jpg&quot; style=&quot;cursor: hand; height: 231px; width: 471px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
and on the OnCreate event of the form1 we will try to display the coordinates of the form and Application object via the use of the API &lt;strong&gt;GetWindowRect&lt;/strong&gt;. The &lt;strong&gt;GetWindowRect&lt;/strong&gt; API is used to find the coordinates of a window as screen coordinates for which a handle number is known. So our API statement will look similar to something like -&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;&lt;em&gt;GetWindowRect(Form1.Handle, FormRect); for form1 and similarly GetWindowRect(Application.Handle, AppRect); for Application object window, where FormRect and AppRect are of type TRect.&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;The procedure I have written to do the following and display the same in the edit boxes in the form is as follows -&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;em&gt;procedure TForm1.RefreshRectInfo;&lt;br /&gt;
var&lt;br /&gt;
FormRect : TRect;&lt;br /&gt;
AppRect : TRect;&lt;br /&gt;
begin&lt;br /&gt;
GetWindowRect(Form1.Handle, FormRect);&lt;br /&gt;
edtTop.Text := IntToStr(FormRect.Top);&lt;br /&gt;
edtLeft.Text := IntToStr(FormRect.Left);&lt;br /&gt;
edtRight.Text := IntToStr(FormRect.Right);&lt;br /&gt;
edtBottom.Text := IntToStr(FormRect.Bottom);&lt;br /&gt;
GetWindowRect(Application.Handle, AppRect);&lt;br /&gt;
edtAppTop.Text := IntToStr(AppRect.Top);&lt;br /&gt;
edtAppLeft.Text := IntToStr(AppRect.Left);&lt;br /&gt;
edtAppRight.Text := IntToStr(AppRect.Right);&lt;br /&gt;
edtAppBottom.Text := IntToStr(AppRect.Bottom);&lt;/em&gt;&lt;/div&gt;&lt;div&gt;end;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Once the form gets opened up, the user is shown that there are infact two different handles assigned to Application and Form1 and hence suggesting that Application object would be handling different messages and is seperate from form1 though is not visible to us. Also, just check what the Application Windows Coordinates group box values are displaying. &lt;em&gt;For me these values suggested the following -&amp;gt; Top: 384, Left: 683: Right: 683 and Bottom: 384&lt;/em&gt;. What does this mean? &lt;strong&gt;&lt;em&gt;Well this mean that Application window is actually a ZERO size window on the desktop and hence we are not able to see it. &lt;/em&gt;&lt;/strong&gt;So to make it visible we will be just trying to stretch it a little bit not enough to tear it but enough to make it visible to us... :) ..&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Now, when the user clicks on the button - &quot;&lt;strong&gt;View Application Window&quot;&lt;/strong&gt; the Application window will become visible however as the form1 which is the MainForm still remains visible hence the Application window remains behind the form1 window. See the screenshot for the same below -&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;(Please click on the image to enlarge)&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb20_djoZ4m6cVaaWgknLVrWGf7w0Hu22ckoy2SINvVFBYqhl0hdvzkOwH9bwvy5sjQt-StMRrb3wc7Xz_DQ3gRsrFFOCGJKJP7pkCAiy5B49ZrPZyZnqn_O8977VFoBlV4chhiR8khfs/s1600/AppWindow.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5484783750946743634&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb20_djoZ4m6cVaaWgknLVrWGf7w0Hu22ckoy2SINvVFBYqhl0hdvzkOwH9bwvy5sjQt-StMRrb3wc7Xz_DQ3gRsrFFOCGJKJP7pkCAiy5B49ZrPZyZnqn_O8977VFoBlV4chhiR8khfs/s400/AppWindow.jpg&quot; style=&quot;cursor: hand; height: 438px; width: 680px;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb20_djoZ4m6cVaaWgknLVrWGf7w0Hu22ckoy2SINvVFBYqhl0hdvzkOwH9bwvy5sjQt-StMRrb3wc7Xz_DQ3gRsrFFOCGJKJP7pkCAiy5B49ZrPZyZnqn_O8977VFoBlV4chhiR8khfs/s1600/AppWindow.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
As you can see the values displayed in the Application Window coordinates groupbox of form1 have also changed for the Application window and the application window is getting displayed with a border though it displays a transparent client area.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
To remove the form1 window just check the checkbox Hide form1 and the application window will be displayed when the user clicks on the View Application Window button. However keep this in mind that here we can&#39;t change the actual behaviour of how delphi treats its MainForm and as we made the MainForm invisible hence the once we minimize the Application Window the MainForm will remain invisible and also the Application Window.&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;em&gt;Thus by this small exercise we have been able to show that Application window is actually a window with size Zero and is working behind the scenes.. :) ..&lt;/em&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Thats all for now.. &lt;strong&gt;&lt;em&gt;Here is the dfm code and the pas file code which I created for this application in Delphi 5.0 &lt;/em&gt;&lt;/strong&gt;-&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;DFM Code (AppWindow) -&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;em&gt;object Form1: TForm1&lt;br /&gt;
Left = 192&lt;br /&gt;
Top = 122&lt;br /&gt;
Width = 506&lt;br /&gt;
Height = 232&lt;br /&gt;
Caption = &#39;Form1&#39;&lt;br /&gt;
Color = clBtnFace&lt;br /&gt;
Font.Charset = DEFAULT_CHARSET&lt;br /&gt;
Font.Color = clWindowText&lt;br /&gt;
Font.Height = -11&lt;br /&gt;
Font.Name = &#39;MS Sans Serif&#39;&lt;br /&gt;
Font.Style = []&lt;br /&gt;
OldCreateOrder = False&lt;br /&gt;
OnCreate = FormCreate&lt;br /&gt;
PixelsPerInch = 96&lt;br /&gt;
TextHeight = 13&lt;br /&gt;
object lblAppObjHandle: TLabel&lt;br /&gt;
Left = 16&lt;br /&gt;
Top = 8&lt;br /&gt;
Width = 129&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Application Object Handle: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblFormHandle: TLabel&lt;br /&gt;
Left = 16&lt;br /&gt;
Top = 32&lt;br /&gt;
Width = 72&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Form1 Handle: &#39;&lt;br /&gt;
end&lt;br /&gt;
object edtAppObjHandle: TEdit&lt;br /&gt;
Left = 176&lt;br /&gt;
Top = 8&lt;br /&gt;
Width = 121&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 0&lt;br /&gt;
end&lt;br /&gt;
object edtFormHandle: TEdit&lt;br /&gt;
Left = 176&lt;br /&gt;
Top = 32&lt;br /&gt;
Width = 121&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 1&lt;br /&gt;
end&lt;br /&gt;
object btnViewAppWindow: TButton&lt;br /&gt;
Left = 312&lt;br /&gt;
Top = 5&lt;br /&gt;
Width = 145&lt;br /&gt;
Height = 25&lt;br /&gt;
Caption = &#39;View Application Window&#39;&lt;br /&gt;
Default = True&lt;br /&gt;
TabOrder = 2&lt;br /&gt;
OnClick = btnViewAppWindowClick&lt;br /&gt;
end&lt;br /&gt;
object gbRectCoordinates: TGroupBox&lt;br /&gt;
Left = 0&lt;br /&gt;
Top = 61&lt;br /&gt;
Width = 490&lt;br /&gt;
Height = 135&lt;br /&gt;
Align = alBottom&lt;br /&gt;
Caption = &#39;Windows Coordinates&#39;&lt;br /&gt;
TabOrder = 3&lt;br /&gt;
object gbForm1Coordinates: TGroupBox&lt;br /&gt;
Left = 2&lt;br /&gt;
Top = 15&lt;br /&gt;
Width = 239&lt;br /&gt;
Height = 118&lt;br /&gt;
Align = alLeft&lt;br /&gt;
Caption = &#39;Form1 Coordinates&#39;&lt;br /&gt;
TabOrder = 0&lt;br /&gt;
object lblTop: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 24&lt;br /&gt;
Width = 25&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Top: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblLeft: TLabel&lt;br /&gt;
Left = 9&lt;br /&gt;
Top = 47&lt;br /&gt;
Width = 24&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Left: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblRight: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 67&lt;br /&gt;
Width = 31&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Right: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblBottom: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 88&lt;br /&gt;
Width = 39&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Bottom: &#39;&lt;br /&gt;
end&lt;br /&gt;
object edtTop: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 20&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 0&lt;br /&gt;
end&lt;br /&gt;
object edtLeft: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 42&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 1&lt;br /&gt;
end&lt;br /&gt;
object edtRight: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 64&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 2&lt;br /&gt;
end&lt;br /&gt;
object edtBottom: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 86&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 3&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
object gbAppWindowCoordinates: TGroupBox&lt;br /&gt;
Left = 241&lt;br /&gt;
Top = 15&lt;br /&gt;
Width = 247&lt;br /&gt;
Height = 118&lt;br /&gt;
Align = alClient&lt;br /&gt;
Caption = &#39;Application Window Coordinates&#39;&lt;br /&gt;
TabOrder = 1&lt;br /&gt;
object lblAppTop: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 24&lt;br /&gt;
Width = 25&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Top: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblAppLeft: TLabel&lt;br /&gt;
Left = 9&lt;br /&gt;
Top = 47&lt;br /&gt;
Width = 24&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Left: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblAppRight: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 67&lt;br /&gt;
Width = 31&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Right: &#39;&lt;br /&gt;
end&lt;br /&gt;
object lblAppBottom: TLabel&lt;br /&gt;
Left = 8&lt;br /&gt;
Top = 88&lt;br /&gt;
Width = 39&lt;br /&gt;
Height = 13&lt;br /&gt;
Caption = &#39;Bottom: &#39;&lt;br /&gt;
end&lt;br /&gt;
object edtAppTop: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 20&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 0&lt;br /&gt;
end&lt;br /&gt;
object edtAppLeft: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 42&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 1&lt;br /&gt;
end&lt;br /&gt;
object edtAppRight: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 64&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 2&lt;br /&gt;
end&lt;br /&gt;
object edtAppBottom: TEdit&lt;br /&gt;
Left = 72&lt;br /&gt;
Top = 86&lt;br /&gt;
Width = 49&lt;br /&gt;
Height = 21&lt;br /&gt;
ReadOnly = True&lt;br /&gt;
TabOrder = 3&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
object cbHideForm1: TCheckBox&lt;br /&gt;
Left = 313&lt;br /&gt;
Top = 35&lt;br /&gt;
Width = 152&lt;br /&gt;
Height = 17&lt;br /&gt;
Caption = &#39;Hide Form1&#39;&lt;br /&gt;
TabOrder = 4&lt;br /&gt;
end&lt;br /&gt;
end&lt;/em&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;Pas Code -&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;unit AppWindow; &lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
interface&lt;br /&gt;
&lt;br /&gt;
uses&lt;br /&gt;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,&lt;br /&gt;
StdCtrls;&lt;br /&gt;
&lt;br /&gt;
type&lt;br /&gt;
TForm1 = class(TForm)&lt;br /&gt;
lblAppObjHandle: TLabel;&lt;br /&gt;
lblFormHandle: TLabel;&lt;br /&gt;
edtAppObjHandle: TEdit;&lt;br /&gt;
edtFormHandle: TEdit;&lt;br /&gt;
btnViewAppWindow: TButton;&lt;br /&gt;
gbRectCoordinates: TGroupBox;&lt;br /&gt;
gbForm1Coordinates: TGroupBox;&lt;br /&gt;
gbAppWindowCoordinates: TGroupBox;&lt;br /&gt;
lblTop: TLabel;&lt;br /&gt;
lblLeft: TLabel;&lt;br /&gt;
lblRight: TLabel;&lt;br /&gt;
lblBottom: TLabel;&lt;br /&gt;
edtTop: TEdit;&lt;br /&gt;
edtLeft: TEdit;&lt;br /&gt;
edtRight: TEdit;&lt;br /&gt;
edtBottom: TEdit;&lt;br /&gt;
lblAppTop: TLabel;&lt;br /&gt;
edtAppTop: TEdit;&lt;br /&gt;
lblAppLeft: TLabel;&lt;br /&gt;
edtAppLeft: TEdit;&lt;br /&gt;
lblAppRight: TLabel;&lt;br /&gt;
edtAppRight: TEdit;&lt;br /&gt;
lblAppBottom: TLabel;&lt;br /&gt;
edtAppBottom: TEdit;&lt;br /&gt;
cbHideForm1: TCheckBox;&lt;br /&gt;
procedure FormCreate(Sender: TObject);&lt;br /&gt;
procedure btnViewAppWindowClick(Sender: TObject);&lt;br /&gt;
private&lt;br /&gt;
{ Private declarations }&lt;br /&gt;
public&lt;br /&gt;
{ Public declarations }&lt;br /&gt;
procedure RefreshRectInfo;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
var&lt;br /&gt;
Form1: TForm1;&lt;br /&gt;
&lt;br /&gt;
implementation&lt;br /&gt;
&lt;br /&gt;
{$R *.DFM}&lt;br /&gt;
&lt;br /&gt;
procedure TForm1.FormCreate(Sender: TObject);&lt;br /&gt;
begin&lt;br /&gt;
edtAppObjHandle.Text := IntToStr(Application.Handle);&lt;br /&gt;
edtFormHandle.Text := IntToStr(Form1.Handle);&lt;br /&gt;
RefreshRectInfo;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure TForm1.btnViewAppWindowClick(Sender: TObject);&lt;br /&gt;
begin&lt;br /&gt;
SetWindowPos(Application.Handle, HWND_TOPMOST, 10, 10, Screen.Width - 100, Screen.Height - 100, SWP_SHOWWINDOW);&lt;br /&gt;
if cbHideForm1.Checked then&lt;br /&gt;
ShowWindow(Form1.Handle, SW_HIDE)&lt;br /&gt;
else&lt;br /&gt;
RefreshRectInfo;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure TForm1.RefreshRectInfo;&lt;br /&gt;
var&lt;br /&gt;
FormRect : TRect;&lt;br /&gt;
AppRect : TRect;&lt;br /&gt;
begin&lt;br /&gt;
GetWindowRect(Form1.Handle, FormRect);&lt;br /&gt;
edtTop.Text := IntToStr(FormRect.Top);&lt;br /&gt;
edtLeft.Text := IntToStr(FormRect.Left);&lt;br /&gt;
edtRight.Text := IntToStr(FormRect.Right);&lt;br /&gt;
edtBottom.Text := IntToStr(FormRect.Bottom);&lt;br /&gt;
GetWindowRect(Application.Handle, AppRect);&lt;br /&gt;
edtAppTop.Text := IntToStr(AppRect.Top);&lt;br /&gt;
edtAppLeft.Text := IntToStr(AppRect.Left);&lt;br /&gt;
edtAppRight.Text := IntToStr(AppRect.Right);&lt;br /&gt;
edtAppBottom.Text := IntToStr(AppRect.Bottom);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
end.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/8079763656974662588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/8079763656974662588' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/8079763656974662588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/8079763656974662588'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2010/06/is-application-object-window-in-delphi.html' title='Is Application Object a window in Delphi?'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOdy8IXc80peg4HZ8y8vkXPHsmBo0oY14-Ka35zX4DpEVl8jbaJTJH5MPgOuASoqnSkRWhm-cK2PIQh_cs6pyRwMEhBMUtIFXSxiJL4RfI8kM1lubrDTfcUPyLsDPd2IJxCLeEwQIfQ8/s72-c/Form1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-5958416703628945210</id><published>2010-01-11T08:07:00.000-08:00</published><updated>2010-01-11T08:14:59.104-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facts about Delphi"/><title type='text'>A list of popular applications created in Delphi!</title><content type='html'>Hi All,&lt;br /&gt;&lt;br /&gt;I was going through a lot of discussions in forums and other communities when the discussion turned towards the facts as how many and which popular applications have been created using the Delphi and the answer most were giving was - Skype. Though Skype is indeed a very popular product and ofcourse distributed under Freeware software category however it is not the only product that is popular and has been developed using Delphi. I went through various sites and found a list of such applications created using Delphi. Instead of presenting the same list again at this place here is the link to one such page - &lt;a href=&quot;http://delphi.wikia.com/wiki/Good_Quality_Applications_Built_With_Delphi&quot;&gt;http://delphi.wikia.com/wiki/Good_Quality_Applications_Built_With_Delphi&lt;/a&gt;&lt;br /&gt;I hope there will be many more such applications that would have been created using this excellent tool but for now above is the list.</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/5958416703628945210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/5958416703628945210' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/5958416703628945210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/5958416703628945210'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2010/01/list-of-popular-applications-created-in.html' title='A list of popular applications created in Delphi!'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-3131296031182857601</id><published>2009-05-14T06:07:00.000-07:00</published><updated>2009-05-14T06:17:39.633-07:00</updated><title type='text'>Initialization and Finalization Sections of a Unit!</title><content type='html'>&lt;strong&gt;&quot;Initialization &amp;amp; Finalization Sections - What are they?&quot;&lt;/strong&gt; - Ever heard of these names earlier while programming delphi application, must have but never bothered much about them.. Guess Right??..&lt;br /&gt;&lt;br /&gt;Yes, these two terms are the optional sections of a delphi unit, the common one being the unit header, interface section and implementaion section. However, sometimes we are in a need to perform certain tasks before any of the units code is executed, it is then that we start searching for these two optional sections.&lt;br /&gt;&lt;br /&gt;Wheneever we need to do some extra work before any other code is read we place that piece of code in the Initialization section of the unit which is then being called while the application is executed. Now, once this is done and the application needs to terminate then all the resources allocated during the Initialization section of a unit are done free in the finalization section. These two are being declared like this -&lt;br /&gt;&lt;br /&gt;&lt;em&gt;unit &lt;unit&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;interface&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;implementation&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;initialization&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{Place initialization code here}&lt;/em&gt;&lt;br /&gt;&lt;em&gt;finalization&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{Place finalization code here}&lt;/em&gt;&lt;br /&gt;&lt;em&gt;end.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;i.e. before the final end of the unit.</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/3131296031182857601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/3131296031182857601' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/3131296031182857601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/3131296031182857601'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2009/05/initialization-and-finalization.html' title='Initialization and Finalization Sections of a Unit!'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-7514813371818690399</id><published>2008-04-20T01:35:00.000-07:00</published><updated>2011-07-16T13:42:43.586-07:00</updated><title type='text'>Introduction to Dynamic Link Libraries DLLs.</title><content type='html'>Once there was a discussion between me and my friend as why DLL&#39;s are required and how to do that in Delphi. So, I thought of demonstrating a very simple program to show how simple it is to create a DLL in delphi.&lt;br /&gt;
&lt;br /&gt;
Dynamic link library or DLL is a collection of routines (i.e. small programs) that can be called by other applications and DLLs.&lt;br /&gt;
&lt;br /&gt;
Dynamic link libraries or DLLs are pieces of sharable codes that various other applications can use. These DLLs contain common code that may be required by different applications to perform similar operations. Thus allowing a single copy of routines to be used by many applications at the same time.&lt;br /&gt;
&lt;br /&gt;
Another advantage of DLLs is that we can safely use routines created in other development environments like VB, C++ to be used in delphi or vice-versa.&lt;br /&gt;
&lt;br /&gt;
Now you must be thinking as how to create a DLL in delphi. Is it really difficult or is it simple?&lt;br /&gt;
&lt;br /&gt;
Well dear developer no need to worry. Its pretty simple in delphi.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Here I will try to create a simple delphi application using a new DLL -&lt;/em&gt;&lt;br /&gt;
This example will try to do the following for us - &lt;br /&gt;
&lt;br /&gt;
First we will create a DLL that will have methods in it -&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;First will be a procedure and will display a welcome message.&lt;/li&gt;
&lt;li&gt;Second procedure will display a message dialog and will tell us when summation of numbers will start.&lt;/li&gt;
&lt;li&gt;Third procedure will also display a message dialog and will tell us when the summation is over and finally,&lt;/li&gt;
&lt;li&gt;Fourth will be a function and will actually do summation of two numbers for us and return the result back to our calling program.&lt;/li&gt;
&lt;/ul&gt;The two methods &lt;span style=&quot;font-weight: bold;&quot;&gt;&quot;Welcome&quot;&lt;/span&gt; and &lt;span style=&quot;font-weight: bold;&quot;&gt;&quot;sumnumbers&quot;&lt;/span&gt; will be called by our delphi application, remaining two are called from inside the sumnumbers function and are for our dll&#39;s internal use.&lt;br /&gt;
&lt;br /&gt;
So all set in our mind then lets create our DLL now -&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First open Delphi and select &lt;span style=&quot;font-weight: bold;&quot;&gt;File -&amp;gt; New -&amp;gt; DLL&lt;/span&gt; to create a DLL template for us. Then add Dialogs unit to uses portion of the DLL in case it is not already present (This is because I want to show a dialog box in our DLL to highlight the progress). Now, Save the project as &lt;span style=&quot;font-weight: bold;&quot;&gt;MyLibrary&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Well thats not all done, we have to do some more... &lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;But first observe the first line of our DLL. Here , we see that the keyword used is library and not program as in case of form based delphi applications. Well this is because this keyword tells that this is a DLL file and not other delphi application. So, now add the following code to the file -&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;library MyFirstDLL;&lt;br /&gt;
&lt;br /&gt;
{ Important note about DLL memory management: ShareMem must be the&lt;br /&gt;
first unit in your library&#39;s USES clause AND your project&#39;s (select&lt;br /&gt;
Project-View Source) USES clause if your DLL exports any procedures or&lt;br /&gt;
functions that pass strings as parameters or function results. This&lt;br /&gt;
applies to all strings passed to and from your DLL--even those that&lt;br /&gt;
are nested in records and classes. ShareMem is the interface unit to&lt;br /&gt;
the BORLNDMM.DLL shared memory manager, which must be deployed along&lt;br /&gt;
with your DLL. To avoid using BORLNDMM.DLL, pass string information&lt;br /&gt;
using PChar or ShortString parameters. }&lt;br /&gt;
&lt;br /&gt;
uses&lt;br /&gt;
SysUtils,&lt;br /&gt;
Classes,&lt;br /&gt;
Dialogs;&lt;br /&gt;
&lt;br /&gt;
{$R *.RES}&lt;br /&gt;
&lt;br /&gt;
procedure Welcome(); export;&lt;br /&gt;
begin&lt;br /&gt;
ShowMessage(&#39;Welcome to MyLibrary DLL. You are about to view a DLL demo.&#39;);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure firstmsg();&lt;br /&gt;
begin&lt;br /&gt;
ShowMessage(&#39;Summation is about to start. Please wait&#39;);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure lastmsg();&lt;br /&gt;
begin&lt;br /&gt;
ShowMessage(&#39;Summation complete. Thanks for using DLL&#39;);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
// This function will sum two numbers and display result&lt;br /&gt;
function sumnumbers(first, second : integer): integer; export;&lt;br /&gt;
var&lt;br /&gt;
sum : integer;&lt;br /&gt;
begin&lt;br /&gt;
firstmsg();&lt;br /&gt;
sum := first + second;&lt;br /&gt;
lastmsg();&lt;br /&gt;
Result := sum; // Sending the output back to calling application&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
exports Welcome, sumnumbers;&lt;br /&gt;
&lt;br /&gt;
begin&lt;br /&gt;
end.&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;Save the project as &lt;span style=&quot;font-weight: bold;&quot;&gt;MyFirstDll&lt;/span&gt;. Now compile the DLL project by pressing &lt;span style=&quot;font-weight: bold;&quot;&gt;Ctrl + F9&lt;/span&gt;. On compilation a dll file will be created for us in the destination folder (where we saved the project named MyFirstDLL.). So, our dll file is created and the name is - &lt;span style=&quot;font-weight: bold;&quot;&gt;MyFirstDLL.dll&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Now close the project and open a new delphi application by selecting &lt;span style=&quot;font-weight: bold;&quot;&gt;File -&amp;gt; New Application &lt;/span&gt;from the main menu. Now add three edit boxes and a button on the form (Hey, I leave the GUI design for you.. :).. ). Now add the following code to your application and save the application (in the same location where we saved our &lt;span style=&quot;font-weight: bold;&quot;&gt;MyFirstDLL.dll&lt;/span&gt; application) and the unit as &lt;span style=&quot;font-weight: bold;&quot;&gt;FirstDLLPrj&lt;/span&gt; and &lt;span style=&quot;font-weight: bold;&quot;&gt;FirstDLL&lt;/span&gt; respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;unit FirstDLL;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;interface&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;uses&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;StdCtrls;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;type&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;TForm1 = class(TForm)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit1: TEdit;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit2: TEdit;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit3: TEdit;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Button1: TButton;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure FormCreate(Sender: TObject);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure Button1Click(Sender: TObject);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;{ Private declarations }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;public&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;{ Public declarations }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;end;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;var&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Form1: TForm1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure Welcome; external &#39;MyFirstDLL.dll&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;function sumnumbers (a, b :integer) : integer; external &#39;MyFirstDll.dll&#39;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;implementation&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;{$R *.DFM}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure TForm1.FormCreate(Sender: TObject);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Welcome;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit1.text := &#39;&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit2.text := &#39;&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit3.text := &#39;&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;end;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure TForm1.Button1Click(Sender: TObject);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Edit3.Text := inttostr (sumnumbers(strtoint(Edit1.Text), strtoint(Edit2.Text)));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;end;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;end.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;Now all done then we are ready to compile our application. Hey, what are you waiting for press Ctrl F9 and now run the application and Bingo here is our first DLL application created.&lt;br /&gt;
&lt;br /&gt;
Simple isn&#39;t it?&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Hey, I know what you are thinking now. You must be thinking, &quot;hey hello!! what happened in the above code actually?&quot;&lt;br /&gt;
&lt;br /&gt;
So no need to panic, I will explain what has actually happened above.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
First while creating the DLL we did the following - we created two methods &lt;span style=&quot;font-weight: bold;&quot;&gt;(procedure Welcome and function sumnumbers)&lt;/span&gt; that we wanted to be used by other applications (These are the common routines that are exported.).&lt;br /&gt;
&lt;br /&gt;
Now to make a procedure or function external i.e. to be used by other applications we have to tag them with &lt;span style=&quot;font-weight: bold;&quot;&gt;export&lt;/span&gt; keyword in there definition (see use of &lt;span style=&quot;font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;font-weight: bold;&quot;&gt;keyword &lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/span&gt;against the procedure &lt;span style=&quot;font-weight: bold;&quot;&gt;Welcome&lt;/span&gt; and also against function &lt;span style=&quot;font-weight: bold;&quot;&gt;sumnumbers&lt;/span&gt; in code above). The keyword &lt;span style=&quot;font-weight: bold;&quot;&gt;export &lt;/span&gt;will tell that the following procedure or function is exportable i.e. could be referenced by outside applications.&lt;br /&gt;
&lt;br /&gt;
The other two procedures &lt;span style=&quot;font-weight: bold;&quot;&gt;firstmsg&lt;/span&gt; and &lt;span style=&quot;font-weight: bold;&quot;&gt;lastmsg&lt;/span&gt; are for internal purpose (i.e. within our dll and cannot be refered by outside applications) and hence are not tagged with the keywords &lt;span style=&quot;font-weight: bold;&quot;&gt;export&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Finally, to let the compiler know which all are the functions and procedures that are being exported by the DLL we will define the list with &lt;span style=&quot;font-weight: bold;&quot;&gt;exports&lt;/span&gt; keyword (see our dll code above) -&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;exports Welcome, sumnumbers;&lt;/span&gt;So, that&#39;s all what was required to write a DLL code.&lt;br /&gt;
&lt;br /&gt;
Now coming to the calling application that will actually use this dll and its routines.&lt;br /&gt;
&lt;br /&gt;
To use the DLL routines in our code we have to declare the procedures and functions so that the compiler could find the entry points to these routines. This we did by writing the following code in our calling application -&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;procedure Welcome; external &#39;MyFirstDLL.dll&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;function sumnumbers (a, b :integer) : integer; external &#39;MyFirstDll.dll&#39;&lt;/span&gt;Above statements have the following portions, (carefully observe these) - first is the name of the procedure as defined in the DLL, then the keyword &lt;span style=&quot;font-weight: bold;&quot;&gt;external&lt;/span&gt; telling that the procedure/function is an external function and finally defining the dll file name where the procedure is actually located.&lt;br /&gt;
&lt;br /&gt;
We have used the name of the dll file in our code as the dll was located in the same folder where our calling program is located otherwise we would have to specify the complete path name to access the dll because if the dll won&#39;t be located in the same folder we will get an entry point error while running the application.&lt;br /&gt;
&lt;br /&gt;
The entry point error tells that the compiler is not able to find the function or procedure specified in the calling program and so is not able to attach it to our application and execute the routine.&lt;br /&gt;
&lt;br /&gt;
Rest we come to calling and invoking the procedure or function, this is done in the same way as is done for normal procedures and functions in a delphi application. Here it could be noted that we didn&#39;t use any special method for invoking the procedures in our code because the dll functions and procedures are now a part of our application.&lt;br /&gt;
&lt;br /&gt;
So, thats it for now. We have finally created our DLL. Now, Enjoy writing more DLL&#39;s... My job is done... Astalavista till next article.&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/7514813371818690399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/7514813371818690399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7514813371818690399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7514813371818690399'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2008/04/introduction-to-dynamic-link-libraries.html' title='Introduction to Dynamic Link Libraries DLLs.'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7149314580863147047.post-7821776211164411885</id><published>2008-04-13T06:54:00.000-07:00</published><updated>2008-04-13T07:22:47.355-07:00</updated><title type='text'>Can Objects be assigned to a TStringList?</title><content type='html'>Well if someone asks that can we store an object in a TStringlist or should we use only TList for this purpose, the answer should be ----&gt; Yes ofcourse!.&lt;br /&gt;&lt;br /&gt;Now how to do that and where can I use such facility. Now first to answer why should we require this feature if at all. One place where we can use such a feature is when we are required to save or associate an object to a particular name, like saving a location name with the corresponding bitmap.&lt;br /&gt;&lt;br /&gt;Now coming to how to do that in delphi. The answer is using the Objects property associated with TStringlist. Delphi gives the power of associating objects to tstringlist using this simple property.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Please see the below example to see how to do that -&lt;br /&gt;&lt;br /&gt;Here in this example add a button to a simple delphi form. Now add two edit texts and add a TMemo component. Now write the following code on the button click event -&lt;br /&gt;&lt;br /&gt;procedure TForm1.Button2Click(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;  mystringlist : tstringlist;&lt;br /&gt;begin&lt;br /&gt;  Memo1.clear;&lt;br /&gt;  mystringlist := tstringlist.create();&lt;br /&gt;  mystringlist.Add(edit1.text);&lt;br /&gt;  mystringlist.Objects[0] := edit1;&lt;br /&gt;  mystringlist.Add(edit2.text);&lt;br /&gt;  mystringlist.objects[1] := edit2;&lt;br /&gt;  memo1.Lines.Add(TEdit(mystringlist.objects[0]).name);&lt;br /&gt;  memo1.Lines.Add(TEdit(mystringlist.objects[1]).name);&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;Run the delphi program by pressing F9 key or navigating to &quot;Run&quot; Menu and clicking on &quot;Run&quot; Menu item.&lt;br /&gt;&lt;br /&gt;Now click on the button on the form and you will see that memo displays two strings edit1 and edit2. Here the names have been derieved from the objects stored in the stringlist.&lt;br /&gt;&lt;br /&gt;This was just a demonstration program and the power of such a feature can be easily utilized in performing complex tasks.</content><link rel='replies' type='application/atom+xml' href='http://neo-delphi.blogspot.com/feeds/7821776211164411885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7149314580863147047/7821776211164411885' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7821776211164411885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7149314580863147047/posts/default/7821776211164411885'/><link rel='alternate' type='text/html' href='http://neo-delphi.blogspot.com/2008/04/can-objects-be-assigned-to-tstringlist.html' title='Can Objects be assigned to a TStringList?'/><author><name>Neo</name><uri>http://www.blogger.com/profile/14411612301710790630</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih5eFHd3lIHV1CYT5PPrEZgjHIVHUiD-8tfIbAefa1dzIsRz12qFqKxr9c1fc05q0yROrcIR_RpspnqUF24fTuEnwtjXlS5DUglz95eE9W6iitEczavDBjAKf6TK6mfj8/s220/23022008758.jpg'/></author><thr:total>1</thr:total></entry></feed>