:: My another contributions in Delphi

»Delphi3000.com
posting and uploading delphi articles
[currently as Top 66 uploader]


»Komunitas Delphi Indonesia
starting as a member

Tuesday, December 12, 2006

:: Delphi Editor [IDE] Shortcuts (All)

Shortcuts for Delphi's Editor (IDE)

Shortcut
Action or command
-----------------------------------
F1 Help|Topic Search
Ctrl+F1 Help|Topic Search
F3 Search|Search Again

Ctrl+E Search|Incremental Search
Ctrl+F Search|Find
Ctrl+I Inserts a tab character
Ctrl+j Templates pop-up menu
Ctrl+N Inserts a new line
Ctrl+P Causes next character to be interpreted as an ASCII sequence
Ctrl+R Search|Replace
Ctrl+S File|Save
Ctrl+T Deletes a word

Ctrl+Y Deletes a line
Ctrl+Z Edit|Undo
Ctrl+[space bar] Code Completion pop-up window

Ctrl+Shift+g Inserts a new Globally Unique Identifier (GUID) (Delphi)
Ctrl+Shift+I Indents block
Ctrl+Shift+U Outdents block
Ctrl+Shift+Y Deletes to the end of a line
Ctrl+Shift+Z Edit|Redo
Ctrl+Shift+[space bar] Code Parameters pop-up window

End Moves to the end of a line
Home Moves to the start of a line

Ctrl+Left Arrow Moves one word left
Ctrl+Right Arrow Moves one word right
Ctrl+Tab Moves to the next code page (or file)
Ctrl+Shift+Tab Moves to the previous code page (or file)
Ctrl+Backspace Deletes the word to the right of the cursor
Ctrl+Home Moves to the top of a file
Ctrl+End Moves to the end of a file
Ctrl+Del Deletes a currently selected block
Ctrl+PgDn Moves to the bottom of a screen
Ctrl+PgUp Moves to the top of a screen
Ctrl+Up Arrow Scrolls up one line
Ctrl+Down Arrow Scrolls down one line
Ctrl+Enter Opens file at cursor

Shift+Tab Moves the cursor to the left one tab position
Shift+Backspace Deletes the character to the left of the cursor

Ctrl+Shift+Left Arrow Selects the word to the left of the cursor
Ctrl+Shift+Right Arrow Selects the word to the right of the cursor

Ctrl+Shift+Home Selects from the cursor position to the start of the current file
Ctrl+Shift+End Selects from the cursor position to the end of the current file
Ctrl+Shift+PgDn Selects from the cursor position to the bottom of the screen
Ctrl+Shift+PgUp Selects from the cursor position to the top of the screen
Ctrl+Shift+Tab Moves to the previous page
Shift+Alt+arrow Selects column-oriented blocks
Click+Alt+mousemove Selects column-oriented blocks

Ctrl+O+C Turns on column blocking
Ctrl+O+K Turns off column blocking

Alt+Backspace Edit|Undo
Alt+Page Down Goes to the next tab
Alt+Page Up Goes to the previous tab
Alt+Shift+Backspace Edit|Redo
Alt+Shift+Left Arrow Selects the column to the left of the cursor
Alt+Shift+Right Arrow Selects the column to the right of the cursor
Alt+Shift+Up Arrow Moves the cursor up one line and selects the column from the left of the starting cursor position

Alt+Shift+Down Arrow Moves the cursor down one line and selects the column from the left of the starting cursor position
Alt+Shift+Page Up Moves the cursor up one screen and selects the column from the left of the starting cursor position
Alt+Shift+Page Down Moves the cursor down one line and selects the column from the right of the starting cursor position
Alt+Shift+End Selects the column from the cursor position to the end of the current line

Alt+Shift+Home Selects the column from the cursor position to the start of the current line

Ctrl+Alt+Shift+Left Arrow Selects the column to the left of the cursor
Ctrl+Alt+Shift+Right Arrow Selects the column to the right of the cursor
Ctrl+Alt+Shift+Home Selects the column from the cursor position to the start of the current file
Ctrl+Alt+Shift+End Selects the column from the cursor position to the end of the current file
Ctrl+Alt+Shift+Page Up Selects the column from the cursor position to the bottom of the screen

Ctrl+Alt+Shift+Page Down Selects the column from the cursor position to the top of the screen

You should read this too :
» Delphi Shortcuts for block commands

Saturday, December 02, 2006

:: Delphi Shortcuts [Block Command]

In my previous post about Delphi's shortcuts,
I didn't group it into its category.
From now on, I'll post it into my category definition.

For the 1st move, I tried to figure out
all the shortcuts that lies on "Block" commands

Here is the list :

Ctrl+K+B Marks the beginning of a block
Ctrl+K+C Copies a selected block
Ctrl+K+H Hides/shows a selected block
Ctrl+K+I Indents a block by an amount specified
Ctrl+K+U Outdents a block by an amount specified
Ctrl+K+K Marks the end of a block
Ctrl+K+L Marks the current line as a block
Ctrl+K+N Changes a block to uppercase
Ctrl+K+O Changes a block to lowercase
Ctrl+K+P Prints selected block
Ctrl+K+R Reads a block from a file
Ctrl+K+T Marks a word as a block
Ctrl+K+V Moves a selected block
Ctrl+K+W Writes a selected block to a file
Ctrl+K+Y Deletes a selected block

Ctrl+O+C Turns on column blocking
Ctrl+O+I Marks an inclusive block
Ctrl+O+K Turns off column blocking
Ctrl+O+L Marks a line as a block

Shift+Alt+arrow Selects column-oriented blocks
Click+Alt+mousemove Selects column-oriented blocks

Ctrl+Q+B Moves to the beginning of a block selected
Ctrl+Q+K Moves to the end of a block selected

Enjoy it.

Previous post about shortcuts :
» Delphi IDE's Shortcuts #1

Saturday, November 25, 2006

:: Displaying Month Names in Indonesian or Other Language Using FormatDateTime Function

» FormatDateTime Function

Category:

» DateTime & System

Question/Problem/Abstract:
» How we can display long month names in a specific language, eg Indonesia
So, the result will be like this : today is 25 Nopember 2006

Answer:

Actually, that's quiet simple to do that
You only need to replace the default (Delphi) "LongMonthNames" constants with the preferable any language you desire.

For this example, I want to display a specific date into Indonesian Date Format (dd MMMM yyyy)

Which,
» January is Januari in Indonesian
» February is Februari
» March is Maret
» April is April
» May is Mei
» June is Juni
» July is Juli
» August is Agustus
» September is September (unchanged)
» October is Oktober
» November is Nopember
» December is Desember

The example code would be like this :
-------------------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
DateTimePicker1: TDateTimePicker;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

// English:
// this variable ("namaBulan") is used to replace month names' string
// from English into Indonesian
// this variable is used in "replaceLongMonthNamesWithIndonesian" procedure

// dipakai untuk menggantikan string nama bulan dr bhs Inggris ke Indonesia
// digunakan dalam procedure "replaceLongMonthNamesWithIndonesian"
namaBulan: array[1..12] of string =
( 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli',
'Agustus', 'September', 'Oktober', 'Nopember', 'Desember');

// You can change the string constant above with your language choice

implementation

{$R *.dfm}

procedure replaceLongMonthNamesWithIndonesian;
var i : integer;
begin
for i:=1 to High(namaBulan) do
LongMonthNames[i] := namaBulan[i];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
replaceLongMonthNamesWithIndonesian;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessageFmt(
'The date in Indonesian format (dd mmmm yyyy) : %s',
[FormatDateTime('dd MMMM yyyy', DateTimePicker1.Date)]);
end;

end.

-------------------------------------
// end of the code

if you want to change the short name of a month with some other language either, you need to change the "ShortMonthNames" like we did above


Enjoy it

ps : the original code is posted @delphi3000.com [http://www.delphi3000.com/articles/article_4642.asp] by me either


Thursday, November 23, 2006

:: Simple Way To Give Leading Zero In a Number

» String Format Function

Question/Problem/Abstract:

How can we put the leading zero in a Number with specifix n Max Digit place holder ??
Is there any Delphi built in function to do this job ??

Eg :
» if digit place holder is 5 => 00123
» if digit place holder is 3 => 012

Answer:
Actually, Delphi has supported to do this kind of job.
Yes, we can use function "Format" strings to do this
But we must do a little trick here to use it appropriately

Here is my example code:
********************************

function GiveLeadingZero(const aNumber, aMaxDigit: Integer): String;
var formatSpecifier: String;
begin
formatSpecifier := Format('%%.%dd', [aMaxDigit]);

// formatSpecifier will result like this: '%.5d' if aMaxDigit=5
Result := Format(formatSpecifier, [aNumber]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var aNumber: Integer;
begin
if (TryStrToInt(Edit1.Text, aNumber)) then
Edit2.Text := GiveLeadingZero(aNumber, 5)
else
ShowMessage('Value in Edit1 is not a valid integer value');
end;

********************************

To use those code, simply juzt put two TEdit component on the Form with one button to execute the code



I think it solved the problem.

ps : the original code is posted @delphi3000.com [http://www.delphi3000.com/articles/article_4639.asp?SK=] by me either


Saturday, November 18, 2006

:: How To Use Macro In Delphi's IDE









See the picture first

Question/Problem/Abstract:

How to make such changes [see above picture] efficiently n quicker
* Left picture : before quote formatting
* Right picture : after use macro to give quote formatting

Answer:
You can do that only using Macro
see my previous posting about Macro Shortcut In Delphi
and then follow below steps :

1. Move your text cursor into "SELECT" line
2. Activate the Recording Macro by pressing [Ctrl]+[Shift]+[r]
3. Press [Home] button in order to move the cursor to the beggining of that line
4. Press [Ctrl]+[Right Arrow] button
5. Press ['] { give opening quote you deserve }
6. Press [End] button
7. Press [space] button in order to give trailing space for that line
8. Press ['] { give closing quote you deserve }
9. Press [space] button in order to give extra space again for that line
10. Press [+] button to insert plus char at that position
11. Press [Down Arrow] in order to move down the text cursor
12. Deactivate/stop the Recording Macro by pressing [Ctrl]+[Shift]+[r] again
13. Last step is press [Ctrl]+[Shift]+[p] to play/use we've recorded macro for the remaining lines

It's simple isn't it ?
:D

Increase your coding efficiency now !!

Sunday, November 05, 2006

:: Easiest Way Drawing Transparent Image

Question/Problem/Abstract:
How to draw an image transparently ?

Answer:
Here is anohter way to draw a transparent image.
Only using Delphi properties and method (Image).

Here is the example code:


// make draw proc to draw transparently
procedure MyTransparentDraw(src, dest: TBitmap; x, y: integer; warna: TColor);
begin
src.Transparent := true;
src.TransparentMode := tmFixed;
src.TransparentColor := warna;
dest.Canvas.Draw(x, y, src);
end;

procedure TForm1.Button1Click(Sender: TObject);
const
TRANS_COLOR = clYellow; // change with transparent color you want
var bmp, bmp2: TBitmap;
begin
if (OpenPictureDialog1.Execute) then begin
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
bmp := TBitmap.Create;
try
bmp.Width := Image1.Width;
bmp.Height := Image1.Height;
bmp.Assign(Image1.Picture.Bitmap);
bmp2 := TBitmap.Create;
try
bmp2.Width := bmp.Width;
bmp2.Height := bmp.Height;
MyTransparentDraw(bmp, bmp2, 0, 0, TRANS_COLOR);
Image1.Canvas.Draw(0, 0, bmp2);
finally
bmp2.Free;
end;
finally
bmp.Free;
end;
end;
end;

To try above code, just copy and paste those code,
then click on button to choose an image to be drawn transparently.
You can change the value of "TRANS_COLOR" above with any other color that you want to be the transparent color of your image


ps : original source of this article was uploaded by h4ry p @ delphi3000.com
http://www.delphi3000.com/articles/article_3115.asp


Thursday, October 26, 2006

:: Delphi IDE's Shortcuts #2

» Block Code Vertically

Untuk Highlight/blok code per baris tentunya para delphiers tidak ada

kesulitan / sudah tau semua kan, kan tinggal menekan tombol [shift]
yang diikuti tombol kursor bawah atau atas.

Nah kalo kita mau highlight/blok code secara kolom bisa atau tidak ?
Misalnya kita mau copy blok code tertentu tetapi tidak mau
menyertakan indentasi yang ada pada blok code tersebut ?

Nah, ini ada caranya :
1. Aktifkan dulu mode highlight/block per kolom-nya dengan menekan
tombol [Ctrl+O+C] (ctrl + huruf O (bukan nol) + huruf C)
2. Silahkan menekan tombol arah kanan/kiri untuk mengubah lebar kolom
yang hendak dihighlight/blok
3. Silahkan kalau mau di copy/cut blok code tersebut.
4. Untuk mengembalikan mode highlight/blok code-nya ke mode per baris
tekan tombol [Ctrl+O+L] atau clik mouse dimana saja.

Sekian dulu tips nya.
Semoga berguna

[diambil dari milis delphierscafe@yahoogroups.com]


:: Delphi IDE's Shortcuts #1

Maybe this post can help you to code more efficiently with Delphi's IDE
Here is the list : (I use Delphi 7)

o> Bookmarking
a. Mark =>
[Ctrl]+[Shift]+[0|1|2|...|9]
or
[Ctrl]+[k]+[0|1|2|...|9]
b. UnMark =>
[Ctrl]+[Shift]+[0|1|2|...|9]
or
[Ctrl]+[k]+[0|1|2|...|9]

o> Change code capitalization
a. Lower Case : [Ctrl]+[k]+[o] { o not zero (0) }
b. Upper Case : [Ctrl]+[k]+[n]

How to use :
1. Select the code
2. Press [Ctrl]+[k]+[n]
3. Now, the code has changed to its upper case

o> Make block indentation
1. Select block of code
2. Press [Ctrl]+[k]+[i]

o> Remove block indentation
1. Select block of code
2. Press [Ctrl]+[k]+[u]

o> Jumps to code declaration
1. Move to code implementation
2. Press [Ctrl]+[Shift]+[up arrow]

o> Jumps to code implementation
1. Move to code declaration
2. Press [Ctrl]+[Shift]+[down arrow]

o> Macro :
a. Start recording : [Ctrl]+[Shift]+[r]
b. Stop recording : [Ctrl]+[Shift]+[r]
c. Play macro : [Ctrl]+[Shift]+[p]