Programlama yapalım ve Öğrenelim. - Delphi Eğitim91
  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

UTCTIMETOLOCALTIME

function UniversalTimeToLocal(UT: TDateTime): TDateTime;

var

LT: TDateTime;

TZOffset: Integer;

TZInfo: TTimeZoneInformation;

begin

GetTimeZoneInformation(TZInfo);

LT := UT;

// Determine offset in effect for DateTime UT.

if DaylightSavings(UT) then

TZOffset := TZInfo.Bias + TZInfo.DaylightBias

else

TZOffset := TZInfo.Bias + TZInfo.StandardBias;

// Apply offset.

if (TZOffset > 0) then

// Time zones west of Greenwich.

LT := UT - EncodeTime(TZOffset div 60,

TZOffset mod 60, 0, 0)

else if (TZOffset = 0) then

// Time Zone = Greenwich.

LT := UT

else if (TZOffset < 0) then

// Time zones east of Greenwich.

LT := UT + EncodeTime(Abs(TZOffset) div 60,

Abs(TZOffset) mod 60, 0, 0);

// Return Local Time.

Result := LT;

end;

 

/////////////////////  KULLANIM

 

procedure TForm1.Button5Click(Sender: TObject);

begin

ShowMessage(DateTimeToStr(UniversalTimeToLocal(DateTimePicker1.DateTime)));

end;

 

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

 

FORMUN TASINMA OLAYINI ALGILA (NOTIFY)

//1,YOL

 

type

  TForm1 = class(TForm)

  private

    procedure WMMove(var Msg: TWMMove); message WM_MOVE;

    { Private-Deklarationen}

  public

    { Public-Deklarationen}

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMMove(var Msg: TWMMove);

begin

  inherited;

  ShowMessage('Form has moved!');

end;

 

end.

 

 

//2.OL

  private

    { Private declarations }

    procedure WMNCHitTest(var M: TWMNCHitTest);

       message WM_NCHitTest;

    procedure WMNCLButtonDown(var Msg : TWMNCLButtonDown);

       message WM_NCLBUTTONDOWN;

...

var

  basliktan:boolean;

implementation

...

procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);

begin

inherited;

if M.Result = htCaption then

 if basliktan then begin

  islemler;

  basliktan:=false;

  end;

end;

 

procedure TForm1.WMNCLButtonDown(var Msg : TWMNCLButtonDown);

begin

  inherited;

  if (Msg.HitTest = htCaption) then

    basliktan:=true;

end;

 

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

 

FORMUN TASINMA OLAYINI ALGILA (NOTIFY)

//1,YOL

 

type

  TForm1 = class(TForm)

  private

    procedure WMMove(var Msg: TWMMove); message WM_MOVE;

    { Private-Deklarationen}

  public

    { Public-Deklarationen}

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMMove(var Msg: TWMMove);

begin

  inherited;

  ShowMessage('Form has moved!');

end;

 

end.

 

 

//2.OL

  private

    { Private declarations }

    procedure WMNCHitTest(var M: TWMNCHitTest);

       message WM_NCHitTest;

    procedure WMNCLButtonDown(var Msg : TWMNCLButtonDown);

       message WM_NCLBUTTONDOWN;

...

var

  basliktan:boolean;

implementation

...

procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);

begin

inherited;

if M.Result = htCaption then

 if basliktan then begin

  islemler;

  basliktan:=false;

  end;

end;

 

procedure TForm1.WMNCLButtonDown(var Msg : TWMNCLButtonDown);

begin

  inherited;

  if (Msg.HitTest = htCaption) then

    basliktan:=true;

end;

 

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

 

BILGISAYARIN KAPANMA ANINI TESPIT ETME (NOTIFY)

{

  To detect a Windows Shutdown, you must trap the

  WM_EndSession message.

  Declare a message handling procedure in your Form's Private section.

 

  Um herauszufinden, ob Windows heruntergefahren wird, muss

  die WM_EndSession abgefangen werden.

}

 

 

type

  TForm1 = class(TForm)

  private

    procedure WMEndSession(var Msg: TWMEndSession); message WM_ENDSESSION;

  public

  end;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMEndSession(var Msg: TWMEndSession);

begin

  if Msg.EndSession = True then

    ShowMessage('Windows is shutting down!');

  inherited;

end;

 

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

 

BILGISAYARIN KAPANMA ANINI TESPIT ETME (NOTIFY)

{

  To detect a Windows Shutdown, you must trap the

  WM_EndSession message.

  Declare a message handling procedure in your Form's Private section.

 

  Um herauszufinden, ob Windows heruntergefahren wird, muss

  die WM_EndSession abgefangen werden.

}

 

 

type

  TForm1 = class(TForm)

  private

    procedure WMEndSession(var Msg: TWMEndSession); message WM_ENDSESSION;

  public

  end;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMEndSession(var Msg: TWMEndSession);

begin

  if Msg.EndSession = True then

    ShowMessage('Windows is shutting down!');

  inherited;

end;

 

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

 

CD KONULDUGUNU ALGILAMA (NOTIFY)

type

  TForm1 = class(TForm)

  private

    procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;

  public

 

  end;

 

{...}

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMDeviceChange(var Msg: TMessage);

const

  DBT_DEVICEARRIVAL = $8000; // system detected a new device

  DBT_DEVICEREMOVECOMPLETE = $8004;  // device is gone

var

  myMsg: string;

begin

  inherited;

  case Msg.wParam of

    DBT_DEVICEARRIVAL: myMsg  := 'CD inserted!';

    DBT_DEVICEREMOVECOMPLETE: myMsg := 'CD removed!';

  end;

  ShowMessage(myMsg);

end;

 

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

 

CD KONULDUGUNU ALGILAMA (NOTIFY)

type

  TForm1 = class(TForm)

  private

    procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;

  public

 

  end;

 

{...}

 

implementation

 

{$R *.DFM}

 

procedure TForm1.WMDeviceChange(var Msg: TMessage);

const

  DBT_DEVICEARRIVAL = $8000; // system detected a new device

  DBT_DEVICEREMOVECOMPLETE = $8004;  // device is gone

var

  myMsg: string;

begin

  inherited;

  case Msg.wParam of

    DBT_DEVICEARRIVAL: myMsg  := 'CD inserted!';

    DBT_DEVICEREMOVECOMPLETE: myMsg := 'CD removed!';

  end;

  ShowMessage(myMsg);

end;

 

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

 

CD NIN CIKARILIP TAKILDIGINDAN HABERDAR OLMA (NOTIFY)

//CD'nin takılıp çıkarıldığından haberdar olma

//Bunun için WM_DEVICECHANGE mesajlarını yakalamamız lazım.

 

private kısmına aşağıdaki satırı ekleyin :

procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;

 

//bu da yakalama kısmı :

 

procedure TForm1.WMDeviceChange (var Msg: TMessage);

const

  CD_IN = $8000;

  CD_OUT = $8004;

var

  Mesaj : String;

begin

  inherited;

  case Msg.wParam of

    CD_IN : Mesaj := 'CD takıldı';

    CD_OUT : Mesaj := 'CD çıkarıldı';

  end;

  ShowMessage(Mesaj);

end;

 

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

 

CD NIN CIKARILIP TAKILDIGINDAN HABERDAR OLMA (NOTIFY)

//CD'nin takılıp çıkarıldığından haberdar olma

//Bunun için WM_DEVICECHANGE mesajlarını yakalamamız lazım.

 

private kısmına aşağıdaki satırı ekleyin :

procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;

 

//bu da yakalama kısmı :

 

procedure TForm1.WMDeviceChange (var Msg: TMessage);

const

  CD_IN = $8000;

  CD_OUT = $8004;

var

  Mesaj : String;

begin

  inherited;

  case Msg.wParam of

    CD_IN : Mesaj := 'CD takıldı';

    CD_OUT : Mesaj := 'CD çıkarıldı';

  end;

  ShowMessage(Mesaj);

end;

 

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

 

EKRAN COZUNURLUGU DEGISIKLIKLERINI ALGILAMA (NOTIFY)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

 

type

  TForm1 = class(TForm)

  private

    { Private declarations }

  public

    { Public declarations }

      procedure WMDisplayChange( var msg : TWMDisplayChange );message wm_DisplayChange;

  end;

 

var

  Form1: TForm1;

implementation

 

{$R *.DFM}

procedure tform1.WMDisplayChange( var msg : TWMDisplayChange );

begin

      showmessage('Renk=2 üzeri '+inttostr(msg.BitsPerPixel)+

                  ' En='+inttostr(msg.width)+

                  ' Boy='+inttostr(msg.height))

end;

 

end.

 

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

 

EKRAN COZUNURLUGU DEGISIKLIKLERINI ALGILAMA (NOTIFY)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

 

type

  TForm1 = class(TForm)

  private

    { Private declarations }

  public

    { Public declarations }

      procedure WMDisplayChange( var msg : TWMDisplayChange );message wm_DisplayChange;

  end;

 

var

  Form1: TForm1;

implementation

 

{$R *.DFM}

procedure tform1.WMDisplayChange( var msg : TWMDisplayChange );

begin

      showmessage('Renk=2 üzeri '+inttostr(msg.BitsPerPixel)+

                  ' En='+inttostr(msg.width)+

                  ' Boy='+inttostr(msg.height))

end;

 

end.

 

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

 

EKRAN KORUYUCUYU CALISTIRMA VE CALISTIGINDAN HABERDAR OLMA(NOTIFY)

{

Bazi durumlarda programiniz calisirken ekran koruyucunun devreye

girmesini istemeyebilirsiniz ekran koruyucunun islemci kullanimini

artirmasindan dolayi. Özellikle kullanicinin islem yapmadigi

fakat programin devamli isler yaptigi (Seri Porttan veri transferi vb)

durumlarda faydali olabilir.

}

 

uses

  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,

  Controls, Forms, Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    CheckBox1: TCheckBox;

    Label1: TLabel;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

    procedure WMSysCommand(VAR Msg: TWMSysCommand);

      message WM_SYSCOMMAND;

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

// Ekran koruyucuyu calistir

procedure TForm1.Button1Click(Sender: TObject);

begin

  Perform(WM_SYSCOMMAND, SC_SCREENSAVE, 0);

end;

 

// Ekran koruyucu devreye girmek uzere

procedure TForm1.WMSysCommand(VAR Msg: TWMSysCommand);

BEGIN

  IF (Msg.CmdType AND $FFF0) = SC_SCREENSAVE THEN

    IF CheckBox1.Checked THEN

      BEGIN

        Msg.Result := 0;

        Label1.Captiion := 'Ekran koruyucunun calismasi durduruldu';

        Exit;

      END

    ELSE Label1.Captiion := 'Ekran koruyucu calisti';

  Inherited;

END;

 

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

 

EKRAN KORUYUCUYU CALISTIRMA VE CALISTIGINDAN HABERDAR OLMA(NOTIFY)

{

Bazi durumlarda programiniz calisirken ekran koruyucunun devreye

girmesini istemeyebilirsiniz ekran koruyucunun islemci kullanimini

artirmasindan dolayi. Özellikle kullanicinin islem yapmadigi

fakat programin devamli isler yaptigi (Seri Porttan veri transferi vb)

durumlarda faydali olabilir.

}

 

uses

  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,

  Controls, Forms, Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    CheckBox1: TCheckBox;

    Label1: TLabel;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

    procedure WMSysCommand(VAR Msg: TWMSysCommand);

      message WM_SYSCOMMAND;

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

// Ekran koruyucuyu calistir

procedure TForm1.Button1Click(Sender: TObject);

begin

  Perform(WM_SYSCOMMAND, SC_SCREENSAVE, 0);

end;

 

// Ekran koruyucu devreye girmek uzere

procedure TForm1.WMSysCommand(VAR Msg: TWMSysCommand);

BEGIN

  IF (Msg.CmdType AND $FFF0) = SC_SCREENSAVE THEN

    IF CheckBox1.Checked THEN

      BEGIN

        Msg.Result := 0;

        Label1.Captiion := 'Ekran koruyucunun calismasi durduruldu';

        Exit;

      END

    ELSE Label1.Captiion := 'Ekran koruyucu calisti';

  Inherited;

END;

 

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

 

FORMUN AVTIF-PASIF EDILDIGINI YAKALA - ONENTER / ONLEAVE (NOTIFY)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

  StdCtrls;

 

type

  TForm1 = class(TForm)

    Label1: TLabel;

    Button1: TButton;

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);

  private

    { Private declarations }

    FFocusControl: TControl;

    procedure ApplicationIdle(Sender: TObject; var Done: Boolean);

  public

    { Public declarations }

    procedure OnEnter(Sender: TObject);

    procedure OnExit(Sender: TObject);

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

  FFocusControl := nil;

  Application.OnIdle := ApplicationIdle;

end;

 

procedure TForm1.FormDestroy(Sender: TObject);

begin

  Application.OnIdle := nil;

end;

 

procedure TForm1.ApplicationIdle(Sender: TObject; var Done: Boolean);

var

  CurControl: TControl;

  P: TPoint;

begin

  GetCursorPos(P);

  CurControl := FindDragTarget(P, True);

  if FFocusControl <> CurControl then

  begin

    if FFocusControl <> nil then

      OnExit(FFocusControl);

    FFocusControl := CurControl;

    if FFocusControl <> nil then

      OnEnter(FFocusControl);

  end;

end;

 

procedure TForm1.OnEnter(Sender: TObject);

begin

  //OnEnter code

  if sender = Button1 then

  begin

    Label1.caption := 'Hello';

    Button1.Caption := 'Exit';

  end;

end;

 

procedure TForm1.OnExit(Sender: TObject);

begin

  //OnExit code

  if sender = Button1 then

  begin

    Label1.caption := 'Godbye';

    Button1.Caption := 'Enter';

  end;

end;

 

end.

 

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

 

FORMUN AVTIF-PASIF EDILDIGINI YAKALA - ONENTER / ONLEAVE (NOTIFY)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

  StdCtrls;

 

type

  TForm1 = class(TForm)

    Label1: TLabel;

    Button1: TButton;

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);

  private

    { Private declarations }

    FFocusControl: TControl;

    procedure ApplicationIdle(Sender: TObject; var Done: Boolean);

  public

    { Public declarations }

    procedure OnEnter(Sender: TObject);

    procedure OnExit(Sender: TObject);

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

  FFocusControl := nil;

  Application.OnIdle := ApplicationIdle;

end;

 

procedure TForm1.FormDestroy(Sender: TObject);

begin

  Application.OnIdle := nil;

end;

 

procedure TForm1.ApplicationIdle(Sender: TObject; var Done: Boolean);

var

  CurControl: TControl;

  P: TPoint;

begin

  GetCursorPos(P);

  CurControl := FindDragTarget(P, True);

  if FFocusControl <> CurControl then

  begin

    if FFocusControl <> nil then

      OnExit(FFocusControl);

    FFocusControl := CurControl;

    if FFocusControl <> nil then

      OnEnter(FFocusControl);

  end;

end;

 

procedure TForm1.OnEnter(Sender: TObject);

begin

  //OnEnter code

  if sender = Button1 then

  begin

    Label1.caption := 'Hello';

    Button1.Caption := 'Exit';

  end;

end;

 

procedure TForm1.OnExit(Sender: TObject);

begin

  //OnExit code

  if sender = Button1 then

  begin

    Label1.caption := 'Godbye';

    Button1.Caption := 'Enter';

  end;

end;

 

end.

 

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

 

MEDIAPLAYERIN CALMAYI IPTAL ETTIGINI TESPIT ETME (NOTIFY)

Uyarı eylemi gerçekleştiğinde, Notify özelliği False olarak geri resetlenir.

Bu nedenle daha ileriki uyarı eylemlerini almak için kod içerisinde onu tekrar True

olarak değiştirmeniz gerekir.

~~~~~~~~~~~~~~~~~~~~~~~~~

procedure TForm1.FormCreate(Sender: TObject) ;

begin

   MediaPlayer1.Notify := True;

   MediaPlayer1.OnNotify := NotifyProc;

end;

 

procedure TForm1.NotifyProc(Sender: TObject) ;

begin

   with Sender as TMediaPlayer do

   begin

     case Mode of

       mpStopped: {DO something HERE};

     end;

//Daha ileriki uyarı için True olarak ayarlanması gerekir.

     Notify := True;

   end;

end;

~~~~~~~~~~~~~~~~~~~~~~~~~

 

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

 

MEDIAPLAYERIN CALMAYI IPTAL ETTIGINI TESPIT ETME (NOTIFY)

Uyarı eylemi gerçekleştiğinde, Notify özelliği False olarak geri resetlenir.

Bu nedenle daha ileriki uyarı eylemlerini almak için kod içerisinde onu tekrar True

olarak değiştirmeniz gerekir.

~~~~~~~~~~~~~~~~~~~~~~~~~

procedure TForm1.FormCreate(Sender: TObject) ;

begin

   MediaPlayer1.Notify := True;

   MediaPlayer1.OnNotify := NotifyProc;

end;

 

procedure TForm1.NotifyProc(Sender: TObject) ;

begin

   with Sender as TMediaPlayer do

   begin

     case Mode of

       mpStopped: {DO something HERE};

     end;

//Daha ileriki uyarı için True olarak ayarlanması gerekir.

     Notify := True;

   end;

end;

~~~~~~~~~~~~~~~~~~~~~~~~~

 

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

 

PLUG AND PLAY DONANIM DEGISIKLIKLERINI IZLEME (NOTIFY)

type

  TForm1 = class(TForm)

    Button1: TButton;

  private

    { Private declarations }

    procedure WMDeviceChange(var Message: TMessage);

      message WM_DEVICECHANGE;

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

const DBT_DEVICEARRIVAL = $8000;

const DBT_DEVICEQUERYREMOVE = $8001;

const DBT_DEVICEQUERYREMOVEFAILED = $8002;

const DBT_DEVICEREMOVEPENDING = $8003;

const DBT_DEVICEREMOVECOMPLETE = $8004;

const DBT_DEVICETYPESPECIFIC = $8005;

const DBT_CONFIGCHANGED = $0018;

 

procedure TForm1.WMDeviceChange(var Message: TMessage);

var

  s : string;

begin

{Do Something here}

  case Message.wParam of

    DBT_DEVICEARRIVAL :

      s := 'A device has been inserted and is now available';

    DBT_DEVICEQUERYREMOVE: begin

      s := 'Permission to remove a device is requested';

      ShowMessage(s);

     {True grants premission}

      Message.Result := integer(true);

      exit;

    end;

    DBT_DEVICEQUERYREMOVEFAILED :

      s := 'Request to remove a device has been canceled';

    DBT_DEVICEREMOVEPENDING :

      s := 'Device is about to be removed';

    DBT_DEVICEREMOVECOMPLETE :

      s := 'Device has been removed';

    DBT_DEVICETYPESPECIFIC :

      s := 'Device-specific event';

    DBT_CONFIGCHANGED :

      s:= 'Current configuration has changed'

    else s := 'Unknown Device Message';

  end;

  ShowMessage(s);

  inherited;

end;

 

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

 

PLUG AND PLAY DONANIM DEGISIKLIKLERINI IZLEME (NOTIFY)

type

  TForm1 = class(TForm)

    Button1: TButton;

  private

    { Private declarations }

    procedure WMDeviceChange(var Message: TMessage);

      message WM_DEVICECHANGE;

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

const DBT_DEVICEARRIVAL = $8000;

const DBT_DEVICEQUERYREMOVE = $8001;

const DBT_DEVICEQUERYREMOVEFAILED = $8002;

const DBT_DEVICEREMOVEPENDING = $8003;

const DBT_DEVICEREMOVECOMPLETE = $8004;

const DBT_DEVICETYPESPECIFIC = $8005;

const DBT_CONFIGCHANGED = $0018;

 

procedure TForm1.WMDeviceChange(var Message: TMessage);

var

  s : string;

begin

{Do Something here}

  case Message.wParam of

    DBT_DEVICEARRIVAL :

      s := 'A device has been inserted and is now available';

    DBT_DEVICEQUERYREMOVE: begin

      s := 'Permission to remove a device is requested';

      ShowMessage(s);

     {True grants premission}

      Message.Result := integer(true);

      exit;

    end;

    DBT_DEVICEQUERYREMOVEFAILED :

      s := 'Request to remove a device has been canceled';

    DBT_DEVICEREMOVEPENDING :

      s := 'Device is about to be removed';

    DBT_DEVICEREMOVECOMPLETE :

      s := 'Device has been removed';

    DBT_DEVICETYPESPECIFIC :

      s := 'Device-specific event';

    DBT_CONFIGCHANGED :

      s:= 'Current configuration has changed'

    else s := 'Unknown Device Message';

  end;

  ShowMessage(s);

  inherited;

end;

 

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

 

YAZICIDAKI DOSYALARI DURDUR & DEVAM ET & TUM DOSYALARI SIL

Uses Winspool, printers;

 

Function GetCurrentPrinterHandle: THandle;

  Const

    Defaults: TPrinterDefaults = (

      pDatatype : nil;

      pDevMode  : nil;

      DesiredAccess : PRINTER_ACCESS_USE or PRINTER_ACCESS_ADMINISTER );

  Var

    Device, Driver, Port : array[0..255] of char;

    hDeviceMode: THandle;

  Begin { GetCurrentPrinterHandle }

    Printer.GetPrinter(Device, Driver, Port, hDeviceMode);

    If not OpenPrinter(@Device, Result, @Defaults) Then

      RaiseLastWin32Error;

  End; { GetCurrentPrinterHandle }

 

{: Kill all pending jobs on the current printer }

Procedure PurgeJobsOnCurrentPrinter;

  Var

    hPrinter: THandle;

  Begin

    hPrinter:= GetCurrentPrinterHandle;

    try

      If not WinSpool.SetPrinter( hPrinter, 0, nil, PRINTER_CONTROL_PURGE )

      Then

        RaiseLastWin32Error;

    finally

      ClosePrinter( hPrinter );

    end;

  End; { PurgeJobsOnCurrentPrinter }

 

Yukarıdda "PRINTER_CONTROL_PAUSE" yere

 

PRINTER_CONTROL_PAUSE ->koyarsan duraklatır

 

PRINTER_CONTROL_RESUME -> koyarsan duraklamayı kaldırı

 

PRINTER_CONTROL_PURGE ->koyarsan bütün giden dosyalar siler (aynı anda galiba duraklatıyor ama emin değilim)

 

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

 

YAZICIDAKI DOSYALARI DURDUR & DEVAM ET & TUM DOSYALARI SIL

Uses Winspool, printers;

 

Function GetCurrentPrinterHandle: THandle;

  Const

    Defaults: TPrinterDefaults = (

      pDatatype : nil;

      pDevMode  : nil;

      DesiredAccess : PRINTER_ACCESS_USE or PRINTER_ACCESS_ADMINISTER );

  Var

    Device, Driver, Port : array[0..255] of char;

    hDeviceMode: THandle;

  Begin { GetCurrentPrinterHandle }

    Printer.GetPrinter(Device, Driver, Port, hDeviceMode);

    If not OpenPrinter(@Device, Result, @Defaults) Then

      RaiseLastWin32Error;

  End; { GetCurrentPrinterHandle }

 

{: Kill all pending jobs on the current printer }

Procedure PurgeJobsOnCurrentPrinter;

  Var

    hPrinter: THandle;

  Begin

    hPrinter:= GetCurrentPrinterHandle;

    try

      If not WinSpool.SetPrinter( hPrinter, 0, nil, PRINTER_CONTROL_PURGE )

      Then

        RaiseLastWin32Error;

    finally

      ClosePrinter( hPrinter );

    end;

  End; { PurgeJobsOnCurrentPrinter }

 

Yukarıdda "PRINTER_CONTROL_PAUSE" yere

 

PRINTER_CONTROL_PAUSE ->koyarsan duraklatır

 

PRINTER_CONTROL_RESUME -> koyarsan duraklamayı kaldırı

 

PRINTER_CONTROL_PURGE ->koyarsan bütün giden dosyalar siler (aynı anda galiba duraklatıyor ama emin değilim)

 

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

 

FULL KEY TUŞLARI VE NUMLOCK CAPSLOCK (ALINTI)

//CAPSLOCK VE NUMLOCK ÖRNEĞİ

procedure ToggleNumLock;

var

   KeyState: TKeyboardState;

begin

   //note: Use VK_CAPITAL for Caps Lock

 

   GetKeyboardState(KeyState) ;

 

   //simulate key events (down + up)

   if (KeyState[VK_NUMLOCK] = 0) then

   begin

     Keybd_Event(VK_NUMLOCK, 1, KEYEVENTF_EXTENDEDKEY or 0, 0) ;

     Keybd_Event(VK_NUMLOCK, 1, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;

   end

   else

   begin

     Keybd_Event(VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY or 0, 0) ;

     Keybd_Event(VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;

   end;

end;

//***************

(hexadecimal) Keyboard (or mouse) equivalent

VK_LBUTTON 01 Left mouse button

VK_RBUTTON 02 Right mouse button

VK_CANCEL 03 Control-break processing

VK_MBUTTON 04 Middle mouse button (three-button mouse)

VK_BACK 08 BACKSPACE key

VK_TAB 09 TAB key

VK_CLEAR 0C CLEAR key

VK_RETURN 0D ENTER key

VK_SHIFT 10 SHIFT key

VK_CONTROL 11 CTRL key

VK_MENU 12 ALT key

VK_PAUSE 13 PAUSE key

VK_CAPITAL 14 CAPS LOCK key

VK_ESCAPE 1B ESC key

VK_SPACE 20 SPACEBAR

VK_PRIOR 21 PAGE UP key

VK_NEXT 22 PAGE DOWN key

VK_END 23 END key

VK_HOME 24 HOME key

VK_LEFT 25 LEFT ARROW key

VK_UP 26 UP ARROW key

VK_RIGHT 27 RIGHT ARROW key

VK_DOWN 28 DOWN ARROW key

VK_SELECT 29 SELECT key

VK_PRINT 2A PRINT key

VK_EXECUTE 2B EXECUTE key

VK_SNAPSHOT 2C PRINT SCREEN key

VK_INSERT 2D INS key

VK_DELETE 2E DEL key

VK_HELP 2F HELP key

 30 0 key

 31 1 key

 32 2 key

 33 3 key

 34 4 key

 35 5 key

 36 6 key

 37 7 key

 38 8 key

 39 9 key

 41 A key

 42 B key

 43 C key

 44 D key

 45 E key

 46 F key

 47 G key

 48 H key

 49 I key

 4A J key

 4B K key

 4C L key

 4D M key

 4E N key

 4F O key

 50 P key

 51 Q key

 52 R key

 53 S key

 54 T key

 55 U key

 56 V key

 57 W key

 58 X key

 59 Y key

 5A Z key

VK_NUMPAD0 60 Numeric keypad 0 key

VK_NUMPAD1 61 Numeric keypad 1 key

VK_NUMPAD2 62 Numeric keypad 2 key

VK_NUMPAD3 63 Numeric keypad 3 key

VK_NUMPAD4 64 Numeric keypad 4 key

VK_NUMPAD5 65 Numeric keypad 5 key

VK_NUMPAD6 66 Numeric keypad 6 key

VK_NUMPAD7 67 Numeric keypad 7 key

VK_NUMPAD8 68 Numeric keypad 8 key

VK_NUMPAD9 69 Numeric keypad 9 key

VK_SEPARATOR 6C Separator key

VK_SUBTRACT 6D Subtract key

VK_DECIMAL 6E Decimal key

VK_DIVIDE 6F Divide key

VK_F1 70 F1 key

VK_F2 71 F2 key

VK_F3 72 F3 key

VK_F4 73 F4 key

VK_F5 74 F5 key

VK_F6 75 F6 key

VK_F7 76 F7 key

VK_F8 77 F8 key

VK_F9 78 F9 key

VK_F10 79 F10 key

VK_F11 7A F11 key

VK_F12 7B F12 key

VK_F13 7C F13 key

VK_F14 7D F14 key

VK_F15 7E F15 key

VK_F16 7F F16 key

VK_F17 80H F17 key

VK_F18 81H F18 key

VK_F19 82H F19 key

VK_F20 83H F20 key

VK_F21 84H F21 key

VK_F22 85H F22 key

VK_F23 86H F23 key

VK_F24 87H F24 key

VK_NUMLOCK 90 NUM LOCK key

VK_SCROLL 91 SCROLL LOCK key

VK_LSHIFT A0 Left SHIFT key

VK_RSHIFT A1 Right SHIFT key

VK_LCONTROL A2 Left CONTROL key

VK_RCONTROL A3 Right CONTROL key

VK_LMENU A4 Left MENU key

VK_RMENU A5 Right MENU key

VK_PLAY FA Play key

VK_ZOOM FB Zoom key

 

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

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