Programlama yapalım ve Öğrenelim. - Delphi Eğitim116
  Ana Sayfa
  .NET Eğitim Notları
  Visual C# .NET Örnek Kodları
  VisualBasic.NET Örnek Kodları
  J# Örnekleri
  ASP.NET Örnek Kodları
  Delphi Eğitim
  => Delphi Eğitim1
  => Delphi Eğitim2
  => Delphi Eğitim3
  => Delphi Eğitim4
  => Delphi Eğitim5
  => Delphi Eğitim6
  => Delphi Eğitim7
  => Delphi Eğitim8
  => Delphi Eğitim9
  => Delphi Eğitim10
  => Delphi Eğitim11
  => Delphi Eğitim13
  => Delphi Eğitim14
  => Delphi Eğitim15
  => Delphi Eğitim16
  => Delphi Eğitim17
  => Delphi Eğitim18
  => Delphi Eğitim19
  => Delphi Eğitim20
  => Delphi Eğitim21
  => Delphi Eğitim22
  => Delphi Eğitim23
  => Delphi Eğitim24
  => Delphi Eğitim25
  => Delphi Eğitim26
  => Delphi Eğitim27
  => Delphi Eğitim28
  => Delphi Eğitim29
  => Delphi Eğitim30
  => Delphi Eğtim31
  => Delphi Eğitim32
  => Delphi Eğitim33
  => Delphi Eğitim34
  => Delphi Eğitim35
  => Delphi Eğitim36
  => Delphi Eğitim37
  => Delphi Eğitim38
  => Delphi Eğitim39
  => Delphi Eğitim40
  => Delphi Eğitim41
  => Delphi Eğitim42
  => Delphi Eğitim43
  => Delphi Eğitim44
  => Delphi Eğitim45
  => Delphi Eğitim46
  => Delphi Eğitim47
  => Delphi Eğitim48
  => Delphi Eğitim49
  => Delphi Eğitim50
  => Delphi Eğitim51
  => Delphi Eğitim52
  => Delphi Eğitim53
  => Delphi Eğitim54
  => Delphi Eğitim55
  => Delphi Eğitim56
  => Delphi Eğitim57
  => Delphi Eğitim58
  => Delphi Eğitim59
  => Delphi Eğitim60
  => Delphi Eğitim61
  => Delphi Eğitim62
  => Delphi Eğitim63
  => Delphi Eğitim64
  => Delphi Eğitim65
  => Delphi Eğitim66
  => Delphi Eğitim67
  => Delphi Eğitim68
  => Delphi Eğitim69
  => Delphi Eğitim70
  => Delphi Eğitim71
  => Delphi Eğitim72
  => Delphi Eğitim73
  => Delphi Eğitim74
  => Delphi Eğitim75
  => Delphi Eğitim76
  => Delphi Eğitim77
  => Delphi Eğitim78
  => Delphi Eğitim79
  => Delphi Eğitim80
  => Delphi Eğitim81
  => Delphi Eğitim82
  => Delphi Eğitim83
  => Delphi Eğitim84
  => Delphi Eğitim85
  => Delphi Eğitim86
  => Delphi Eğitim87
  => Delphi Eğitim88
  => Delphi Eğitim89
  => Delphi Eğitim90
  => Delphi Eğitim91
  => Delphi Eğitim92
  => Delphi Eğitim93
  => Delphi Eğitim94
  => Delphi Eğitim95
  => Delphi Eğitim96
  => Delphi Eğitim97
  => Delphi Eğitim98
  => Delphi Eğitim99
  => Delphi Eğitim100
  => Delphi Eğitim101
  => Delphi Eğitim102
  => Delphi Eğitim103
  => Delphi Eğitim104
  => Delphi Eğitim105
  => Delphi Eğitim106
  => Delphi Eğitim107
  => Delphi Eğitim108
  => Delphi Eğitim109
  => Delphi Eğitim110
  => Delphi Eğitim111
  => Delphi Eğitim112
  => Delphi Eğitim113
  => Delphi Eğitim114
  => Delphi Eğitim115
  => Delphi Eğitim116
  => Delphi Eğitim117
  => Delphi Eğitim118
  => Delphi Eğitim119
  => Delphi Eğitim120
  => Delphi Eğitim121
  => Delphi Eğitim122
  => Delphi Eğitim123
  => Delphi Eğitim124
  => Delphi Eğitim125
  => Delphi Eğitim126
  => Delphi Eğitim127
  => Delphi Eğitim128
  => Delphi Eğitim129
  => Delphi Eğitim130
  => Delphi Eğitim131
  => Delphi Eğitim132
  => Delphi Eğitim133
  => Delphi Eğitim134
  => Delphi Eğitim135
  => Delphi Eğitim136
  => Delphi Eğitim137
  => Delphi Eğitim138
  => Delphi Eğitim139
  => Delphi Eğitim140
  => Delphi Eğitim141
  => Delphi Eğitim142
  => Delphi Eğitim143
  => Delphi Eğitim144
  => Delphi Eğitim145
  => Delphi Eğitim146
  => Delphi eğitim147
  => Delphi Eğitim148
  => Delphi Eğitim149
  => Delphi Eğitim150
  => Delphi Eğitim151
  => Delphi Eğitim152
  => Delphi Eğitim153
  => Delphi Eğitim154
  => Delphi Eğitim155
  => Delphi Eğitim156
  => Delphi Eğitim157
  => Delphi Eğitim158
  => Delphi Eğitim159
  => Delphi Eğitim160
  => Delphi Eğitim161
  => Delphi Eğitim162
  => Delphi Eğitim164
  => Delphi Eğitim165
  => Delphi Eğitim166
  => Delphi Eğitim167
  => Delphi Eğitim168
  => Delphi Eğitim169
  => Delphi Eğitim170
  => Delphi Eğitim171
  => Delphi Eğitim172
  => Delphi Eğitim173
  => Delphi Eğitim174
  => Delphi Eğitim175
  => Delphi Eğitim176
  => Delphi Eğitim177
  => Delphi Eğitim178
  => Delphi Eğitim179
  => Delphi Eğitim180
  => Delphi Eğitim181
  => Delphi Eğitim182
  => Delphi Eğitim183
  => Delphi Eğitim184
  => Delphi Eğitim185
  => Delphi Eğitim186
  => Delphi Eğitim187
  => Delphi Eğitim188
  => Delphi Eğitim189
  => Delphi Eğitim190
  => Delphi Eğitim191
  => Delphi Eğitim192
  => Delphi Eğitim193
  => Delphi Eğitim194
  => Delphi Eğitim195
  => Delphi Eğitim196
  => Delphi Eğitim197
  => Delphi Eğitim198
  => Delphi Eğitim199
  => Delphi Eğitim200
  => Delphi Eğitim201
  => Delphi Eğitim202
  => Delphi Eğitim203
  => Delphi Eğitim204
  => Delphi Eğitim205
  => Delphi Eğitim206
  => Delphi Eğitim207
  => Delphi Eğitim208
  => Delphi Eğitim209
  => Delphi Eğitim210
  => Delphi Eğitim211
  => Delphi Eğitim212
  => Delphi Eğitim213
  => Delphi Eğitim214
  => Delphi Eğitim215
  => Delphi Eğitim216
  => Delphi Eğitim217
  => Delphi Eğitim218
  => Delphi Eğitim219
  => Delphi Eğitim220
  => Delphi Eğitim221
  => Delphi Eğitim222
  => Delphi Eğitim223
  => Delphi Eğitim224
  => Delphi Eğitim225
  => Delphi Eğitim226
  => Delphi Eğitim227
  => Delphi Eğitim228
  => Delphi Eğitim229
  => Delphi Eğitim230
  => Delphi Eğitim231
  => Delphi Eğitim232
  => Delphi Eğitim233
  => Delphi Eğitim234
  => Delphi Eğitim235
  => Delphi Eğitim236
  => Delphi Eğitim237
  => Delphi Eğitim238
  => Delphi Eğitim239
  => Delphi Eğitim240
  => Delphi Eğitim241
  => Delphi Eğitim242
  İletişim

Verilen bir kredi karti numarasi'nin gecerli olup olmadiginin kontrolü

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

Verilen bir kredi karti numarasi'nin gecerli olup olmadiginin kontrolü

 

{-------------------------------------------------

  Credit card validator

 

  Returns:

 

   0  : Card is invalid or unknown

   1  : Card is a valid AmEx

   2  : Card is a valid Visa

   3  : Card is a valid MasterCard

 

-------------------------------------------------}

 

function Vc(c: string): integer;

var

  card: string[21];

  Vcard: array[0..21] of byte absolute card;

  Xcard: integer;

  Cstr: string[21];

  y, x: integer;

begin

  Cstr := ";

  fillchar(Vcard, 22, #0);

  card := c;

  for x := 1 to 20 do

    if (Vcard[x] in [48..57]) then

      Cstr := Cstr + chr(Vcard[x]);

  card := ";

  card := Cstr;

  Xcard := 0;

  if not odd(length(card)) then

    for x := (length(card) - 1) downto 1 do

    begin

      if odd(x) then

        y := ((Vcard[x] - 48) * 2)

      else

        y := (Vcard[x] - 48);

      if (y >= 10) then

        y := ((y - 10) + 1);

      Xcard := (Xcard + y)

    end

  else

    for x := (length(card) - 1) downto 1 do

    begin

      if odd(x) then

        y := (Vcard[x] - 48)

      else

        y := ((Vcard[x] - 48) * 2);

      if (y >= 10) then

        y := ((y - 10) + 1);

      Xcard := (Xcard + y)

    end;

  x := (10 - (Xcard mod 10));

  if (x = 10) then

    x := 0;

  if (x = (Vcard[length(card)] - 48)) then

    Vc := ord(Cstr[1])-ord('2')

  else

    Vc := 0

end;

 

 

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

 

Delphi - .....................................

 

Verilen bir kredi karti numarasi'nin gecerli olup olmadiginin kontrolü

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

Verilen bir kredi karti numarasi'nin gecerli olup olmadiginin kontrolü

 

{-------------------------------------------------

  Credit card validator

 

  Returns:

 

   0  : Card is invalid or unknown

   1  : Card is a valid AmEx

   2  : Card is a valid Visa

   3  : Card is a valid MasterCard

 

-------------------------------------------------}

 

function Vc(c: string): integer;

var

  card: string[21];

  Vcard: array[0..21] of byte absolute card;

  Xcard: integer;

  Cstr: string[21];

  y, x: integer;

begin

  Cstr := ";

  fillchar(Vcard, 22, #0);

  card := c;

  for x := 1 to 20 do

    if (Vcard[x] in [48..57]) then

      Cstr := Cstr + chr(Vcard[x]);

  card := ";

  card := Cstr;

  Xcard := 0;

  if not odd(length(card)) then

    for x := (length(card) - 1) downto 1 do

    begin

      if odd(x) then

        y := ((Vcard[x] - 48) * 2)

      else

        y := (Vcard[x] - 48);

      if (y >= 10) then

        y := ((y - 10) + 1);

      Xcard := (Xcard + y)

    end

  else

    for x := (length(card) - 1) downto 1 do

    begin

      if odd(x) then

        y := (Vcard[x] - 48)

      else

        y := ((Vcard[x] - 48) * 2);

      if (y >= 10) then

        y := ((y - 10) + 1);

      Xcard := (Xcard + y)

    end;

  x := (10 - (Xcard mod 10));

  if (x = 10) then

    x := 0;

  if (x = (Vcard[length(card)] - 48)) then

    Vc := ord(Cstr[1])-ord('2')

  else

    Vc := 0

end;

 

 

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

 

Delphi - .....................................

 

Programdan windows wallpaper'i degistirme islemi

Programdan windows wallpaper'i degistirme islemi

 

procedure TForm1.ChangeWallPaper(const FileName: string);

begin

  SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0,

  PChar(FileName), SPIF_UPDATEINIFILE);

end;

 

Delphi - .....................................

 

Programdan windows wallpaper'i degistirme islemi

Programdan windows wallpaper'i degistirme islemi

 

procedure TForm1.ChangeWallPaper(const FileName: string);

begin

  SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0,

  PChar(FileName), SPIF_UPDATEINIFILE);

end;

 

Delphi - .....................................

 

Bir Popup menüyü kod ile gösterme

Bir Popup menüyü kod ile gösterme

 

PopupMenu1.Popup(Form1.Left+60,Form1.Top+140);

 

Delphi - .....................................

 

Bir Popup menüyü kod ile gösterme

Bir Popup menüyü kod ile gösterme

 

PopupMenu1.Popup(Form1.Left+60,Form1.Top+140);

 

Delphi - .....................................

 

Edit'e sadece sayı girilsin

Edit'e sadece sayı girilsin

 

Bir edit'e sadece istediğiniz karakterlerin girilmesini sağlayabilirsiniz.

Bunun için Edit'in OnKeyPress olayına aşağıdaki kodu yazın.

if not (key in ['0'..'9',#8]) then

begin

Key:=#0; //girilen karakter rakam veya backspace değilse null(#0)'a dönüştür

Beep; //bip sesi ile kullanıcıyı uyar.

end;

 

 

 

NOT:Kullanıcı Edit'e rakamların dışında karakter giremez, ancak Paste ile Edit'e bir

metni kopyalayabilir. Bunuda Edit'in OnExit olayında kontrol edip, girilen değerin

istediğiniz şekilde olup olmadığını kontrol edebilirsiniz.

 

Delphi - .....................................

 

Edit'e sadece sayı girilsin

Edit'e sadece sayı girilsin

 

Bir edit'e sadece istediğiniz karakterlerin girilmesini sağlayabilirsiniz.

Bunun için Edit'in OnKeyPress olayına aşağıdaki kodu yazın.

if not (key in ['0'..'9',#8]) then

begin

Key:=#0; //girilen karakter rakam veya backspace değilse null(#0)'a dönüştür

Beep; //bip sesi ile kullanıcıyı uyar.

end;

 

 

 

NOT:Kullanıcı Edit'e rakamların dışında karakter giremez, ancak Paste ile Edit'e bir

metni kopyalayabilir. Bunuda Edit'in OnExit olayında kontrol edip, girilen değerin

istediğiniz şekilde olup olmadığını kontrol edebilirsiniz.

 

Delphi - .....................................

 

Edit'e girilen metnin ilk harfini büyük harf yapma

Edit'e girilen metnin ilk harfini büyük harf yapma

 

Bunun için Edit'in OnKeyPress olayına aşağıdaki kodu ekleyin.

with Sender as TEdit do

if (SelStart = 0) or

(Text[SelStart] = ' ') then

if Key in ['a'..'z'] then

Key := UpCase(Key);

 

Delphi - .....................................

 

Edit'e girilen metnin ilk harfini büyük harf yapma

Edit'e girilen metnin ilk harfini büyük harf yapma

 

Bunun için Edit'in OnKeyPress olayına aşağıdaki kodu ekleyin.

with Sender as TEdit do

if (SelStart = 0) or

(Text[SelStart] = ' ') then

if Key in ['a'..'z'] then

Key := UpCase(Key);

 

Delphi - .....................................

 

Form'un arka kısmına bir resmi döşemek

Form'un arka kısmına bir resmi döşemek

 

Bitmap: TBitmap;

procedure TForm1.FormCreate(Sender: TObject);

begin

Bitmap := TBitmap.Create;

Bitmap.LoadFromFile('C:WINDOWScars.BMP');

end; procedure TForm1.FormPaint(Sender: TObject); var X, Y, W, H: LongInt;

begin with Bitmap do begin W := Width; H := Height; end;

Y := 0; while Y < Height do begin X := 0;

while X < Width do begin Canvas.Draw(X, Y, Bitmap); Inc(X, W); end; Inc(Y, H); end; end;

 

Delphi - .....................................

 

Form'un arka kısmına bir resmi döşemek

Form'un arka kısmına bir resmi döşemek

 

Bitmap: TBitmap;

procedure TForm1.FormCreate(Sender: TObject);

begin

Bitmap := TBitmap.Create;

Bitmap.LoadFromFile('C:WINDOWScars.BMP');

end; procedure TForm1.FormPaint(Sender: TObject); var X, Y, W, H: LongInt;

begin with Bitmap do begin W := Width; H := Height; end;

Y := 0; while Y < Height do begin X := 0;

while X < Width do begin Canvas.Draw(X, Y, Bitmap); Inc(X, W); end; Inc(Y, H); end; end;

 

Delphi - .....................................

 

Sürücünün kapasitesini ve sürücüdeki boş yer miktarını bulmak

Sürücünün kapasitesini ve sürücüdeki boş yer miktarını bulmak

 

DiskFree(0) //o anki sürücüdeki boş yer miktarını byte cinsinden döndürür.

DiskSize(0) //o anki sürücünün kapasitesini byte cinsinden döndürür.

DiskSize(0) div 1024 //o anki sürücünün kapasitesini KB cinsinden döndürür.

 

Delphi - .....................................

 

Sürücünün kapasitesini ve sürücüdeki boş yer miktarını bulmak

Sürücünün kapasitesini ve sürücüdeki boş yer miktarını bulmak

 

DiskFree(0) //o anki sürücüdeki boş yer miktarını byte cinsinden döndürür.

DiskSize(0) //o anki sürücünün kapasitesini byte cinsinden döndürür.

DiskSize(0) div 1024 //o anki sürücünün kapasitesini KB cinsinden döndürür.

 

Delphi - .....................................

 

Programım hangi klasörde çalışıyor

Programım hangi klasörde çalışıyor

 

procedure TForm1.Button1Click(Sender: TObject);

var

path: string;

begin

Path := ExtractFilePath(ParamStr(0));

Showmessage (path);

end;

 

Delphi - .....................................

 

Programım hangi klasörde çalışıyor

Programım hangi klasörde çalışıyor

 

procedure TForm1.Button1Click(Sender: TObject);

var

path: string;

begin

Path := ExtractFilePath(ParamStr(0));

Showmessage (path);

end;

 

Delphi - .....................................

 

Bilgisayarı reboot etmek [assembley]

DELPHI -- ASSEMBLY İPUCU

 

1-Bilgisayarı reboot etmek

asm

cli

@@WaitOutReady:

in al,64h

test al,00000010b

jnz

@@WaitOutReady

mov al,0FEh

out 64h,al

End;

 

Delphi - .....................................

 

Bilgisayarı reboot etmek [assembley]

DELPHI -- ASSEMBLY İPUCU

 

1-Bilgisayarı reboot etmek

asm

cli

@@WaitOutReady:

in al,64h

test al,00000010b

jnz

@@WaitOutReady

mov al,0FEh

out 64h,al

End;

 

Delphi - .....................................

 

Delphi -- Form İpuçları

DELPHI FORM İPUCU

1. Form üzerindeki bileşenleri resolution oranında büyütme.

 

//640*480 referans olarak alindi

procedure AdjustResolution(oForm:TForm);

var

iPercentage:integer;

begin

if Screen.Width > 640 then

begin

iPercentage:=Round(((Screen.Width-640)/640)*100)+100;

oForm.ScaleBy(iPercentage,100);

end;

end;

AdjustResolution(Self);

 

 

 

2. Formun title Bar'da gözükmesini engellemek.

 

{ Mutlaka Winprocs & WinTypes unitlerinin çagrilmasi gerekli }

 

Procedure TSeninFormName.HideTitlebar;

Var

Save : LongInt;

Begin

If BorderStyle=bsNone then Exit;

Save:=GetWindowLong(Handle,gwl_Style);

If (Save and ws_Caption)=ws_Caption then Begin

Case BorderStyle of

bsSingle,

bsSizeable : SetWindowLong(Handle,gwl_Style,Save and

(Not(ws_Caption)) or ws_border);

bsDialog : SetWindowLong(Handle,gwl_Style,Save and

(Not(ws_Caption)) or ds_modalframe or ws_dlgframe);

End;

Height:=Height-getSystemMetrics(sm_cyCaption);

Refresh;

End;

end;

 

Procedure TSeninFormName.ShowTitlebar;

Var

Save : LongInt;

begin

If BorderStyle=bsNone then Exit;

Save:=GetWindowLong(Handle,gwl_Style);

If (Save and ws_Caption)<>ws_Caption then Begin

Case BorderStyle of

bsSingle,

bsSizeable : SetWindowLong(Handle,gwl_Style,Save or ws_Caption or

ws_border);

bsDialog : SetWindowLong(Handle,gwl_Style,Save or ws_Caption or

ds_modalframe or ws_dlgframe);

End;

Height:=Height+getSystemMetrics(sm_cyCaption);

Refresh;

End;

end;

 

 

 

3. Form'da kendi hotkeyini olusturma...

 

//Önce formun KeyPreview := true; yapin.

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if (ssCtrl in Shift) and (chr(Key) in ['A', 'a']) then

ShowMessage('Ctrl-A');

end;

 

 

 

4. MDI Child formun kapatılması...

 

//Formun onClose olayina asagidaki satiri yazmaniz yeterli.

Action := caFree;

 

5. Formu ilk açılışta minimize açmak...

 

//Formun onCreate olayina

ShowWindow(Handle, SW_MINIMIZE);

//yazin...

 

Delphi - .....................................

 

Delphi -- Form İpuçları

DELPHI FORM İPUCU

1. Form üzerindeki bileşenleri resolution oranında büyütme.

 

//640*480 referans olarak alindi

procedure AdjustResolution(oForm:TForm);

var

iPercentage:integer;

begin

if Screen.Width > 640 then

begin

iPercentage:=Round(((Screen.Width-640)/640)*100)+100;

oForm.ScaleBy(iPercentage,100);

end;

end;

AdjustResolution(Self);

 

 

 

2. Formun title Bar'da gözükmesini engellemek.

 

{ Mutlaka Winprocs & WinTypes unitlerinin çagrilmasi gerekli }

 

Procedure TSeninFormName.HideTitlebar;

Var

Save : LongInt;

Begin

If BorderStyle=bsNone then Exit;

Save:=GetWindowLong(Handle,gwl_Style);

If (Save and ws_Caption)=ws_Caption then Begin

Case BorderStyle of

bsSingle,

bsSizeable : SetWindowLong(Handle,gwl_Style,Save and

(Not(ws_Caption)) or ws_border);

bsDialog : SetWindowLong(Handle,gwl_Style,Save and

(Not(ws_Caption)) or ds_modalframe or ws_dlgframe);

End;

Height:=Height-getSystemMetrics(sm_cyCaption);

Refresh;

End;

end;

 

Procedure TSeninFormName.ShowTitlebar;

Var

Save : LongInt;

begin

If BorderStyle=bsNone then Exit;

Save:=GetWindowLong(Handle,gwl_Style);

If (Save and ws_Caption)<>ws_Caption then Begin

Case BorderStyle of

bsSingle,

bsSizeable : SetWindowLong(Handle,gwl_Style,Save or ws_Caption or

ws_border);

bsDialog : SetWindowLong(Handle,gwl_Style,Save or ws_Caption or

ds_modalframe or ws_dlgframe);

End;

Height:=Height+getSystemMetrics(sm_cyCaption);

Refresh;

End;

end;

 

 

 

3. Form'da kendi hotkeyini olusturma...

 

//Önce formun KeyPreview := true; yapin.

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if (ssCtrl in Shift) and (chr(Key) in ['A', 'a']) then

ShowMessage('Ctrl-A');

end;

 

 

 

4. MDI Child formun kapatılması...

 

//Formun onClose olayina asagidaki satiri yazmaniz yeterli.

Action := caFree;

 

5. Formu ilk açılışta minimize açmak...

 

//Formun onCreate olayina

ShowWindow(Handle, SW_MINIMIZE);

//yazin...

 

Delphi - .....................................

 

Delphi -- Miscellaneous İpuçları

Delphi -- Miscellaneous İpuçları

 

1. Programı sleep moduna alma...

 

Procedure MsSleep(ms : Integer);

Var

tmpTime : Integer;

tmpMs : Integer;

Begin

 

tmpMs := ms;

tmpTime := GetTickCount + tmpMs;

While tmpTime > GetTickCount Do

Application.ProcessMessages;

End;

{Program kapanışında istediğiniz bir açıklamayı koyup çalıştırın

bu uyuma metodunu engellemenin yolu yok ) }

 

 

 

2. Saat'i parçalayarak yaz...

 

// Kayıtları oluştur

type TimeParse = record

timeDay : Integer;

timeHour : Integer;

timeMin : Integer;

timeSec : Integer;

timeMilli : Integer;

end;

 

 

// function burda başlıyor

function DoTime(MilliSeconds : Integer) : TimeParse;

begin

// Değerleri sıfırla

Result.timeHour := 0;

Result.timeMin := 0;

Result.timeDay := 0;

Result.timeSec := 0;

Result.timeMilli := 0;

// Günü al

While MilliSeconds > 86399999 Do

Begin

Result.timeDay := Result.timeDay + 1;

MilliSeconds := MilliSeconds - 86400000;

End;

// Saati al

While MilliSeconds > 3599999 Do

Begin

Result.timeHour := Result.timeHour + 1;

MilliSeconds := MilliSeconds - 3600000;

End;

// Dakikayı al

While MilliSeconds > 59999 Do

Begin

Result.timeMin := Result.timeMin + 1;

MilliSeconds := MilliSeconds - 60000;

End;

// Saniyeyi al

While MilliSeconds > 999 Do

Begin

Result.timeSec := Result.timeSec + 1;

MilliSeconds := MilliSeconds - 1000;

End;

// Kaç milisaniye geçti

Result.timeMilli := MilliSeconds;

end;

 

Procedure TFrom1.Button1Click(Sender:TObject)

Var

FTimeParse : TTimeParse;

I : Integer;

begin

I := GetTickCount;

 

I := GetTickCount - I;

LabelDays.Caption := FTimeParse.timeDay;

LabelHours.Caption := FTimeParse.timeHour;

LabelMinutes.Caption := FTimeParse.timeMin;

LabelSeconds.Caption := FTimeParse.timeSec;

LabelMilliseconds.Caption := FTimeParse.timeMilli;

end;

 

Delphi - .....................................

 

Delphi -- Miscellaneous İpuçları

Delphi -- Miscellaneous İpuçları

 

1. Programı sleep moduna alma...

 

Procedure MsSleep(ms : Integer);

Var

tmpTime : Integer;

tmpMs : Integer;

Begin

 

tmpMs := ms;

tmpTime := GetTickCount + tmpMs;

While tmpTime > GetTickCount Do

Application.ProcessMessages;

End;

{Program kapanışında istediğiniz bir açıklamayı koyup çalıştırın

bu uyuma metodunu engellemenin yolu yok ) }

 

 

 

2. Saat'i parçalayarak yaz...

 

// Kayıtları oluştur

type TimeParse = record

timeDay : Integer;

timeHour : Integer;

timeMin : Integer;

timeSec : Integer;

timeMilli : Integer;

end;

 

 

// function burda başlıyor

function DoTime(MilliSeconds : Integer) : TimeParse;

begin

// Değerleri sıfırla

Result.timeHour := 0;

Result.timeMin := 0;

Result.timeDay := 0;

Result.timeSec := 0;

Result.timeMilli := 0;

// Günü al

While MilliSeconds > 86399999 Do

Begin

Result.timeDay := Result.timeDay + 1;

MilliSeconds := MilliSeconds - 86400000;

End;

// Saati al

While MilliSeconds > 3599999 Do

Begin

Result.timeHour := Result.timeHour + 1;

MilliSeconds := MilliSeconds - 3600000;

End;

// Dakikayı al

While MilliSeconds > 59999 Do

Begin

Result.timeMin := Result.timeMin + 1;

MilliSeconds := MilliSeconds - 60000;

End;

// Saniyeyi al

While MilliSeconds > 999 Do

Begin

Result.timeSec := Result.timeSec + 1;

MilliSeconds := MilliSeconds - 1000;

End;

// Kaç milisaniye geçti

Result.timeMilli := MilliSeconds;

end;

 

Procedure TFrom1.Button1Click(Sender:TObject)

Var

FTimeParse : TTimeParse;

I : Integer;

begin

I := GetTickCount;

 

I := GetTickCount - I;

LabelDays.Caption := FTimeParse.timeDay;

LabelHours.Caption := FTimeParse.timeHour;

LabelMinutes.Caption := FTimeParse.timeMin;

LabelSeconds.Caption := FTimeParse.timeSec;

LabelMilliseconds.Caption := FTimeParse.timeMilli;

end;

 

Delphi - .....................................

 

Delphi -- Sistem İpuçları

Delphi -- Sistem İpuçları

 

 

 

1. Registryden kayıt okuma...

 

procedure TForm1.FormCreate(Sender: TObject);

Var

Registry: TRegistry;

Listan:TStringList;

begin

Listan := TStringList.create;

Registry := TRegistry.Create;

try

Registry.RootKey := HKey_Classes_Root;

Registry.OpenKey('',False);

Registry.GetKeynames(Listan);

ComboBox1.Items := Listan;

finally

Registry.Free;

end;

end;

 

 

 

2. Porttan bilgi oku...

 

function ReadPortB( wPort : Word ) : Byte;

begin

asm

mov dx, wPort

in al, dx

mov result, al

end;

end;

 

 

 

3. Porta bilgi gönder...

 

procedure WritePortB( wPort : Word; bValue : Byte );

begin

asm

mov dx, wPort

mov al, bValue

out dx, al

end;

end.

 

 

 

4.Uygulamanız Desktop'ta kısayol oluştursun..

 

procedure desktopShortcut(ffilename:string; fcaption: widestring);

var

IObject : IUnknown;

ISLink : IShellLink;

IPFile : IPersistFile;

PIDL : PItemIDList;

InFolder : array[0..MAX_PATH] of Char;

TargetName : String;

LinkName : WideString;

FLinkName : String;

begin

TargetName := ffilename;

 

IObject := CreateComObject(CLSID_ShellLink);

ISLink := IObject as IShellLink;

IPFile := IObject as IPersistFile;

 

with ISLink do begin

SetPath(pChar(TargetName));

SetWorkingDirectory

(pChar(ExtractFilePath(TargetName)));

end;

 

SHGetSpecialFolderLocation

(0, CSIDL_DESKTOPDIRECTORY, PIDL);

SHGetPathFromIDList

(PIDL, InFolder);

FlinkName := ''+ FCaption + '.lnk';

LinkName := InFolder + FlinkName;

IPFile.Save(PWChar(LinkName), false);

end;

 

Kullanımı:

DesktopShortcut('C:/windows/notepad.exe','Notepad');

 

Delphi - .....................................

 

Delphi -- Sistem İpuçları

Delphi -- Sistem İpuçları

 

 

 

1. Registryden kayıt okuma...

 

procedure TForm1.FormCreate(Sender: TObject);

Var

Registry: TRegistry;

Listan:TStringList;

begin

Listan := TStringList.create;

Registry := TRegistry.Create;

try

Registry.RootKey := HKey_Classes_Root;

Registry.OpenKey('',False);

Registry.GetKeynames(Listan);

ComboBox1.Items := Listan;

finally

Registry.Free;

end;

end;

 

 

 

2. Porttan bilgi oku...

 

function ReadPortB( wPort : Word ) : Byte;

begin

asm

mov dx, wPort

in al, dx

mov result, al

end;

end;

 

 

 

3. Porta bilgi gönder...

 

procedure WritePortB( wPort : Word; bValue : Byte );

begin

asm

mov dx, wPort

mov al, bValue

out dx, al

end;

end.

 

 

 

4.Uygulamanız Desktop'ta kısayol oluştursun..

 

procedure desktopShortcut(ffilename:string; fcaption: widestring);

var

IObject : IUnknown;

ISLink : IShellLink;

IPFile : IPersistFile;

PIDL : PItemIDList;

InFolder : array[0..MAX_PATH] of Char;

TargetName : String;

LinkName : WideString;

FLinkName : String;

begin

TargetName := ffilename;

 

IObject := CreateComObject(CLSID_ShellLink);

ISLink := IObject as IShellLink;

IPFile := IObject as IPersistFile;

 

with ISLink do begin

SetPath(pChar(TargetName));

SetWorkingDirectory

(pChar(ExtractFilePath(TargetName)));

end;

 

SHGetSpecialFolderLocation

(0, CSIDL_DESKTOPDIRECTORY, PIDL);

SHGetPathFromIDList

(PIDL, InFolder);

FlinkName := ''+ FCaption + '.lnk';

LinkName := InFolder + FlinkName;

IPFile.Save(PWChar(LinkName), false);

end;

 

Kullanımı:

DesktopShortcut('C:/windows/notepad.exe','Notepad');

 

Delphi - .....................................

 

Delphi -- Database İpuçları

Delphi -- Database İpuçları

 

 

 

1. İstenilen alanları Combobox'a yazdırma...

 

procedure TForm1.FormCreate(Sender: TObject);

begin

with Table1 do begin

DisableControls;

try

First

while not EOF do begin

with MyCombo.Items do

Objects[Add(FieldByName('Terms').AsString)] := Pointer((FieldByName('EmpNo').AsInteger));

Next;

end;

finally

EnableControls;

end;

end;

end;

 

procedure TForm1.MyComboClick(Sender: TObject);

var EmpNo: Integer;

begin

with MyCombo do

EmpNo:=LongInt(Items.Objects[ ItemIndex ]);

ShowMessage('Emp.No.: ' + IntToStr(EmpNo));

End;

 

 

 

2. Query'de SQL kullanarak arama yapmak...

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Query1.Close;

Query1.Sql.Clear;

Query1.Sql.Add('Select * From Database Where Adi like "'+Edit1.text+'%"');

Query1.Open;

End;

 

 

 

3. Table'da istenilen alana göre arama yapmak

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Table1.Locate('AlanAdi',Edit1.Text,[]);

end;

 

4. Table'da her tuşa basışta girilen kadarının uyduğu kayıdı bulma...

 

procedure TForm1.Edit1Change(Sender: TObject);

begin

Table1.FindNearst([Edit1.Text]);

end;

 

 

 

5. Table'da indexli alana göre arama yapmak...

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Table1.FindKey([Edit1.text]);

end;

 

Delphi - .....................................

 

Delphi -- Database İpuçları

Delphi -- Database İpuçları

 

 

 

1. İstenilen alanları Combobox'a yazdırma...

 

procedure TForm1.FormCreate(Sender: TObject);

begin

with Table1 do begin

DisableControls;

try

First

while not EOF do begin

with MyCombo.Items do

Objects[Add(FieldByName('Terms').AsString)] := Pointer((FieldByName('EmpNo').AsInteger));

Next;

end;

finally

EnableControls;

end;

end;

end;

 

procedure TForm1.MyComboClick(Sender: TObject);

var EmpNo: Integer;

begin

with MyCombo do

EmpNo:=LongInt(Items.Objects[ ItemIndex ]);

ShowMessage('Emp.No.: ' + IntToStr(EmpNo));

End;

 

 

 

2. Query'de SQL kullanarak arama yapmak...

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Query1.Close;

Query1.Sql.Clear;

Query1.Sql.Add('Select * From Database Where Adi like "'+Edit1.text+'%"');

Query1.Open;

End;

 

 

 

3. Table'da istenilen alana göre arama yapmak

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Table1.Locate('AlanAdi',Edit1.Text,[]);

end;

 

4. Table'da her tuşa basışta girilen kadarının uyduğu kayıdı bulma...

 

procedure TForm1.Edit1Change(Sender: TObject);

begin

Table1.FindNearst([Edit1.Text]);

end;

 

 

 

5. Table'da indexli alana göre arama yapmak...

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Table1.FindKey([Edit1.text]);

end;

 

Delphi - .....................................

 

Delphi -- Graphic İpuçları

Delphi -- Graphic İpuçları

 

1. 3D Yazı yazmak..

 

procedure imgPaintCanvas(TheCanvas : TCanvas; TheString : String; TheFontSize, UCorner, LCorner : Integer);

Begin

TheCanvas.Brush.Style := bsClear;

TheCanvas.Font.Style := [fsBold];

TheCanvas.Font.Name := 'MS Sans Serif';

TheCanvas.Font.Size := TheFontSize;

TheCanvas.Font.Color := clBlack;

TheCanvas.TextOut(UCorner, LCorner, TheString);

TheCanvas.Font.Color := clGray;

TheCanvas.TextOut(UCorner - 1, LCorner - 1, TheString);

TheCanvas.Font.Color := clSilver;

TheCanvas.TextOut(UCorner - 2, LCorner - 2, TheString);

TheCanvas.Font.Color := clBlack;

TheCanvas.TextOut(UCorner - 3, LCorner - 3, TheString);

End;

//Şöyle Çalışıyor

imgPaintCanvas(Image3.Canvas, '0', 10, 6, 4);

 

 

 

2. Form da MetaFile çizmek...

 

implementation

 

{$R *.DFM}

 

type

TMetafileCanvas = class(TCanvas)

private

FClipboardHandle: THandle;

FMetafileHandle: HMetafile;

FRect: TRect;

protected

procedure CreateHandle; override;

function GetMetafileHandle: HMetafile;

public

constructor Create;

destructor Destroy; override;

property Rect: TRect read FRect write FRect;

property MetafileHandle: HMetafile read GetMetafileHandle;

end;

 

constructor TMetafileCanvas.Create;

begin

inherited Create;

FClipboardHandle := GlobalAlloc(

GMEM_SHARE or GMEM_ZEROINIT, SizeOf(TMetafilePict));

end;

 

destructor TMetafileCanvas.Destroy;

begin

DeleteMetafile(CloseMetafile(Handle));

if Bool(FClipboardHandle) then GlobalFree(FClipboardHandle);

if Bool(FMetafileHandle) then DeleteMetafile(FMetafileHandle);

inherited Destroy;

end;

 

procedure TMetafileCanvas.CreateHandle;

var

MetafileDC: HDC;

begin

 

MetafileDC := CreateMetaFile(nil);

if Bool(MetafileDC) then

begin

with FRect do SetWindowOrg(MetafileDC, Left - 10, Top - 10);

with FRect do SetWindowExt(MetafileDC, Right - Left + 20, Bottom - Top + 20);

if Bool(FMetafileHandle) then

begin

PlayMetafile(MetafileDC, FMetafileHandle);

end;

end;

Handle := MetafileDC;

end;

 

function TMetafileCanvas.GetMetafileHandle: HMetafile;

var

MetafilePict: PMetafilePict;

IC: HDC;

ExtRect: TRect;

begin

if Bool(FMetafileHandle) then DeleteMetafile(FMetafileHandle);

FMetafileHandle := CloseMetafile(Handle);

Handle := 0;

MetafilePict := GlobalLock(FClipboardHandle);

MetafilePict^.mm := mm_AnIsoTropic;

IC := CreateIC('DISPLAY', nil, nil, nil);

SetMapMode(IC, mm_HiMetric);

ExtRect := FRect;

DPtoLP(IC, ExtRect, 2);

DeleteDC(IC);

MetafilePict^.xExt := ExtRect.Right - ExtRect.Left;

MetafilePict^.yExt := ExtRect.Top - ExtRect.Bottom;

MetafilePict^.HMF := FMetafileHandle;

GlobalUnlock(FClipboardHandle);

Result := FClipboardHandle;

end;

 

procedure TForm1.BitBtn1Click(Sender: TObject);

var

MetafileCanvas : TMetafileCanvas;

begin

MetafileCanvas := TMetafileCanvas.Create;

MetafileCanvas.Rect := Rect(0,0,500,500);

MetafileCanvas.Ellipse(10,10,400,400);

Image1.Picture.Metafile.LoadFromClipboardFormat(cf_MetafilePict, MetafileCanvas.MetafileHandle, 0);

MetafileCanvas.Free;

end;

end.

 

 

 

3. Forma Bitmap kaplanması...

 

var

Form1: TForm1;

Bitmap: TBitmap;

implementation

 

{$R *.DFM}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

Bitmap := TBitmap.Create;

Bitmap.LoadFromFile('C:WINDOWShasir.bmp');

end;

 

procedure TForm1.FormPaint(Sender: TObject);

var

X, Y, W, H: LongInt;

begin

with Bitmap do

begin

W := Width;

H := Height;

end;

Y := 0;

while Y < Height do

begin

X := 0;

while X < Width do

begin

Canvas.Draw(X, Y, Bitmap);

Inc(X, W);

end;

Inc(Y, H);

end;

end;

end.

 

 

 

4.Transparan Bitmap nasıl yapılır...

 

procedure DrawTrans(DestCanvas: TCanvas; X,Y: smallint; SrcBitmap: TBitmap; AColor, BackColor: TColor);

var ANDBitmap, ORBitmap: TBitmap;

CM: TCopyMode;

Src: TRect;

begin

ANDBitmap:= NIL;

ORBitmap:= NIL;

try

ANDBitmap:= TBitmap.Create;

ORBitmap:= TBitmap.Create;

Src := Bounds(0,0, SrcBitmap.Width, SrcBitmap.Height);

with ORBitmap do begin

Width:= SrcBitmap.Width;

Height:= SrcBitmap.Height;

Canvas.Brush.Color := clBlack;

Canvas.CopyMode := cmSrcCopy;

Canvas.BrushCopy(Src, SrcBitmap, Src, AColor);

end;

with ANDBitmap do begin

Width:= SrcBitmap.Width;

Height:= SrcBitmap.Height;

Canvas.Brush.Color := BackColor;

Canvas.CopyMode := cmSrcInvert;

Canvas.BrushCopy(Src, SrcBitmap, Src, AColor);

end;

with DestCanvas do begin

CM := CopyMode;

CopyMode := cmSrcAnd;

Draw(X,Y, ANDBitmap);

CopyMode := cmSrcPaint;

Draw(X,Y, ORBitmap);

CopyMode := CM;

end;

finally

ANDBitmap.Free;

ORBitmap.Free;

end;

end;

 

Kullanımı :

DrawTrans(Image2.Canvas, 0,0, 'C:Windowsdeepblue.bmp', clBlack, clSilver);

 

Delphi - .....................................

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol