Arsip: pake Enter buat pengganti tab

 
user image
more 13 years ago

shindo

kk sekalian, mohon info nya ... biasanya kalo kita buat form isian, kan utk pindah antar field pada form dengan menggunakan tab ... nah, kalo misalnya diinginkan untuk pake tombol enter buat pengganti Tab tsb, bagaimana caranya ? soalnya ini di kantor banyak yg suka pake enter karena program sebelumnya pakai DOS, yg notabene pindah field nya pake tombol Enter mohon pencerahannya thx a lot sebelumnya
user image
more 13 years ago

R-One

buat di event keypress key:=#13 <--enter
user image
more 13 years ago

DelphiExpert


if Key =#13then // atau Key = VK_RETURN
begin
  Key:=#0;
  SendMessage(Handle, WM_NEXTDLGCTL, 0, 0);
end;
letakkan code tsb. di event OnKeyPress / OnKeyDown ... bisa diletakkan pada tiap2 control yg dikehendaki atau cukup pada TForm dengan set KeyPreview:= True;
user image
more 13 years ago

MrLee

coba komponen turunan nya TEDIT nih

unit EditTab;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
type
  TEditTab = class(TEdit)
  private
    { Private declarations }
    parentHwnd: HWND;
  protected
    { Protected declarations }
    procedure WMKeyDown (var Msg: TMessage); message WM_KEYDOWN;
  public
    { Public declarations }
    constructor Create (AOwner: TComponent); override;
  end;
procedure Register;
implementation
constructor TEditTab.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  parentHwnd := (AOwner as TForm).Handle;
end;
procedure TEditTab.WMKeyDown (var Msg: TMessage);
var
  VirtKey: integer;
begin
  inherited;
  VirtKey := Msg.wParam;
  if (VirtKey = VK_RETURN) or (VirtKey = VK_DOWN) then
    PostMessage (parentHwnd, WM_NEXTDLGCTL, 0, 0)
  else if (VirtKey = VK_UP) then
    PostMessage (parentHwnd, WM_NEXTDLGCTL, 1, 0);
end;
procedure Register;
begin
  RegisterComponents('MrLee', [TEditTab]);
end;
end.
jadi tinggal ambil komponen TEditTab aja; kalu dbedit cukup ganti TEditTab = class(TEdit) menjadi TDbEditTab = class(TDbEdit) semoga berguna
user image
more 13 years ago

shindo

wah ... langsung berhasil ... tadinya sudah nyoba2 gak berhasil terus ... ternyata baru tau ada yg kurang : KeyPreview=true itu yg belon thx a lot utk semuanya
user image
more 13 years ago

andi_yon84

k2 sekalian , saya mau tanya gmana cara buat validasi tanggal, biar inputannya tanggal aja, pada event on exit.makasih
user image
more 13 years ago

mas_kofa

@andi_yon84 procedure Tfrm1.edInputKeyPress(Sender: TObject; var Key: Char); begin if not (key in ) then key :=#0; end; procedure Tfrm1.edInputExit(Sender: TObject); begin if not tryStrToDate(edinput.text,tgl) then begin showmessage('tanggal salah'); edinput.setfocus; end; end; napa gak pake DateTimePicker aja
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com