Delphi Can

Orjinalini görmek için tıklayınız: InputBox'a Date girme
Şu anda (Arşiv) modunu görüntülemektesiniz. Orjinal Sürümü Görüntüle internal link
Merhaba arkadaşlar.

Geçenlerde lazım olan bir problemimin çözümünü sizlerle de paylaşmak istedim.
Not: Anakodları google dan bulup biraz değiştirip Tarih formatına değiştirdim. Hangi siteden aldığımı hatırlamıyorum

InputBox'a tarih değeri alıp işlemek için:


function InputValor(const aCaption: String; APrompt: string; var aValor: String): Boolean;
var
  vForm: TForm;
  vLabel: TLabel;
  vBtnOk: TBitBtn;
  vValor: TDateTimePicker;
  vBtnCancel: TBitBtn;
begin
  Result := False;
  vForm := TForm.Create(application);
  vLabel := TLabel.Create(vForm);
  vValor := TDateTimePicker.Create(vForm);
  vBtnOk := TBitBtn.Create(vForm);
  vBtnCancel := TBitBtn.Create(vForm);

  with vForm do
  begin
    Name := 'frmValor';
    Position := poOwnerFormCenter;
    BorderIcons := [biSystemMenu];
    BorderStyle := bsDialog;
    Caption := aCaption;
    ClientHeight := 100;
    ClientWidth := 200;
    Color := clBtnFace;
    OldCreateOrder := False;
    Font.Charset := DEFAULT_CHARSET;
    Font.Color := clWindowText;
    Font.Height := -11;
    Font.Name := 'Tahoma';
    Font.Style := [];
    OldCreateOrder := False;
    PixelsPerInch := 96;
    Left := 0;
    top := 0;
  end;

  with vLabel do
  begin
    Name := 'vLabel';
    Parent := vForm;
    AutoSize := False;
    Font.Style := [fsBold];
    Left := 15;
    top := 15;
    Width := 150;
    Height := 21;
    Caption := APrompt;
    WordWrap := True;
  end;

  with vValor do
  begin
    Name := 'vValorEdit';
    Parent := vForm;
    Left := 15;
    top := 35;
    Width := 150;
    Height := 21;
//    Date:=Date();
  end;

  with vBtnOk do
  begin
    Name := 'vBtnOk';
    Parent := vForm;
    Caption := 'Tamam';
    Left := 15;
    top := 65;
    Width := 75;
    Height := 25;
    TabOrder := 1;
    ModalResult := mrOk;
  end;

  with vBtnCancel do
  begin
    Name := 'vBtnCancel';
    Parent := vForm;
    Caption := 'İptal';
    Left := 100;
    top := 65;
    Width := 75;
    Height := 25;
    TabOrder := 2;
    ModalResult := mrCancel;
  end;

  vForm.showmodal;

  if (vForm.ModalResult = mrOk) and (Datetostr(vValor.date) <> '') then
  begin
    Result := True;
    aValor := datetostr(vValor.date);
  end
  else
  begin
    Result := False;
    aValor := '';
  end;

  FreeAndNil(vForm);
end;




Kullanımı:


var
  GirTarih: String;
begin
  if (InputValor('Fiyatı Değişen Ürünler', 'Tarih Giriniz:', GirTarih) = True) then
     Showmessage(GirTarih
);