tag:blogger.com,1999:blog-66012782518222395322024-02-19T21:20:00.487-08:00Delphi Tips and TricksUnknownnoreply@blogger.comBlogger16125tag:blogger.com,1999:blog-6601278251822239532.post-56494363635637577682012-04-17T20:17:00.005-07:002012-04-19T09:52:45.029-07:00Speed up Delphi 7 loading time<span style="font-size: large;">My Delphi 7 loading time is so slow, about 1.30 minute. I know that's to slow, but i am using netbook with AMD E-350 processor. Googling around how to speed it up, and found this wonderful app that can speed up Delphi 7 loading time. And now i can get into my delphi for only 25 seconds!!! wow... I love this apps.... It's called <a href="http://andy.jgknet.de/blog/ide-tools/delphispeedup/" style="background-color: white; color: blue;" target="_blank">DelphiSpeedUp 3.1</a><span style="background-color: white; color: blue;">.</span> and it's free, You should check it out. And compiling time is faster too, once my compile time it's about 25 seconds and now after installing it, it took only 16 seconds.</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-27365371338113465222012-04-15T23:33:00.000-07:002012-04-15T23:34:29.926-07:00Fix Illegal character in input file when installing JEDI 3.45<div style="text-align: center;">
<b>Fix Illegal character in input file when installing JEDI 3.45 for Delphi 7. </b></div>
<br />
<u>Error Messages :</u><br />
jvcl\run\JvPageSetup.pas(1) Error: Illegal character in input file: 'ï' ($EF)<br />
JvDlgs.dpk(86) Fatal: Could not compile used unit '..\..\run\JvPageSetup.pas'<br />
<br />
jvcl\run\JvDialogs.pas(1) Error: Illegal character in input file: 'ï' ($EF)<br />
JvDlgs.dpk(86) Fatal: Could not compile used unit '..\..\run\JvDialogs.pas'<br />
<br />
<u>How to fix :</u><br />
Open the JvPageSetup.pas and JvDialogs.pas using <a href="http://notepad-plus-plus.org/download" target="_blank">Notepad++</a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJYUSz4U_C6kqY8beJzRspGEpxBqaitj18mgH2vMNxpS2y1KGvPkm21JPgLZ4GN7flTdejxxi7TEZbNw8_topFmJVinyekcQEb7z5tZTrUutvGEy_it3CYHEwylKeGU0opTHNMY3tLKk8/s1600/JVCL+Error.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJYUSz4U_C6kqY8beJzRspGEpxBqaitj18mgH2vMNxpS2y1KGvPkm21JPgLZ4GN7flTdejxxi7TEZbNw8_topFmJVinyekcQEb7z5tZTrUutvGEy_it3CYHEwylKeGU0opTHNMY3tLKk8/s320/JVCL+Error.JPG" width="320" /></a></div>
<br />
and change the encoding from UTF-8 into ANSI for both files, save them. And run the install.bat again. Now your installation won't give any error message and successful.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-11407695397730923852012-04-15T21:44:00.002-07:002012-04-15T21:45:25.426-07:00Fix Delphi 7 WinHelp<div style="text-align: center;">
<span style="font-size: small;"><b>When you are installing Delphi 7 on Windows 7, the Help system inside Delphi 7 is not working. And this is the solution to fix it.</b></span></div>
<br />
1. Go to Microsoft website to get the MS Update Fix.<br />
here is the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=258aa5ec-e3d9-4228-8844-008e02b32a2c&displaylang=en&Hash=bc0nbVsZtNC%2fmhn01kruqtQFvzTcZdJbiAv3sSo%2f3mMWvi745uR0cMVQ8NwBr4pqCp9P2irmOyAGcEh1cL333w%3d%3d#filelist" target="_blank">MS Update Fix for Winhelp<br /></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbTyExQQpDT1pmAkMhZs2f98dssNUakeWwEeKAVHr37Xf-r3noCQHQXxR034lLePKv3J6lIqDJ2tMcNo2DylEd8ons4IshHZXNzS5oc-YP9ZIvd2x6Jd-bJRxjxDDZ47_R3QDVlCoTeWM/s1600/Delphi7-12.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbTyExQQpDT1pmAkMhZs2f98dssNUakeWwEeKAVHr37Xf-r3noCQHQXxR034lLePKv3J6lIqDJ2tMcNo2DylEd8ons4IshHZXNzS5oc-YP9ZIvd2x6Jd-bJRxjxDDZ47_R3QDVlCoTeWM/s320/Delphi7-12.JPG" width="320" /></a></div>
<br />
2. Download the update, and run it, start Delphi 7, and voila the Delphi 7 Help system is working now...<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmFy4VYx7O3m9zg2kVvm0peNSxiXF7lio_cEOVAxNtYV57FIs6Le8DLeDHjpPu_g3x7zPO_K3eq7WNGxAp2mxCICjthwMZeq_sV1SSpkaJ0XDvJMkzfOM_VxTuj6YMOCyo70Irb-kAaUk/s1600/Delphi7-15.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmFy4VYx7O3m9zg2kVvm0peNSxiXF7lio_cEOVAxNtYV57FIs6Le8DLeDHjpPu_g3x7zPO_K3eq7WNGxAp2mxCICjthwMZeq_sV1SSpkaJ0XDvJMkzfOM_VxTuj6YMOCyo70Irb-kAaUk/s320/Delphi7-15.JPG" width="320" /></a></div>
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-12342166328736543412012-04-15T21:32:00.001-07:002012-04-15T21:51:45.623-07:00Installing Delphi 7 on Windows 7<div style="text-align: center;">
<b><span style="font-size: large;">If you still love to developing with Delphi 7 and you're using Windows 7. Here's the tricks on how to install it.</span></b></div>
<br />
1. Make sure you run the install.exe as Administrator.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuf9V7luT2gk0BgV54nUrFtWExjbUNnFvdCYzJ-sF94_Bgh489jkubku-40x_By_hsUpt9lVIOR1UeBtXa9Ec9gG38KLOxH8eN4IRVbkmqdXYK0J28_nEmEnOFpsotgKFrdDYXO7_PBhE/s1600/Delphi7-01.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuf9V7luT2gk0BgV54nUrFtWExjbUNnFvdCYzJ-sF94_Bgh489jkubku-40x_By_hsUpt9lVIOR1UeBtXa9Ec9gG38KLOxH8eN4IRVbkmqdXYK0J28_nEmEnOFpsotgKFrdDYXO7_PBhE/s1600/Delphi7-01.JPG" /></a></div>
2. Ignore the compatibility issue and run the program.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtMnZVUhkaamv9ARdj2oxYIHTpwA8c7piFjWXVncE6kIrKrs8ZVJwkNZyJXAMNqNU3rvW4C3ySgdoDAkLGFKtez1OvfxwnLWniknTlPBn27ihdKkxl5KAtykt-nF7P8hE-GrjoTzL2cfY/s1600/Delphi7-02.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtMnZVUhkaamv9ARdj2oxYIHTpwA8c7piFjWXVncE6kIrKrs8ZVJwkNZyJXAMNqNU3rvW4C3ySgdoDAkLGFKtez1OvfxwnLWniknTlPBn27ihdKkxl5KAtykt-nF7P8hE-GrjoTzL2cfY/s320/Delphi7-02.JPG" width="320" /></a></div>
3. Install Delphi 7, by click on it.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifz0ykdphuojKcPF6mq0IdhdkyoJnn58VRHu-lyJ9beo5bw5REupZwvRjkxJVR5fdiMdr2qt9IAuBO4cmg5o2iMIJ-u5gs5CMOChkag1NqtxXYDa8MsB8lrvtUjjIQY-klSye1SXot2KE/s1600/Delphi7-03.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifz0ykdphuojKcPF6mq0IdhdkyoJnn58VRHu-lyJ9beo5bw5REupZwvRjkxJVR5fdiMdr2qt9IAuBO4cmg5o2iMIJ-u5gs5CMOChkag1NqtxXYDa8MsB8lrvtUjjIQY-klSye1SXot2KE/s320/Delphi7-03.JPG" width="320" /></a></div>
4. After installation finishes, don't run Delphi yet.<br />
Because it will pop an error message like this. And it will pop the error message whenever you want to start a new application.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAa9eGH_LVd8CHejri8qwPoF44j1XHhyphenhyphenW87zYvh-1U-wOPJ19n7EtOS-uV-ng5mcuQDuQTBegXqxYH_KmbKK0ifcGGvTHkTeUoZqIbex7i4P7l7tSJCWqRsCM-d5t7dBPl5N4RUgx4lDw/s1600/Delphi7-05.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="73" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAa9eGH_LVd8CHejri8qwPoF44j1XHhyphenhyphenW87zYvh-1U-wOPJ19n7EtOS-uV-ng5mcuQDuQTBegXqxYH_KmbKK0ifcGGvTHkTeUoZqIbex7i4P7l7tSJCWqRsCM-d5t7dBPl5N4RUgx4lDw/s320/Delphi7-05.JPG" width="320" /></a></div>
5. Now go to C:\Program Files (x86)\Borland\ (assuming you are using Win7 64bit)<br />
And right click on Delphi 7 Folder, choose Properties. Uncheck Read-only Checkbox and click apply.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6O3rNv6sRCrFFkgMI13S-C1gF2GAlKhbvsxyXOO8hWiI35by6OnSIrO9FUdRQROrNIvr6vhuT0vqFfUGEpTDnlUunY1EYT7lOMumLt9Zbhf3hn2gKH0iqHO0yKJcw0CKZapSodSeONyI/s1600/Delphi7-06.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6O3rNv6sRCrFFkgMI13S-C1gF2GAlKhbvsxyXOO8hWiI35by6OnSIrO9FUdRQROrNIvr6vhuT0vqFfUGEpTDnlUunY1EYT7lOMumLt9Zbhf3hn2gKH0iqHO0yKJcw0CKZapSodSeONyI/s320/Delphi7-06.JPG" width="215" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
6. Next, click the Security Tab, click on Users, and click Edit button to change the permission for user to allow full access...</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvQNpgKuFZTUNi4mK3h8l4flt16DaduYYOBrpfVXr2vBngwL88l8x07fEV7_8zWxuRmfPfeI3Sb2O5EZUMKIETPHToQDbKLks3bdEqDwgYdWvwUL7ge7xp4vbdv4mZLnUuo3ltCTcDJcw/s1600/Delphi7-11.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvQNpgKuFZTUNi4mK3h8l4flt16DaduYYOBrpfVXr2vBngwL88l8x07fEV7_8zWxuRmfPfeI3Sb2O5EZUMKIETPHToQDbKLks3bdEqDwgYdWvwUL7ge7xp4vbdv4mZLnUuo3ltCTcDJcw/s320/Delphi7-11.JPG" width="264" /></a></div>
check the Full Control and Modify checkbox, and click the Apply button.<br />
<br />
7. Click OK button, to close it. And you can run the Delphi 7.<br />
If Delphi 7 still pop up the Incompatibility Issue message, Just click the Don't show this message again checkbox and run the program.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyikygeL7JLFA-_xhSVolLEvAADIEPMOdTcgZH33ByDGzplARQ6PiZMmGjJVyfnUHs5-_S7rw3su0Pvx3Q4assBjPRt5Qd_KABomfncfczVMQOkXKvpgswJo31hEADp2F6o9Yk7PiKnPU/s1600/Delphi7-04.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyikygeL7JLFA-_xhSVolLEvAADIEPMOdTcgZH33ByDGzplARQ6PiZMmGjJVyfnUHs5-_S7rw3su0Pvx3Q4assBjPRt5Qd_KABomfncfczVMQOkXKvpgswJo31hEADp2F6o9Yk7PiKnPU/s320/Delphi7-04.JPG" width="320" /></a></div>
<br />
The installation of Delphi 7 is now finished.<br />
<br />
If you are having trouble of using Delphi 7 Winhelp. Please read next solution to fix<a href="http://delphitipsandtricks2.blogspot.com/2012/04/fix-delphi-7-winhelp.html"> delphi 7 help system</a>.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-49583720034923524962012-04-12T21:50:00.003-07:002012-04-15T23:39:19.353-07:00Hide flickering MDI Child Creation<div style="color: lime;">
// To hide annoying flickering MDI Child creation</div>
<br />
<span style="color: blue;">try</span><br />
SendMessage(Application.MainForm.ClientHandle,WM_SETREDRAW,0,0);<br />
FormChild:=TBaseChildForm.Create(application);<br />
FormChild.Caption:='Form '+IntToStr(n);<br />
FormChild.Show;<br />
<span style="color: blue;">finally</span><br />
SendMessage(Application.MainForm.ClientHandle,WM_SETREDRAW,1,0);<br />
RedrawWindow(Application.MainForm.ClientHandle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_NOINTERNALPAINT);<br />
<span style="color: blue;">end;</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-85591596922199604962012-04-08T18:07:00.000-07:002012-04-09T00:31:56.416-07:00Parse String with Delimiter into String List<span style="color: lime;">// Parse String with Delimiter into String List</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG5-OrRHWyLwWcUk_BcQQVmudCBSgx7U_-SW29GTUehkQxVCzFSvBRo9eYpl1N6BA1NDgzDH2JLQJ2Iazg32-xiOqakXg0kFk7YOynSjAKd5aRc_A842eqjQrQfi8Z68f4a_RAC51H4yQ/s1600/ParseString.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="260" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG5-OrRHWyLwWcUk_BcQQVmudCBSgx7U_-SW29GTUehkQxVCzFSvBRo9eYpl1N6BA1NDgzDH2JLQJ2Iazg32-xiOqakXg0kFk7YOynSjAKd5aRc_A842eqjQrQfi8Z68f4a_RAC51H4yQ/s400/ParseString.JPG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: lime;">// Screenshot of running sample application</span></div>
<br />
<span style="color: blue;">procedure</span> TForm1.btnParseClick(Sender: TObject);<br />
<span style="color: blue;">begin</span><br />
ParseDelimited(Memo1.lines, edit1.text, edit2.text);<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">procedure</span> TForm1.Edit1Change(Sender: TObject);<br />
<span style="color: blue;">begin</span><br />
edit3.Text:=Edit1.Text+Edit2.Text;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">procedure</span> TForm1.ParseDelimited(const sl: TStrings; const value:string,<br />
delimiter: string);<br />
<span style="color: lime;">// Originally from : http://delphi.about.com/od/adptips2005/qt/parsedelimited.htm</span><br />
<span style="color: lime;">// Tweak a bit by me, to be more understand to read</span><br />
<span style="color: lime;">// to use it in your own program don't forget to remove all "memo2.lines" Lines. </span><br />
<span style="color: blue;">var</span><br />
nPosDeli : integer;<br />
sGet : string;<br />
sProcess : string;<br />
nLenDeli : integer;<br />
<span style="color: blue;">begin</span><br />
nLenDeli := Length(delimiter) ;<br />
sProcess := value + delimiter;<br />
sl.BeginUpdate;<br />
sl.Clear;<br />
memo2.lines.clear; <br />
try<br />
while Length(sProcess) > 0 do<br />
begin<br />
memo2.Lines.Add('[sProcess] : '+sProcess);<br />
memo2.Lines.Add('Length(sProcess) : '+IntToStr(Length(sProcess)));<br />
nPosDeli := Pos(delimiter, sProcess) ;<br />
memo2.Lines.Add('Pos(delimiter, sProcess) [nPosDeli] : '+IntToStr(nPosDeli));<br />
sGet := Copy(sProcess,0,nPosDeli-1) ;<br />
memo2.Lines.Add('Copy(sProcess,0,nPosDeli-1) [sGet] : '+sGet);<br />
sl.Add(sGet) ;<br />
sProcess := Copy(sProcess,nPosDeli+nLenDeli,MaxInt) ;<br />
memo2.Lines.Add('Copy(sProcess,nPosDeli+nLenDeli,MaxInt) [sProcess]: '+sProcess);<br />
memo2.Lines.Add(' ');<br />
end;<br />
finally<br />
sl.EndUpdate;<br />
end;<br />
<span style="color: blue;">end;</span><br />
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-27829452690717054672012-04-01T02:27:00.003-07:002012-04-01T02:28:42.307-07:00Put Application on Windows Startup<div style="color: lime;">
{You can Drag and Drop your Application to Windows Startup Group to make it start automatically whenever Windows Startup. Or you can programmatically put it in code using Delphi.}</div>
<br />
<span style="color: lime;">// *********************************************** // </span><br />
<span style="color: blue;">procedure </span>RunOnStartup(sProgTitle : string; <br />
sCmdLine: string; <br />
bRunOnce: boolean; <br />
bRemove: boolean) ;<br />
<span style="color: lime;">// *********************************************** // </span> <br />
<span style="color: blue;">var</span><br />
sKey: string;<br />
Section: string;<br />
<br />
<span style="color: blue;">begin</span><br />
if (bRunOnce) then<br />
sKey := 'Once'<br />
else<br />
sKey := '';<br />
<br />
Section := 'Software\Microsoft\Windows\CurrentVersion\Run' + sKey + #0;<br />
<br />
with TRegIniFile.Create('') do<br />
try<br />
RootKey := HKEY_LOCAL_MACHINE;<br />
if bRemove then<br />
DeleteKey(Section, sProgTitle)<br />
else<br />
WriteString(Section, sProgTitle, sCmdLine) ;<br />
finally<br />
Free;<br />
end;<br />
<span style="color: blue;"> end;</span><br />
<br />
<span style="color: lime;"> {</span><br />
<span style="color: lime;">Parameter Description:</span><br />
<span style="color: lime;"> sProgTitle:</span><br />
<span style="color: lime;"> Name of your program. </span><br />
<span style="color: lime;"> sCmdLine:</span><br />
<span style="color: lime;"> This is the full path name to your program. </span><br />
<span style="color: lime;"> bRunOnce:</span><br />
<span style="color: lime;"> True to run the application once, such as intalling first time application. </span><br />
<span style="color: lime;"> False to run the application everytime windows startup.</span><br />
<span style="color: lime;"> bRemove:</span><br />
<span style="color: lime;"> True to remove startup key.</span><br />
<br />
<span style="color: lime;">How to use:</span><br />
<span style="color: lime;">RunOnStartup( </span><br />
<span style="color: lime;"> 'MyCalculator',</span><br />
<span style="color: lime;"> 'My Own Calculator', </span><br />
<span style="color: lime;"> 'MyCalc.exe', </span><br />
<span style="color: lime;"> False );</span><br />
<span style="color: lime;">}</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-76488922037506959232012-03-28T13:03:00.005-07:002012-03-28T13:03:51.491-07:00Scrolling Window Caption Bar Title<div style="color: lime;">
// Scrolling Window Caption Bar Title</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEZ9OgZFKJQxfOxhW154SbCkhs-3W-YeBMH0dw2KjrDpcO9-cQhBavFqQiL5zg8KZ9U6Lg-0JO_9j5m_JcrrTnKYLi19UoHWp7pjQGuVTBt5owUv98uwFqVSh_pI9KmzPxdhyvD2nA-nQ/s1600/Scrolling01.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="102" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEZ9OgZFKJQxfOxhW154SbCkhs-3W-YeBMH0dw2KjrDpcO9-cQhBavFqQiL5zg8KZ9U6Lg-0JO_9j5m_JcrrTnKYLi19UoHWp7pjQGuVTBt5owUv98uwFqVSh_pI9KmzPxdhyvD2nA-nQ/s320/Scrolling01.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<span style="color: lime;">// Screen shot of running application</span></div>
<br /><span style="color: lime;">// dfm</span><br /><span style="color: blue;">object</span> Form1: TForm1<br /> Caption = 'Scrolling Window Caption Bar Title'<br /> Position = poScreenCenter<br /> object Button1: TButton<br /> Caption = 'Start Animation'<br /> Default = True<br /> OnClick = Button1Click<br /> <span style="color: blue;">end</span><br /> <span style="color: blue;">object </span>Edit1: TEdit<br /> Text = 'Scrolling Window Caption Bar Title'<br /> <span style="color: blue;">end</span><br /> <span style="color: blue;">object </span>Timer1: TTimer<br /> Enabled = False<br /> Interval = 100<br /> OnTimer = Timer1Timer<br /> <span style="color: blue;">end</span><br /><span style="color: blue;">end</span><br /><br /><span style="color: lime;">// unit1</span><br /><span style="color: blue;">type</span><br /> TForm1 = class(TForm)<br /> Button1: TButton;<br /> Timer1: TTimer;<br /> Edit1: TEdit;<br /> procedure Button1Click(Sender: TObject);<br /> procedure Timer1Timer(Sender: TObject);<br /><br /><span style="color: blue;">const</span><br /> {$J+} // using assignable typed constant<br /> scrollingCaption : string = 'Scrolling Window Caption Bar Title...';<br /> {$J-}<br /><span style="color: blue;">var</span><br /> Form1: TForm1;<br /><br /><span style="color: blue;">implementation</span><br /><br />{$R *.dfm}<br /><span style="color: lime;">// ********************************************************** //</span><br /><span style="color: blue;">procedure </span>TForm1.Button1Click(Sender: TObject);<br /><span style="color: lime;">// ********************************************************** //</span><br /><span style="color: blue;">begin</span><br /> if TButton(Sender).Caption='Start Animation' then<br /> begin<br /> scrollingCaption:=' >> '+Edit1.Text+' << ';<br /> Timer1.Enabled:=true;<br /> TButton(Sender).Caption:='Stop Animation';<br /> end<br /> else<br /> begin<br /> Timer1.Enabled:=false;<br /> TButton(Sender).Caption:='Start Animation';<br /> end;<br /><span style="color: blue;">end;</span><br /><br style="color: lime;" /><span style="color: lime;">// ********************************************************** //</span><br /><span style="color: blue;">procedure </span>TForm1.Timer1Timer(Sender: TObject);<br /><span style="color: lime;">// ********************************************************** //</span><br /><span style="color: blue;">var</span><br /> n: Integer;<br /><span style="color: blue;">begin</span><br /> Form1.Caption := scrollingCaption;<br /> for n := 1 to (Length(scrollingCaption) - 1) do<br /> scrollingCaption[n] := Form1.Caption[n + 1];<br /><br /> scrollingCaption[Length(scrollingCaption)] := Form1.Caption[1];<br /><span style="color: blue;">end;</span><br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-70712523266482674932012-03-28T11:32:00.006-07:002012-03-28T12:35:34.669-07:00Flashing / Blinking Application Windows Caption Bar<span style="color: lime;">// Flashing (blinking) application window caption bar, in order to get user attention</span><br />
<br />
<span style="color: blue;">object </span>Form1: TForm1<br />
Caption = 'Form1'<br />
<span style="color: blue;">object </span>Button1: TButton<br />
Caption = 'Flash On'<br />
OnClick = Button1Click<br />
<span style="color: blue;">end </span><br />
<span style="color: blue;">object </span>Timer1: TTimer<br />
Enabled = False<br />
Interval = 100<br />
OnTimer = Timer1Timer<br />
<span style="color: blue;">end</span><br />
<span style="color: blue;">end</span><br />
<br />
<span style="color: lime;">// ********************************************* //</span><br />
<span style="color: blue;">procedure </span>TForm1.Button1Click(Sender: TObject);<br />
<span style="color: lime;">// ********************************************* //</span><br />
<span style="color: blue;">begin</span><br />
if TButton(Sender).Caption='Flash On' then<br />
begin<br />
beep;<br />
TButton(Sender).Caption:='Flash Off';<br />
Timer1.Enabled:=true;<br />
end<br />
else<br />
begin<br />
TButton(Sender).Caption:='Flash On';<br />
Timer1.Enabled:=False;<br />
end;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ********************************************* //</span><br />
<span style="color: blue;">procedure </span>TForm1.Timer1Timer(Sender: TObject);<br />
<span style="color: lime;">// ********************************************* //</span><br />
begin<br />
FlashWindow (Handle, True) ;<br />
<span style="color: blue;">end;</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-83183592073780226422012-03-28T11:02:00.002-07:002012-03-28T12:35:45.128-07:00Hide Application Task Bar Button from Windows Taskbar<span style="color: lime;">// ******************************************************* //</span><br />
<span style="color: lime;">// Hide Application Taskbar Button for Delphi <=2006</span><br />
<span style="color: lime;">// ******************************************************* //</span><br />
<br />
<span style="color: blue;">procedure </span>TForm1.FormCreate(Sender: TObject);<br />
<span style="color: blue;">begin</span><br />
ShowWindow(Application.Handle, SW_HIDE) ;<br />
SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ;<br />
ShowWindow(Application.Handle, SW_SHOW) ;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: red;">// above code doesn't work on Delphi >=2007</span><br />
<br />
<br />
<span style="color: lime;">// ******************************************************* //</span><br />
<span style="color: lime;">// Hide Applicaton Taskbar Button for Delphi >=2007</span><br />
<span style="color: lime;">// ******************************************************* //</span><br />
<br />
<span style="color: lime;">// Menu->Project->View Source</span><br />
<span style="color: blue;">program </span>Project1;<br />
<br />
<span style="color: blue;">uses</span><br />
Vcl.Forms,<br />
Unit1 in 'Unit1.pas' {Form1};<br />
<br />
{$R *.res}<br />
<br />
<span style="color: blue;">begin</span><br />
Application.Initialize;<br />
Application.MainFormOnTaskbar := False; <span style="color: lime;">// Change True to False, Default is True</span><br />
Application.CreateForm(TForm1, Form1);<br />
Application.Run;<br />
<span style="color: blue;">end.</span><br />
<br />
<span style="color: lime;">// on Unit1.pas</span><br />
<span style="color: blue;">procedure </span>TForm1.FormActivate(Sender: TObject);<br />
<span style="color: blue;">begin</span><br />
ShowWindow(Application.Handle, SW_HIDE);<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">procedure </span>TForm1.FormShow(Sender: TObject);<br />
<span style="color: blue;">begin</span><br />
ShowWindow(Application.Handle, SW_HIDE);<br />
<span style="color: blue;">end;</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-64640343904993334502012-03-28T10:24:00.003-07:002012-03-29T01:02:32.693-07:00How to detect application idle time<div style="color: lime;">
// How To Track Application Idle Time</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwxaM74MW1lFo1FBteN8mIr8DDwlqewk0QqZ8n01RQyC5daW5ACg8AYZ7tW1x4OZuIJCufyklnnj25YACRjD7XvhYEH12v8tsSNVsu8ZffJXZy9diEey_tGIaO0bF36VBixR-URZBxRmo/s1600/IdleTime01.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="161" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwxaM74MW1lFo1FBteN8mIr8DDwlqewk0QqZ8n01RQyC5daW5ACg8AYZ7tW1x4OZuIJCufyklnnj25YACRjD7XvhYEH12v8tsSNVsu8ZffJXZy9diEey_tGIaO0bF36VBixR-URZBxRmo/s400/IdleTime01.JPG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: lime;">// Screen shot of the program</span></div>
<br />
<span style="color: blue;">unit </span>Unit1;<br />
<br />
<span style="color: blue;">interface</span><br />
<br />
<span style="color: blue;">uses</span><br />
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,<br />
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;<br />
<br />
<span style="color: blue;">type</span><br />
TMainForm = class(TForm)<br />
Timer1: TTimer;<br />
Panel1: TPanel;<br />
procedure Timer1Timer(Sender: TObject);<br />
<span style="color: blue;">private</span><br />
{ Private declarations }<br />
function SecondsIdle:DWord;<br />
function SecToTime(Sec:Integer):string;<br />
<span style="color: blue;">public</span><br />
{ Public declarations }<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">var</span><br />
MainForm: TMainForm;<br />
<br />
<span style="color: blue;">implementation</span><br />
<br />
{$R *.dfm}<br />
<br />
{ TMainForm }<br />
<br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">function </span>TMainForm.SecondsIdle: DWord;<br />
<span style="color: lime;">// from : http://delphi.about.com/od/adptips2004/a/bltip1104_4.htm</span><br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">var</span><br />
liInfo: TLastInputInfo;<br />
<span style="color: blue;">begin</span><br />
liInfo.cbSize := SizeOf(TLastInputInfo) ;<br />
GetLastInputInfo(liInfo) ;<br />
Result := (GetTickCount - liInfo.dwTime) DIV 1000;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">function </span>TMainForm.SecToTime(Sec: Integer): string;<br />
<span style="color: lime;">// from : http://delphi.about.com/cs/adptips2003/a/bltip0403_5.htm</span><br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">var</span><br />
H, M, S: string;<br />
ZH, ZM, ZS: Integer;<br />
<span style="color: blue;">begin</span><br />
ZH := Sec div 3600;<br />
ZM := Sec div 60 - ZH * 60;<br />
ZS := Sec - (ZH * 3600 + ZM * 60) ;<br />
H := IntToStr(ZH) ;<br />
M := IntToStr(ZM) ;<br />
S := IntToStr(ZS) ;<br />
Result := H + ':' + M + ':' + S;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">procedure </span>TMainForm.Timer1Timer(Sender: TObject);<br />
<span style="color: lime;">// ******************************************************** //</span><br />
<span style="color: blue;">begin</span><br />
Panel1.Caption:='You are idle for : '+SecToTime(SecondsIdle);<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">end.</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-52288095365828463462012-03-28T03:54:00.004-07:002012-03-28T03:59:19.321-07:00Creating MDI Tabbed Interface (Sample)// Creating MDI = Multiple Document Interface with Tabbed Interface (with Sample Codes)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoGEqPvkKqRbp1XUIcrwz8RNAcn0IHPrzRj_O8K8ul7d-fl8k-cy2wmyPgnlsxUKZ6hzwSMeA14DbIUeehjU1vfsnoCnKOq5ag_I03hTBaYdTZCCCWALHc1m2rYFMdX81CnLA3W4reqWc/s1600/MDITabs01.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoGEqPvkKqRbp1XUIcrwz8RNAcn0IHPrzRj_O8K8ul7d-fl8k-cy2wmyPgnlsxUKZ6hzwSMeA14DbIUeehjU1vfsnoCnKOq5ag_I03hTBaYdTZCCCWALHc1m2rYFMdX81CnLA3W4reqWc/s400/MDITabs01.JPG" width="400" /></a></div>
<div style="text-align: center;">
// Unit 1 Form</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqaSt3YIrG8IQkt5GYz4kQ7JUMCnWBfWE3YnHJIGPzx38pOLf29XMIYu0XOcLjtByGMHzcufyw6wbpo0Y-2_mTOdYF1rcIskL0rKpgSVyHrWUaXcT38BWLO0r730dLx8OG1lpCX0DEPPo/s1600/MDITabs02.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqaSt3YIrG8IQkt5GYz4kQ7JUMCnWBfWE3YnHJIGPzx38pOLf29XMIYu0XOcLjtByGMHzcufyw6wbpo0Y-2_mTOdYF1rcIskL0rKpgSVyHrWUaXcT38BWLO0r730dLx8OG1lpCX0DEPPo/s400/MDITabs02.JPG" width="400" /></a></div>
<div style="text-align: center;">
// Unit 2 Form</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJI-k_Hf_2PhxXuXn-rNbQm7u2fbTctvxZHLJHMN-n7-r92FblbyBb_KuiwB5Qz50f1-mFR8xnUCrG_M_p_Tyz35fK9KLGGPINl4HB52WG9Qzr27YXz4hbXy6EtbOlzDSvb5ygumk3gcA/s1600/MDITabs03.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJI-k_Hf_2PhxXuXn-rNbQm7u2fbTctvxZHLJHMN-n7-r92FblbyBb_KuiwB5Qz50f1-mFR8xnUCrG_M_p_Tyz35fK9KLGGPINl4HB52WG9Qzr27YXz4hbXy6EtbOlzDSvb5ygumk3gcA/s400/MDITabs03.JPG" width="400" /></a></div>
<div style="text-align: center;">
// Running Application</div>
<br />
<span style="color: lime;">// Sample Code</span><br />
<br />
<span style="color: blue;">unit Unit1;</span><br />
<br />
<span style="color: blue;">interface</span><br />
<br />
<span style="color: blue;">uses</span><br />
<span style="color: lime;">// ... please put your own...</span><br />
<span style="color: blue;">type</span><br />
TMainForm = class(TForm)<br />
mdiChildrenTabs: TTabSet;<br />
ToolBar1: TToolBar;<br />
ToolButton1: TToolButton;<br />
procedure mdiChildrenTabsChange(Sender: TObject; NewTab: Integer;<br />
var AllowChange: Boolean);<br />
procedure ToolButton1Click(Sender: TObject);<br />
<span style="color: blue;"> private</span><br />
{ Private declarations }<br />
<span style="color: blue;">public</span><br />
{ Public declarations }<br />
Procedure MDIChildCreated(const childHandle : THandle);<br />
Procedure MDIChildDestroyed(const childHandle : THandle);<br />
end;<br />
<br />
<span style="color: blue;">var</span><br />
MainForm: TMainForm;<br />
<br />
<span style="color: blue;">implementation</span><br />
<br />
{$R *.dfm}<br />
<br />
<span style="color: blue;">uses</span> Unit2;<br />
<span style="color: lime;">// ****************************************************************************** //</span><br />
<span style="color: blue;">procedure</span> TMainForm.mdiChildrenTabsChange(Sender: TObject; NewTab: Integer;<br />
var AllowChange: Boolean);<span style="color: lime;"> </span><span style="color: lime;"> </span><br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">var</span><br />
cHandle: Integer;<br />
k: Integer;<br />
<span style="color: blue;">begin</span><br />
cHandle := Integer(mdiChildrenTabs.Tabs.Objects[NewTab]);<br />
<br />
if mdiChildrenTabs.Tag = -1 then Exit;<br />
<br />
for k := 0 to MDIChildCount - 1 do<br />
begin<br />
if MDIChildren[k].Handle = cHandle then<br />
begin<br />
MDIChildren[k].Show;<br />
Break;<br />
end;<br />
end;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TMainForm.ToolButton1Click(Sender: TObject);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">var </span>FormChild : TBaseChildForm;<br />
<span style="color: blue;">begin</span><br />
FormChild:=TBaseChildForm.Create(nil);<br />
FormChild.Show;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TMainForm.MDIChildCreated(const childHandle: THandle);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">begin</span><br />
mdiChildrenTabs.Tabs.AddObject(TForm(FindControl(childHandle)).Caption, TObject(childHandle));<br />
mdiChildrenTabs.TabIndex := -1 + mdiChildrenTabs.Tabs.Count;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TMainForm.MDIChildDestroyed(const childHandle: THandle);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">var</span><br />
idx: Integer;<br />
<span style="color: blue;">begin</span><br />
idx := mdiChildrenTabs.Tabs.IndexOfObject(TObject(childHandle));<br />
mdiChildrenTabs.Tabs.Delete(idx);<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">end. </span><br />
<br />
<span style="color: lime;">// ********************************** Unit 2 *********************************** // </span><br />
<br />
<span style="color: blue;">unit </span>Unit2;<br />
<br />
<span style="color: blue;">interface</span><br />
<br />
<span style="color: blue;">uses</span><br />
// ... please put your own...<br />
<br />
<span style="color: blue;">type</span><br />
TBaseChildForm = class(TForm)<br />
Button1: TButton;<br />
Panel1: TPanel;<br />
procedure FormCreate(Sender: TObject);<br />
procedure FormDestroy(Sender: TObject);<br />
procedure Button1Click(Sender: TObject);<br />
procedure FormClose(Sender: TObject; var Action: TCloseAction);<br />
<span style="color: blue;">private</span><br />
{ Private declarations }<br />
<span style="color: blue;">procedure </span>WMMDIACTIVATE(var msg : TWMMDIACTIVATE) ; message WM_MDIACTIVATE;<br />
<span style="color: blue;">public</span><br />
{ Public declarations }<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">var</span><br />
BaseChildForm: TBaseChildForm;<br />
<br />
<span style="color: blue;">implementation</span><br />
<br />
{$R *.dfm}<br />
<br />
<span style="color: blue;">uses </span>Unit1;<br />
<br />
{ TBaseChildForm }<br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TBaseChildForm.Button1Click(Sender: TObject);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">begin</span><br />
panel1.Caption:='Hello World';<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TBaseChildForm.FormCreate(Sender: TObject);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">begin</span><br />
MainForm.MDIChildCreated(self.Handle)<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TBaseChildForm.FormDestroy(Sender: TObject);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">begin</span><br />
MainForm.MDIChildDestroyed(self.Handle);<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TBaseChildForm.FormClose(Sender: TObject; var Action: TCloseAction);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">begin</span><br />
action:=caFree;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">procedure </span>TBaseChildForm.WMMDIACTIVATE(var msg: TWMMDIACTIVATE);<br />
<span style="color: lime;">// ****************************************************************************** // </span><br />
<span style="color: blue;">var</span><br />
active: TWinControl;<br />
idx: Integer;<br />
<span style="color: blue;">begin</span><br />
active := FindControl(msg.ActiveWnd) ;<br />
<br />
if Assigned(active) then<br />
begin<br />
idx := MainForm.mdiChildrenTabs.Tabs.IndexOfObject(TObject(msg.ActiveWnd));<br />
MainForm.mdiChildrenTabs.Tag := -1;<br />
MainForm.mdiChildrenTabs.TabIndex := idx;<br />
MainForm.mdiChildrenTabs.Tag := 0;<br />
end;<br />
<span style="color: blue;">end;</span><br />
<br />
<span style="color: blue;">end.</span>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-40953023667088344442012-03-23T21:50:00.002-07:002012-03-28T04:03:03.200-07:00Set Tab Stops for TMemo<div style="color: lime;">
{</div>
<div style="color: lime;">
Editor: TDBRichEdit;</div>
<div style="color: lime;">
private</div>
<div style="color: lime;">
Procedure SetMemoTabStop;</div>
<div style="color: lime;">
}</div>
<br />
<div style="color: lime;">
// ************************************************************************ //</div>
<div style="color: blue;">
procedure <span style="color: white;">TMainForm.FormCreate(Sender: TObject);</span></div>
<div style="color: lime;">
// ************************************************************************ //</div>
<div style="color: blue;">
begin</div>
SetMemoTabStop;<br />
<div style="color: blue;">
end;</div>
<br />
<div style="color: lime;">
// ************************************************************************ //</div>
<div style="color: blue;">
procedure <span style="color: white;">TMainForm.SetMemoTabStop;</span></div>
<div style="color: lime;">
// ************************************************************************ //</div>
<div style="color: lime;">
// Codes Originally From : http://delphi.about.com/cs/adptips2001/a/bltip1201_2.htm <br />
// and modified by me to become Tab Per Character not Tab Per Pixels. </div>
<div style="color: lime;">
<br /></div>
<div style="color: blue;">
var</div>
DialogUnitsX : LongInt;<br />
PixelsX : LongInt;<br />
i : integer;<br />
PixelPerCharExt : Extended;<br />
PixelPerCharInt : Integer; <br />
TabArray : array[0..4] of integer;<br />
<div style="color: blue;">
begin</div>
Editor.WantTabs := true;<br />
DialogUnitsX := LoWord(GetDialogBaseUnits) ;<br />
<br />
// must get pixels per characters...<br />
PixelPerCharExt:=(Editor.Font.Size / 72)*96;<br />
PixelPerCharInt:=Trunc(PixelPerCharExt);<br />
<br />
PixelsX := PixelPerCharInt*4; <span style="color: lime;">// tab. 4 character, just change 4 with anything you like.</span><br />
<br />
for i := 1 to 5 do begin<br />
TabArray[i - 1] :=<br />
((PixelsX * i ) * 4) div DialogUnitsX;<br />
end;<br />
SendMessage(Editor.Handle,<br />
EM_SETTABSTOPS,<br />
5,<br />
LongInt(@TabArray)) ;<br />
Editor.Refresh;<br />
<div style="color: blue;">
end;</div>
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-1581434941103702202012-03-19T05:58:00.004-07:002012-03-23T22:28:55.345-07:00Create Firebird Database Programmatically<div style="background-color: black; color: lime;">
// To create Firebird Database programmatically</div>
<div style="background-color: black; color: white;">
IBDatabase1.DatabaseName:=ChangeFileExt(Application.ExeName,'.fdb');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('<span style="color: red;">USER ''SYSDBA</span>''');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('<span style="color: red;">PASSWORD ''masterkey'</span>'');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('PAGE_SIZE 4096');</div>
<div style="background-color: black; color: white;">
IBDatabase1.CreateDatabase;</div>
<div style="background-color: black; color: white;">
IBDatabase1.Open;</div>
<div style="background-color: black; color: white;">
</div>
<div style="background-color: black; color: lime;">
// To open Firebird Database programmatically</div>
<div style="background-color: black; color: white;">
IBDatabase1.DatabaseName:=ChangeFileExt(Application.ExeName,'.fdb');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('<span style="color: red;">USER_NAME=SYSDBA</span>');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('<span style="color: red;">PASSWORD=masterkey</span>');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Params.Add('PAGE_SIZE 4096');</div>
<div style="background-color: black; color: white;">
IBDatabase1.Open;</div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-15690834899447612612012-03-19T05:25:00.004-07:002012-03-28T04:01:37.245-07:00Check wheter or not Firebird is running<div style="background-color: black; color: white; font-family: "Trebuchet MS",sans-serif;">
<div style="color: lime;">
// Don't forget to include the unit WinSvc.</div>
<div style="color: lime;">
// Call IsFirebirdRunning Function in your program :</div>
<br />
<span style="color: lime;">// ********************************************************************************** //</span><br />
<div style="color: blue;">
Procedure <span style="color: white;">TMainForm.FormCreate(Sender: TOBject);</span><br />
<span style="color: lime;">// ********************************************************************************** //</span> </div>
<div style="color: blue;">
Begin</div>
If not (IsFirebirdRunning) then ShowMessage('Firebird is not running');<br />
<div style="color: blue;">
End;</div>
<br />
<span style="color: lime;">// ********************************************************************************** //</span></div>
<div style="background-color: black; color: white; font-family: "Trebuchet MS",sans-serif;">
</div>
<div style="background-color: black; color: white; font-family: "Trebuchet MS",sans-serif;">
</div>
<div style="background-color: black; color: blue; font-family: "Trebuchet MS",sans-serif;">
<b>Function <span style="color: white;">IsFirebirdRunning:boolean;</span></b><br />
<span style="color: lime;">// ********************************************************************************** //</span><b> </b></div>
<div style="background-color: black; color: blue; font-family: "Trebuchet MS",sans-serif;">
<b>begin</b></div>
<div style="background-color: black; color: white; font-family: "Trebuchet MS",sans-serif;">
Result:=(ServiceGetStatus('','FirebirdServerDefaultInstance') = SERVICE_RUNNING);</div>
<div style="background-color: black; color: blue; font-family: "Trebuchet MS",sans-serif;">
<b>end;</b></div>
<div style="background-color: black; color: white; font-family: "Trebuchet MS",sans-serif;">
<br />
<span style="color: lime;">// ********************************************************************************** //</span><br />
<div style="color: blue;">
<b>Function <span style="color: white;">ServiceGetStatus(sMachine, sService: string ): DWord;</span></b><br />
<span style="color: lime;">// ********************************************************************************** //</span><b> </b></div>
<div style="color: blue;">
<b>var</b></div>
<div>
schm,</div>
<div>
schs : SC_Handle;</div>
<div>
ss : TServiceStatus;</div>
<div>
dwStat : DWord;</div>
<div style="color: blue;">
<b>begin</b></div>
<div>
dwStat := 0;</div>
<div>
<br /></div>
<div>
schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_CONNECT);</div>
<div>
<br /></div>
<div>
if (schm > 0) then </div>
<div>
begin</div>
<div>
schs := OpenService(schm, PChar(sService), SERVICE_QUERY_STATUS);</div>
<div>
<br /></div>
<div>
if (schs > 0) then </div>
<div>
begin</div>
<div>
if (QueryServiceStatus(schs, ss)) then </div>
<div>
begin</div>
<div>
dwStat := ss.dwCurrentState;</div>
<div>
end;</div>
<div>
CloseServiceHandle(schs);</div>
<div>
end;</div>
<div>
CloseServiceHandle(schm);</div>
<div>
end;</div>
<div>
Result := dwStat;</div>
<div style="color: blue;">
<b>end;</b></div>
</div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-6601278251822239532.post-47934914759468158692012-03-19T05:13:00.000-07:002012-03-19T05:13:27.507-07:00Welcome to my Delphi Tips and Tricks Blog<span style="font-size: large;">Here you'll find Delphi Tips and Tricks that might be useful to you.</span>Unknownnoreply@blogger.com