<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Example Delphi</title>
	<atom:link href="http://exampledelphi.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://exampledelphi.com</link>
	<description>Delphi Examples Collection</description>
	<pubDate>Fri, 01 Aug 2008 10:53:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Take a Property Value From Many Object with As Operator</title>
		<link>http://exampledelphi.com/delphi.php/tips-and-tricks/take-a-property-value-from-many-object-with-as-operator/</link>
		<comments>http://exampledelphi.com/delphi.php/tips-and-tricks/take-a-property-value-from-many-object-with-as-operator/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 10:53:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[As]]></category>

		<category><![CDATA[RadioButton]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/?p=45</guid>
		<description><![CDATA[&#160;
//This is how we can Take a property value from many Object with As Operator
// Form this example we need 5 RadioButton1 to RadioButton5(TRadioButton) placed on Form1
//The we make GetRadioButtonCaption Function to be called by clicking each of RadioButton
//On Click event of each TRadioButton call this GetRadioButtonCaption Function
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi">&nbsp;
<span style="color: #808080; font-style: italic;">//This is how we can Take a property value from many Object with As Operator</span>
<span style="color: #808080; font-style: italic;">// Form this example we need 5 RadioButton1 to RadioButton5(TRadioButton) placed on Form1</span>
<span style="color: #808080; font-style: italic;">//The we make GetRadioButtonCaption Function to be called by clicking each of RadioButton</span>
<span style="color: #808080; font-style: italic;">//On Click event of each TRadioButton call this GetRadioButtonCaption Function</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    <span style="color: #000000; font-weight: bold;">procedure</span> RadioButton1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> RadioButton2Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> RadioButton3Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> RadioButton4Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> RadioButton5Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #993333;">String</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Result :=<span style="color: #66cc66;">&#40;</span>Sender <span style="color: #000000; font-weight: bold;">as</span> TRadioButton<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">Caption</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">RadioButton1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Showmessage<span style="color: #66cc66;">&#40;</span>GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">RadioButton2Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
 Showmessage<span style="color: #66cc66;">&#40;</span>GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">RadioButton3Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Showmessage<span style="color: #66cc66;">&#40;</span>GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">RadioButton4Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Showmessage<span style="color: #66cc66;">&#40;</span>GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">RadioButton5Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Showmessage<span style="color: #66cc66;">&#40;</span>GetRadioButtonCaption<span style="color: #66cc66;">&#40;</span>Sender<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=45" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Other Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/system/encrypt-and-decrypt-text/" title="Encrypt and Decrypt Text">Encrypt and Decrypt Text</a></li><li><a href="http://exampledelphi.com/delphi.php/files/display-list-all-files-in-a-directory/" title="Display List All Files in a Directory">Display List All Files in a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/mouse-scroll-within-dbgrid/" title="Mouse Scroll Within DBGrid">Mouse Scroll Within DBGrid</a></li><li><a href="http://exampledelphi.com/delphi.php/windows-api/capture-desktop-screenshot-to-clipboard/" title="Capture Desktop Screenshot to Clipboard">Capture Desktop Screenshot to Clipboard</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/crop-image-with-drag-the-mouse/" title="Crop Image with Drag the Mouse">Crop Image with Drag the Mouse</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/tips-and-tricks/take-a-property-value-from-many-object-with-as-operator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open A Password Protected Access Database with TOpenDialog</title>
		<link>http://exampledelphi.com/delphi.php/tips-and-tricks/open-a-password-protected-access-database-with-topendialog/</link>
		<comments>http://exampledelphi.com/delphi.php/tips-and-tricks/open-a-password-protected-access-database-with-topendialog/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 03:34:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Database]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Access]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/?p=43</guid>
		<description><![CDATA[//This is how we can open a password protected access database with TOpenDialog
//For this example we need Button1 and Button2 (TButton), Edit1 and Edit2 (TEdit) and also AdoConnection1 (TAdoConnection)
//Button1 is used to open access database file
//Edit2 is used for access database password
//Button2 is used to open connection
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how we can open a password protected access database with TOpenDialog</span>
<span style="color: #808080; font-style: italic;">//For this example we need Button1 and Button2 (TButton), Edit1 and Edit2 (TEdit) and also AdoConnection1 (TAdoConnection)</span>
<span style="color: #808080; font-style: italic;">//Button1 is used to open access database file</span>
<span style="color: #808080; font-style: italic;">//Edit2 is used for access database password</span>
<span style="color: #808080; font-style: italic;">//Button2 is used to open connection</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, ADODB;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    Edit1: TEdit;
    ADOConnection1: TADOConnection;
    Edit2: TEdit;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button2Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">if</span> OpenDialog1.<span style="color: #006600;">Execute</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    Edit1.<span style="color: #006600;">Text</span> := OpenDialog1.<span style="color: #006600;">FileName</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button2Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
    ADOConnection1.<span style="color: #000066;">Close</span>;
    ADOConnection1.<span style="color: #006600;">ConnectionString</span> := <span style="color: #ff0000;">'Provider=Microsoft.Jet.OLEDB.4.0;Data '</span> +
      <span style="color: #ff0000;">'Source='</span>+Edit1.<span style="color: #006600;">Text</span>+<span style="color: #ff0000;">';Mode=ReadWrite;Persist '</span> +
      <span style="color: #ff0000;">'Security Info=False;Jet OLEDB:Database Password='</span>+Edit2.<span style="color: #006600;">Text</span>;
    Edit1.<span style="color: #006600;">Text</span> := OpenDialog1.<span style="color: #006600;">FileName</span>;
    <span style="color: #000000; font-weight: bold;">try</span>
      ADOConnection1.<span style="color: #006600;">Open</span>;
      <span style="color: #000000; font-weight: bold;">if</span> ADOConnection1.<span style="color: #006600;">Connected</span> = <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #000000; font-weight: bold;">then</span>
        showmessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Connected Sccessfull to '</span>+Edit1.<span style="color: #006600;">Text</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">except</span>
      showmessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Connection to '</span>+Edit1.<span style="color: #006600;">Text</span>+<span style="color: #ff0000;">' failed'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">end</span>
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=43" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/compact-and-repair-access-database/" title="Compact and Repair Access Database">Compact and Repair Access Database</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/mouse-scroll-within-dbgrid/" title="Mouse Scroll Within DBGrid">Mouse Scroll Within DBGrid</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/autosize-dbgrid/" title="Autosize DBGrid">Autosize DBGrid</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/fill-the-combobox-items-from-dataset/" title="Fill the Combobox Items from Dataset">Fill the Combobox Items from Dataset</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/tips-and-tricks/open-a-password-protected-access-database-with-topendialog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bitmap Operation for JPEG or JPG Image</title>
		<link>http://exampledelphi.com/delphi.php/files/bitmap-operation-for-jpeg-or-jpg-image/</link>
		<comments>http://exampledelphi.com/delphi.php/files/bitmap-operation-for-jpeg-or-jpg-image/#comments</comments>
		<pubDate>Mon, 12 May 2008 06:51:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Files]]></category>

		<category><![CDATA[Graphic]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Bitmap]]></category>

		<category><![CDATA[Image]]></category>

		<category><![CDATA[JPEG]]></category>

		<category><![CDATA[JPG]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/?p=42</guid>
		<description><![CDATA[//This is how we can operate any Bitmap Operation to our JPEG image
//To make a bitmap operation in JPEG Image, first we need to convert JPEG Image to bitmap
//Then run any bitmap operation on convert result bitmap
//Then assign JPEG result from operated bitmap
//For this example we use convert to grayscale bitmap operation
//Use Button1(TButton) and OpenDialog1(TOpenDialog) [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how we can operate any Bitmap Operation to our JPEG image</span>
<span style="color: #808080; font-style: italic;">//To make a bitmap operation in JPEG Image, first we need to convert JPEG Image to bitmap</span>
<span style="color: #808080; font-style: italic;">//Then run any bitmap operation on convert result bitmap</span>
<span style="color: #808080; font-style: italic;">//Then assign JPEG result from operated bitmap</span>
<span style="color: #808080; font-style: italic;">//For this example we use convert to grayscale bitmap operation</span>
<span style="color: #808080; font-style: italic;">//Use Button1(TButton) and OpenDialog1(TOpenDialog) for this example</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  jpeg;
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ConvertBitmapToGrayscale<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> Bitmap: TBitmap<span style="color: #66cc66;">&#41;</span>: TBitmap;
<span style="color: #000000; font-weight: bold;">var</span>
  i, j: <span style="color: #993333;">Integer</span>;
  Grayshade, Red, Green, Blue: <span style="color: #993333;">Byte</span>;
  PixelColor: <span style="color: #993333;">Longint</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">with</span> Bitmap <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">for</span> i := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> Width - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">for</span> j := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> Height - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
        PixelColor := ColorToRGB<span style="color: #66cc66;">&#40;</span>Canvas.<span style="color: #006600;">Pixels</span><span style="color: #66cc66;">&#91;</span>i, j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
        Red        := PixelColor;
        Green      := PixelColor <span style="color: #000000; font-weight: bold;">shr</span> <span style="color: #cc66cc;">8</span>;
        Blue       := PixelColor <span style="color: #000000; font-weight: bold;">shr</span> <span style="color: #cc66cc;">16</span>;
        Grayshade  := <span style="color: #000066;">Round</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.3</span> * Red + <span style="color: #cc66cc;">0.6</span> * Green + <span style="color: #cc66cc;">0.1</span> * Blue<span style="color: #66cc66;">&#41;</span>;
        Canvas.<span style="color: #006600;">Pixels</span><span style="color: #66cc66;">&#91;</span>i, j<span style="color: #66cc66;">&#93;</span> := RGB<span style="color: #66cc66;">&#40;</span>Grayshade, Grayshade, Grayshade<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #000000; font-weight: bold;">end</span>;
  Result := Bitmap;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> ConvertToBitmap<span style="color: #66cc66;">&#40;</span>Source : TGraphic; Bitmap : TBitmap<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
 <span style="color: #000000; font-weight: bold;">try</span>
  <span style="color: #000000; font-weight: bold;">if</span> Bitmap = <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span>
    Bitmap := TBitmap.<span style="color: #006600;">Create</span>
  <span style="color: #000000; font-weight: bold;">else</span> Bitmap.<span style="color: #006600;">FreeImage</span>;
  Bitmap.<span style="color: #006600;">Width</span> := Source.<span style="color: #006600;">Width</span>;
  Bitmap.<span style="color: #006600;">Height</span> := Source.<span style="color: #006600;">Height</span>;
  Bitmap.<span style="color: #006600;">Canvas</span>.<span style="color: #006600;">Draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,Source<span style="color: #66cc66;">&#41;</span>;
 <span style="color: #000000; font-weight: bold;">except</span>
   showmessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'No Loaded File'</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  MyJpeg,OperatedJpeg:TJPEGImage;
  MyBitmap,OperatedBitmap:TBitmap;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">if</span> OpenDialog1.<span style="color: #006600;">Execute</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    MyJpeg        := TJPEGImage.<span style="color: #006600;">Create</span>;
    MyBitmap      := TBitmap.<span style="color: #006600;">Create</span>;
    OperatedBitmap := TBitmap.<span style="color: #006600;">Create</span>;
    OperatedJpeg   :=  TJPEGImage.<span style="color: #006600;">Create</span>;
    <span style="color: #000000; font-weight: bold;">try</span>
      MyJpeg.<span style="color: #006600;">LoadFromFile</span><span style="color: #66cc66;">&#40;</span>OpenDialog1.<span style="color: #006600;">FileName</span><span style="color: #66cc66;">&#41;</span>;
      ConvertToBitmap<span style="color: #66cc66;">&#40;</span>MyJpeg,MyBitmap<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #808080; font-style: italic;">// Do any Bitmap Operation Here</span>
      <span style="color: #808080; font-style: italic;">//For Example i Convert Bitmap To GrayScale and perform result into</span>
      <span style="color: #808080; font-style: italic;">//operateBitmap</span>
      OperatedBitmap := ConvertBitmapToGrayscale<span style="color: #66cc66;">&#40;</span>MyBitmap<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #808080; font-style: italic;">//Perform operated bitmap into jpeg</span>
      OperatedJpeg.<span style="color: #006600;">Assign</span><span style="color: #66cc66;">&#40;</span>OperatedBitmap<span style="color: #66cc66;">&#41;</span>;
      OperatedJpeg.<span style="color: #006600;">SaveToFile</span><span style="color: #66cc66;">&#40;</span>OpenDialog1.<span style="color: #006600;">FileName</span>+<span style="color: #ff0000;">'-Gray.jpeg'</span><span style="color: #66cc66;">&#41;</span>;
      Showmessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Operation Completed'</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">finally</span>
      MyJpeg.<span style="color: #006600;">Free</span>;
      OperatedJpeg.<span style="color: #006600;">Free</span>;
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=42" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/crop-image-with-drag-the-mouse/" title="Crop Image with Drag the Mouse">Crop Image with Drag the Mouse</a></li><li><a href="http://exampledelphi.com/delphi.php/graphic/rotate-bitmap/" title="Rotate Bitmap">Rotate Bitmap</a></li><li><a href="http://exampledelphi.com/delphi.php/graphic/convert-bitmap-image-to-grayscale/" title="Convert Bitmap Image to Grayscale">Convert Bitmap Image to Grayscale</a></li><li><a href="http://exampledelphi.com/delphi.php/windows-api/capture-desktop-screenshot-to-clipboard/" title="Capture Desktop Screenshot to Clipboard">Capture Desktop Screenshot to Clipboard</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/files/bitmap-operation-for-jpeg-or-jpg-image/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Play a Wav Sound Without TMediaPlayer</title>
		<link>http://exampledelphi.com/delphi.php/tips-and-tricks/play-a-wav-sound-without-tmediaplayer/</link>
		<comments>http://exampledelphi.com/delphi.php/tips-and-tricks/play-a-wav-sound-without-tmediaplayer/#comments</comments>
		<pubDate>Wed, 07 May 2008 09:51:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Multimedia]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Sound]]></category>

		<category><![CDATA[Wav]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/?p=41</guid>
		<description><![CDATA[//This is we can play a WAV file without TMediaPlayer Component
//Using PlaySound Function declared in mmsystem unit
//So you must add mmsystem in uses clause
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, MPlayer, StdCtrls;
&#160;
type
  TForm1 = class&#40;TForm&#41;
    Button1: TButton;
    procedure Button1Click&#40;Sender: TObject&#41;;
  [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is we can play a WAV file without TMediaPlayer Component</span>
<span style="color: #808080; font-style: italic;">//Using PlaySound Function declared in mmsystem unit</span>
<span style="color: #808080; font-style: italic;">//So you must add mmsystem in uses clause</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, MPlayer, StdCtrls;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  mmsystem;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
   PlaySound<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">PChar</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'C:\WINDOWS\Media\Windows XP Startup.wav'</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #cc66cc;">0</span>,SND_ASYNC<span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=41" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Other Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/system/encrypt-and-decrypt-text/" title="Encrypt and Decrypt Text">Encrypt and Decrypt Text</a></li><li><a href="http://exampledelphi.com/delphi.php/system/make-application-delay/" title="Make Application Delay">Make Application Delay</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/yesnocancel-message-box-with-case-of/" title="YesNoCancel Message Box with Case of">YesNoCancel Message Box with Case of</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/how-to-get-current-memo-line-number/" title="How to Get Current Memo Line Number">How to Get Current Memo Line Number</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/parsing-the-string-or-text/" title="Parsing the String or Text">Parsing the String or Text</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/tips-and-tricks/play-a-wav-sound-without-tmediaplayer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delete a Directory</title>
		<link>http://exampledelphi.com/delphi.php/files/delete-a-directory/</link>
		<comments>http://exampledelphi.com/delphi.php/files/delete-a-directory/#comments</comments>
		<pubDate>Tue, 06 May 2008 11:52:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Files]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Windows API]]></category>

		<category><![CDATA[Directory]]></category>

		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/?p=40</guid>
		<description><![CDATA[//This is how we can delete a directory
//DelDir Function originally wrote by Rainer Kümmerle (http://www.thinklazy.de)
//Put a Button1(Tbutton) then use this code
//Make a directory named 'DeletedDir' in your application path to be tested
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&#160;
type
  TForm1 = class&#40;TForm&#41;
    Button1: TButton;
  [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how we can delete a directory</span>
<span style="color: #808080; font-style: italic;">//DelDir Function originally wrote by Rainer Kümmerle (http://www.thinklazy.de)</span>
<span style="color: #808080; font-style: italic;">//Put a Button1(Tbutton) then use this code</span>
<span style="color: #808080; font-style: italic;">//Make a directory named 'DeletedDir' in your application path to be tested</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  ShellApi;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> DelDir<span style="color: #66cc66;">&#40;</span>dir: <span style="color: #993333;">string</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #993333;">Boolean</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  fos: TSHFileOpStruct;
<span style="color: #000000; font-weight: bold;">begin</span>
  ZeroMemory<span style="color: #66cc66;">&#40;</span>@fos, <span style="color: #000066;">SizeOf</span><span style="color: #66cc66;">&#40;</span>fos<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">with</span> fos <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    wFunc  := FO_DELETE;
    fFlags := FOF_SILENT <span style="color: #000000; font-weight: bold;">or</span> FOF_NOCONFIRMATION;
    pFrom  := <span style="color: #993333;">PChar</span><span style="color: #66cc66;">&#40;</span>dir + <span style="color: #ff0000;">#<span style="color: #cc66cc;">0</span></span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
  Result := <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> = ShFileOperation<span style="color: #66cc66;">&#40;</span>fos<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  ShowMessage<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">ExtractFilePath</span><span style="color: #66cc66;">&#40;</span>Application.<span style="color: #006600;">ExeName</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">'DeletedDir'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">if</span> DelDir<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">ExtractFilePath</span><span style="color: #66cc66;">&#40;</span>Application.<span style="color: #006600;">ExeName</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">'DeletedDir'</span><span style="color: #66cc66;">&#41;</span>=<span style="color: #000000; font-weight: bold;">true</span> <span style="color: #000000; font-weight: bold;">then</span>
    ShowMessage<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">ExtractFilePath</span><span style="color: #66cc66;">&#40;</span>Application.<span style="color: #006600;">ExeName</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">'DeletedDir'</span>+<span style="color: #ff0000;">' '</span> +
      <span style="color: #ff0000;">'succesfully deleted'</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    ShowMessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Delete Failed'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=40" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/files/display-list-all-files-in-a-directory/" title="Display List All Files in a Directory">Display List All Files in a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/" title="Export Text File to Excel File">Export Text File to Excel File</a></li><li><a href="http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/" title="Export Excel File to Text File">Export Excel File to Text File</a></li><li><a href="http://exampledelphi.com/delphi.php/windows-api/capture-desktop-screenshot-to-clipboard/" title="Capture Desktop Screenshot to Clipboard">Capture Desktop Screenshot to Clipboard</a></li><li><a href="http://exampledelphi.com/delphi.php/system/check-windows-nt-or-not/" title="Check Windows NT or Not">Check Windows NT or Not</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/files/delete-a-directory/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Export Text File to Excel File</title>
		<link>http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/</link>
		<comments>http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 06:25:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Files]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Excel]]></category>

		<category><![CDATA[StringGrid]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/</guid>
		<description><![CDATA[//This is how to convert or export text file to Ms. Excel File
//SaveAsExcelFile function taken from Torry's Delphi Pages http://www.swissdelphicenter.ch/torry/
//Use button1 (Tbutton) in your Form1 then try this code
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;
&#160;
type
  TForm1 = class&#40;TForm&#41;
    Button1: TButton;
    [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how to convert or export text file to Ms. Excel File</span>
<span style="color: #808080; font-style: italic;">//SaveAsExcelFile function taken from Torry's Delphi Pages http://www.swissdelphicenter.ch/torry/</span>
<span style="color: #808080; font-style: italic;">//Use button1 (Tbutton) in your Form1 then try this code</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
    StringGridku:TStringGrid;
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  ComObj;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> RefToCell<span style="color: #66cc66;">&#40;</span>ARow, ACol: <span style="color: #993333;">Integer</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #993333;">string</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Result := <span style="color: #000066;">Chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">Ord</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span> + ACol - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #000066;">IntToStr</span><span style="color: #66cc66;">&#40;</span>ARow<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> SaveAsExcelFile<span style="color: #66cc66;">&#40;</span>AGrid: TStringGrid; ASheetName, AFileName: <span style="color: #993333;">string</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #993333;">Boolean</span>;
<span style="color: #000000; font-weight: bold;">const</span>
  xlWBATWorksheet = <span style="color: #cc66cc;">-4167</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  Row, Col: <span style="color: #993333;">Integer</span>;
  GridPrevFile: <span style="color: #993333;">string</span>;
  XLApp, Sheet, Data: OLEVariant;
  i, j: <span style="color: #993333;">Integer</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">// Prepare Data</span>
  Data := VarArrayCreate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, AGrid.<span style="color: #006600;">RowCount</span>, <span style="color: #cc66cc;">1</span>, AGrid.<span style="color: #006600;">ColCount</span><span style="color: #66cc66;">&#93;</span>, varVariant<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">for</span> i := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> AGrid.<span style="color: #006600;">ColCount</span> - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">for</span> j := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> AGrid.<span style="color: #006600;">RowCount</span> - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
      Data<span style="color: #66cc66;">&#91;</span>j + <span style="color: #cc66cc;">1</span>, i + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> := AGrid.<span style="color: #006600;">Cells</span><span style="color: #66cc66;">&#91;</span>i, j<span style="color: #66cc66;">&#93;</span>;
  <span style="color: #808080; font-style: italic;">// Create Excel-OLE Object</span>
  Result := <span style="color: #000000; font-weight: bold;">False</span>;
  XLApp := CreateOleObject<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Excel.Application'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">try</span>
    <span style="color: #808080; font-style: italic;">// Hide Excel</span>
    XLApp.<span style="color: #006600;">Visible</span> := <span style="color: #000000; font-weight: bold;">False</span>;
    <span style="color: #808080; font-style: italic;">// Add new Workbook</span>
    XLApp.<span style="color: #006600;">Workbooks</span>.<span style="color: #006600;">Add</span><span style="color: #66cc66;">&#40;</span>xlWBatWorkSheet<span style="color: #66cc66;">&#41;</span>;
    Sheet := XLApp.<span style="color: #006600;">Workbooks</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">WorkSheets</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
    Sheet.<span style="color: #006600;">Name</span> := ASheetName;
    <span style="color: #808080; font-style: italic;">// Fill up the sheet</span>
    Sheet.<span style="color: #006600;">Range</span><span style="color: #66cc66;">&#91;</span>RefToCell<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, RefToCell<span style="color: #66cc66;">&#40;</span>AGrid.<span style="color: #006600;">RowCount</span>,
      AGrid.<span style="color: #006600;">ColCount</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">Value</span> := Data;
    <span style="color: #808080; font-style: italic;">// Save Excel Worksheet</span>
    <span style="color: #000000; font-weight: bold;">try</span>
      XLApp.<span style="color: #006600;">Workbooks</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">SaveAs</span><span style="color: #66cc66;">&#40;</span>AFileName<span style="color: #66cc66;">&#41;</span>;
      Result := <span style="color: #000000; font-weight: bold;">True</span>;
    <span style="color: #000000; font-weight: bold;">except</span>
      <span style="color: #808080; font-style: italic;">// Error ?</span>
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">finally</span>
    <span style="color: #808080; font-style: italic;">// Quit Excel</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">not</span> VarIsEmpty<span style="color: #66cc66;">&#40;</span>XLApp<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">begin</span>
      XLApp.<span style="color: #006600;">DisplayAlerts</span> := <span style="color: #000000; font-weight: bold;">False</span>;
      XLApp.<span style="color: #006600;">Quit</span>;
      XLAPP := Unassigned;
      Sheet := Unassigned;
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  StringListKu:TStrings;
  i:<span style="color: #993333;">integer</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  StringGridku := TStringGrid.<span style="color: #006600;">Create</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #66cc66;">&#41;</span>;
  StringListKu := TStringList.<span style="color: #006600;">Create</span>;
  <span style="color: #000000; font-weight: bold;">try</span>
    <span style="color: #000000; font-weight: bold;">if</span> OpenDialog1.<span style="color: #006600;">Execute</span> <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">begin</span>
      StringListKu.<span style="color: #006600;">LoadFromFile</span><span style="color: #66cc66;">&#40;</span>OpenDialog1.<span style="color: #006600;">FileName</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #000000; font-weight: bold;">for</span> i := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> StringListKu.<span style="color: #006600;">Count</span> - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
        StringGridku.<span style="color: #006600;">Cells</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,i<span style="color: #66cc66;">&#93;</span> := StringListKu.<span style="color: #006600;">Strings</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>
      <span style="color: #000000; font-weight: bold;">end</span>;
      <span style="color: #000000; font-weight: bold;">if</span> SaveAsExcelFile<span style="color: #66cc66;">&#40;</span>StringGridku, <span style="color: #ff0000;">'Datakuuuu'</span>, <span style="color: #ff0000;">'c:\MyExcelFile.xls'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span>
      ShowMessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StringGrid tersimpan di c:\MyExcelFile.xls'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">finally</span>
    StringGridku.<span style="color: #006600;">Free</span>;
    StringListKu.<span style="color: #006600;">Free</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=39" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/" title="Export Excel File to Text File">Export Excel File to Text File</a></li><li><a href="http://exampledelphi.com/delphi.php/files/delete-a-directory/" title="Delete a Directory">Delete a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/delete-row-in-tstringgrid-component/" title="Delete Row in TStringGrid Component">Delete Row in TStringGrid Component</a></li><li><a href="http://exampledelphi.com/delphi.php/files/display-list-all-files-in-a-directory/" title="Display List All Files in a Directory">Display List All Files in a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/system/accept-the-dropped-files-from-windows-explorer/" title="Accept the Dropped Files From Windows Explorer">Accept the Dropped Files From Windows Explorer</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Export Excel File to Text File</title>
		<link>http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/</link>
		<comments>http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 06:17:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Files]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/</guid>
		<description><![CDATA[//This is how to convert Excel file to as text file
//ExcelSaveAsText function taken from Torry's Delphi Page http://www.swissdelphicenter.ch/torry/
//Use Button1 (TButton) and try the code
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&#160;
type
  TForm1 = class&#40;TForm&#41;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how to convert Excel file to as text file</span>
<span style="color: #808080; font-style: italic;">//ExcelSaveAsText function taken from Torry's Delphi Page http://www.swissdelphicenter.ch/torry/</span>
<span style="color: #808080; font-style: italic;">//Use Button1 (TButton) and try the code</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
    StrExcelFile:<span style="color: #993333;">String</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
ComObj;
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ExcelSaveAsText<span style="color: #66cc66;">&#40;</span>ExcelFile, <span style="color: #993333;">TextFile</span>: TFileName<span style="color: #66cc66;">&#41;</span>: <span style="color: #993333;">Boolean</span>;
<span style="color: #000000; font-weight: bold;">const</span>
  xlText = <span style="color: #cc66cc;">-4158</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  ExcelApp: OleVariant;
  vTemp1, vTemp2, vTemp3: OLEVariant;
<span style="color: #000000; font-weight: bold;">begin</span>
  Result := <span style="color: #000000; font-weight: bold;">False</span>;
  <span style="color: #000000; font-weight: bold;">try</span>
    ExcelApp := CreateOleObject<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Excel.Application'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">except</span>
    <span style="color: #808080; font-style: italic;">// Fehler beim öffnen von Excel...</span>
    <span style="color: #808080; font-style: italic;">// Error occured...</span>
    <span style="color: #000066;">Exit</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">try</span>
    ExcelApp.<span style="color: #006600;">Workbooks</span>.<span style="color: #006600;">Open</span><span style="color: #66cc66;">&#40;</span>ExcelFile<span style="color: #66cc66;">&#41;</span>;
    ExcelApp.<span style="color: #006600;">DisplayAlerts</span> := <span style="color: #000000; font-weight: bold;">False</span>;
    vTemp3 := <span style="color: #000000; font-weight: bold;">False</span>;
    vTemp2 := xlText;
    vTemp1 := <span style="color: #993333;">TextFile</span>;
    ExcelApp.<span style="color: #006600;">ActiveWorkbook</span>.<span style="color: #006600;">SaveAs</span><span style="color: #66cc66;">&#40;</span>vTemp1, vTemp2, vTemp3<span style="color: #66cc66;">&#41;</span>;
    Result := <span style="color: #000000; font-weight: bold;">True</span>;
  <span style="color: #000000; font-weight: bold;">finally</span>
    ExcelApp.<span style="color: #006600;">Quit</span>;
    ExcelApp := Unassigned;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">if</span> OpenDialog1.<span style="color: #006600;">Execute</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    StrExcelFile := OpenDialog1.<span style="color: #006600;">FileName</span>;
    ExcelSaveAsText<span style="color: #66cc66;">&#40;</span>StrExcelFile,<span style="color: #ff0000;">'C:\ExportResult.txt'</span><span style="color: #66cc66;">&#41;</span> ;
    Showmessage<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Saved as '</span>+StrExcelFile<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=38" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/" title="Export Text File to Excel File">Export Text File to Excel File</a></li><li><a href="http://exampledelphi.com/delphi.php/files/delete-a-directory/" title="Delete a Directory">Delete a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/files/display-list-all-files-in-a-directory/" title="Display List All Files in a Directory">Display List All Files in a Directory</a></li><li><a href="http://exampledelphi.com/delphi.php/system/accept-the-dropped-files-from-windows-explorer/" title="Accept the Dropped Files From Windows Explorer">Accept the Dropped Files From Windows Explorer</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/how-to-undo-in-memo/" title="How to Undo in Memo">How to Undo in Memo</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/files/export-excel-file-to-text-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Search File in A Directory and Perform Result in TListBox</title>
		<link>http://exampledelphi.com/delphi.php/files/search-file-in-a-directory-and-perform-result-in-tlistbox/</link>
		<comments>http://exampledelphi.com/delphi.php/files/search-file-in-a-directory-and-perform-result-in-tlistbox/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 02:02:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Files]]></category>

		<category><![CDATA[System]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[File]]></category>

		<category><![CDATA[ListBox]]></category>

		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/delphi.php/files/search-file-in-a-directory-and-perform-result-in-tlistbox/</guid>
		<description><![CDATA[//This is how we can search  any file in specific drive and directory by using a simple code
//Search a specific file like 'C:\Windows\zapotec.bmp'
//Search by using part of file name like '*.*' or 'filename.*' or 'partfilename*.*' or 'filename.*xe' etc
//For this example use Button1 (TButton) and ListBox (TListBox)
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how we can search  any file in specific drive and directory by using a simple code</span>
<span style="color: #808080; font-style: italic;">//Search a specific file like 'C:\Windows\zapotec.bmp'</span>
<span style="color: #808080; font-style: italic;">//Search by using part of file name like '*.*' or 'filename.*' or 'partfilename*.*' or 'filename.*xe' etc</span>
<span style="color: #808080; font-style: italic;">//For this example use Button1 (TButton) and ListBox (TListBox)</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, FileCtrl;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    ListBox1: TListBox;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  strFile :<span style="color: #993333;">String</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  strFile :=<span style="color: #ff0000;">'C:\Windows\*.*'</span>;
  <span style="color: #808080; font-style: italic;">//We can write file search string clause like '*.jpg' or 'zap*.bmp' or '*tec.*' etc</span>
  ListBox1.<span style="color: #006600;">Perform</span><span style="color: #66cc66;">&#40;</span>LB_DIR,DDL_READONLY,<span style="color: #993333;">LongInt</span><span style="color: #66cc66;">&#40;</span>@strFile<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=37" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Other Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/splash-screen-when-application-initialized/" title="Splash Screen When Application Initialized">Splash Screen When Application Initialized</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/use-system-tray-icon/" title="Use System Tray Icon">Use System Tray Icon</a></li><li><a href="http://exampledelphi.com/delphi.php/files/bitmap-operation-for-jpeg-or-jpg-image/" title="Bitmap Operation for JPEG or JPG Image">Bitmap Operation for JPEG or JPG Image</a></li><li><a href="http://exampledelphi.com/delphi.php/tips-and-tricks/compact-and-repair-access-database/" title="Compact and Repair Access Database">Compact and Repair Access Database</a></li><li><a href="http://exampledelphi.com/delphi.php/system/encrypt-and-decrypt-text/" title="Encrypt and Decrypt Text">Encrypt and Decrypt Text</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/files/search-file-in-a-directory-and-perform-result-in-tlistbox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delete Row in TStringGrid Component</title>
		<link>http://exampledelphi.com/delphi.php/tips-and-tricks/delete-row-in-tstringgrid-component/</link>
		<comments>http://exampledelphi.com/delphi.php/tips-and-tricks/delete-row-in-tstringgrid-component/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 12:00:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[VCL]]></category>

		<category><![CDATA[StringGrid]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/delphi.php/tips-and-tricks/delete-row-in-tstringgrid-component/</guid>
		<description><![CDATA[//When we work with TStringGrid Component, There is no methode for deleting row
//This is how we can Delete row in TStringGrid Component
//Just place Button1 (TButton) and StringGrid1 (TStringGrid) on the Form1 then try this code
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;
&#160;
type
  TForm1 = class&#40;TForm&#41;
   [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//When we work with TStringGrid Component, There is no methode for deleting row</span>
<span style="color: #808080; font-style: italic;">//This is how we can Delete row in TStringGrid Component</span>
<span style="color: #808080; font-style: italic;">//Just place Button1 (TButton) and StringGrid1 (TStringGrid) on the Form1 then try this code</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    StringGrid1: TStringGrid;
    Button1: TButton;
    <span style="color: #000000; font-weight: bold;">procedure</span> FormCreate<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//Procedure Below to fill StringGrid1 Cells with its coordinate self</span>
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">FormCreate</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  i,j:<span style="color: #993333;">integer</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">for</span> i := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> StringGrid1.<span style="color: #006600;">RowCount</span> <span style="color: #cc66cc;">-1</span> <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    <span style="color: #000000; font-weight: bold;">for</span> j := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> StringGrid1.<span style="color: #006600;">ColCount</span> - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">begin</span>
      StringGrid1.<span style="color: #006600;">Cells</span><span style="color: #66cc66;">&#91;</span>j,i<span style="color: #66cc66;">&#93;</span> := <span style="color: #000066;">IntToStr</span><span style="color: #66cc66;">&#40;</span>j<span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">','</span>+<span style="color: #000066;">IntToStr</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//Copy the parameterized row contains from next row</span>
<span style="color: #000000; font-weight: bold;">procedure</span> DeleteStringGridRow1<span style="color: #66cc66;">&#40;</span>AStringGrid:TStringGrid;Arow:<span style="color: #993333;">Integer</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  i,j:<span style="color: #993333;">integer</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">for</span> i := Arow <span style="color: #000000; font-weight: bold;">to</span> AStringGrid.<span style="color: #006600;">RowCount</span> - <span style="color: #cc66cc;">2</span> <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    <span style="color: #000000; font-weight: bold;">for</span> j := <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> AStringGrid.<span style="color: #006600;">ColCount</span> - <span style="color: #cc66cc;">1</span> <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">begin</span>
      AStringGrid.<span style="color: #006600;">Cells</span><span style="color: #66cc66;">&#91;</span>j,i<span style="color: #66cc66;">&#93;</span> := AStringGrid.<span style="color: #006600;">Cells</span><span style="color: #66cc66;">&#91;</span>j,i<span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #000000; font-weight: bold;">end</span>;
  <span style="color: #000000; font-weight: bold;">end</span>;
  AStringGrid.<span style="color: #006600;">RowCount</span> := AStringGrid.<span style="color: #006600;">RowCount</span><span style="color: #cc66cc;">-1</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span>
  SelectedRow:<span style="color: #993333;">integer</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">//Click to the row you want to delete</span>
  SelectedRow := StringGrid1.<span style="color: #006600;">Row</span>;
  DeleteStringGridRow1<span style="color: #66cc66;">&#40;</span>StringGrid1,SelectedRow<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=36" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/files/export-text-file-to-excel-file/" title="Export Text File to Excel File">Export Text File to Excel File</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/tips-and-tricks/delete-row-in-tstringgrid-component/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get Local IP Address</title>
		<link>http://exampledelphi.com/delphi.php/tips-and-tricks/get-local-ip-address/</link>
		<comments>http://exampledelphi.com/delphi.php/tips-and-tricks/get-local-ip-address/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 07:29:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Socket]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[IP Address]]></category>

		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://exampledelphi.com/delphi.php/tips-and-tricks/get-local-ip-address/</guid>
		<description><![CDATA[//This is how we can get IP Address from our computer
//For this example we need Button1 (TButton) and Label1 (TLabel) placed on Form1
//Add Winsock in uses clausa
//No we can obtain local computer IP Address by clicking Button1
&#160;
unit Unit1;
&#160;
interface
&#160;
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Winsock;
&#160;
type
  TForm1 = class&#40;TForm&#41;
 [...]]]></description>
			<content:encoded><![CDATA[<pre class="delphi"><span style="color: #808080; font-style: italic;">//This is how we can get IP Address from our computer</span>
<span style="color: #808080; font-style: italic;">//For this example we need Button1 (TButton) and Label1 (TLabel) placed on Form1</span>
<span style="color: #808080; font-style: italic;">//Add Winsock in uses clausa</span>
<span style="color: #808080; font-style: italic;">//No we can obtain local computer IP Address by clicking Button1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">unit</span> Unit1;
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Winsock;
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TForm1 = <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#40;</span>TForm<span style="color: #66cc66;">&#41;</span>
    Button1: TButton;
    Label1: TLabel;
    <span style="color: #000000; font-weight: bold;">procedure</span> Button1Click<span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">private</span>
    <span style="color: #808080; font-style: italic;">{ Private declarations }</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #808080; font-style: italic;">{ Public declarations }</span>
  <span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  Form1: TForm1;
&nbsp;
<span style="color: #000000; font-weight: bold;">implementation</span>
&nbsp;
<span style="color: #808080; font-style: italic;">{$R *.dfm}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">Function</span> GetIPAddress<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #993333;">String</span>;
<span style="color: #000000; font-weight: bold;">type</span>
  pu_long = ^u_long;
<span style="color: #000000; font-weight: bold;">var</span>
  varTWSAData : TWSAData;
  varPHostEnt : PHostEnt;
  varTInAddr : TInAddr;
  namebuf : <span style="color: #000000; font-weight: bold;">Array</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>..<span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#93;</span> <span style="color: #000000; font-weight: bold;">of</span> <span style="color: #993333;">char</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">If</span> WSAStartup<span style="color: #66cc66;">&#40;</span><span style="color: #9ac;">$<span style="color: #cc66cc;">101</span></span>,varTWSAData<span style="color: #66cc66;">&#41;</span> &lt;&gt; <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">Then</span>
  Result := <span style="color: #ff0000;">'No. IP Address'</span>
  <span style="color: #000000; font-weight: bold;">Else</span> <span style="color: #000000; font-weight: bold;">Begin</span>
    gethostname<span style="color: #66cc66;">&#40;</span>namebuf,<span style="color: #000066;">sizeof</span><span style="color: #66cc66;">&#40;</span>namebuf<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    varPHostEnt := gethostbyname<span style="color: #66cc66;">&#40;</span>namebuf<span style="color: #66cc66;">&#41;</span>;
    varTInAddr.<span style="color: #006600;">S_addr</span> := u_long<span style="color: #66cc66;">&#40;</span>pu_long<span style="color: #66cc66;">&#40;</span>varPHostEnt^.<span style="color: #006600;">h_addr_list</span>^<span style="color: #66cc66;">&#41;</span>^<span style="color: #66cc66;">&#41;</span>;
    Result := <span style="color: #ff0000;">'IP Address: '</span>+inet_ntoa<span style="color: #66cc66;">&#40;</span>varTInAddr<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">End</span>;
  WSACleanup;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> TForm1.<span style="color: #006600;">Button1Click</span><span style="color: #66cc66;">&#40;</span>Sender: <span style="color: #993333;">TObject</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">begin</span>
  Label1.<span style="color: #006600;">Caption</span> := GetIPAddress;
<span style="color: #000000; font-weight: bold;">end</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">end</span>.
&nbsp;</pre>
 <span class="post2pdf_span" ><a href="http://exampledelphi.com/wp-content/plugins/post2pdf/generate.php?post=35" rel="nofollow"><img src="http://exampledelphi.com/wp-content/plugins/post2pdf/icon/pdf.png" width="18px" height="16px" /></a></span><h2>Related Examples</h2><ul class="related_post"><li><a href="http://exampledelphi.com/delphi.php/socket/get-image-from-server-with-indy-socket/" title="Get Image from Server with Indy Socket">Get Image from Server with Indy Socket</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://exampledelphi.com/delphi.php/tips-and-tricks/get-local-ip-address/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
