🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #194

Re: A simple quetion

#194
From: Feza
Date: Mon, 26 Jan 2004 14:10
100 lines
3435 bytes
> unit Geneller;
>
> interface
>
> uses
>    Windows, Classes, Controls;
>
> type
>    TFormManager = class
>    public
>      procedure DBEditKeyPress(Sender: TObject; var Key: Char);
>    end;
>
>
> implementation
>
> type
>    TWinControlHacker = class(TWinControl); // needed because SelectNext
> is protected
>
> procedure TFormManager.DBEditKeyPress(Sender: TObject; var Key: Char);
> var
>    ParCtrl: TWinControl;
> begin
>    if (Sender is TWinControl) and (Key = #13) then
>    begin
>      ParCtrl := TWinControl(Sender).Parent;
>      if HiWord(GetKeyState(VK_SHIFT)) <> 0 then
>
> TWinControlHacker(ParCtrl).selectNext(TWinControl(Sender),False,TRUE)
>      else
>
TWinControlHacker(ParCtrl).SelectNext(TWinControl(Sender),True,True);
>      Key := #0
>    end;
> end;
>
> end.
>
> You need to create an instance of TFormManager in your formCreate
> procedure and assign its DBEditKeyPress to the OnKeyPressEvent of
> all you edit fields.
>

I have all those you mention above.Althought compiler doesn't complain about
coding, if you try to try to jump over control by pressing Enter key, it
just do nothing.No respone at all.
in every event handler of Dbedit controls, i made assignment;


unit Geneller;
interface

uses windows, controls,dbgrids;

type
   TFormManager = class
   public
     procedure DBEditKeyPress(Sender: TObject; var Key: Char);
   end;

var
Formmanager : TFormManager;

implementation

type
   TWinControlHacker = class(TWinControl)

procedure TFormManager.DBEditKeyPress(Sender: TObject; var Key: Char);
var
   ParCtrl: TWinControl;
begin
   if (Sender is TWinControl) and (Key = #13) then
   begin
     ParCtrl := TWinControl(Sender).Parent;
     if HiWord(GetKeyState(VK_SHIFT)) <> 0 then

TWinControlHacker(ParCtrl).selectNext(TWinControl(Sender),False,TRUE)
     else
       TWinControlHacker(ParCtrl).SelectNext(TWinControl(Sender),True,True);
     Key := #0
   end;
end;

end.

in my main, i made such assignment,

procedure TForm1.FormCreate(Sender: TObject);
begin
Dbedit1.onkeypress := Formmanager.DBEditKeyPress;
Dbedit2.onkeypress := Formmanager.DBEditKeyPress;
Dbedit3.onkeypress := Formmanager.DBEditKeyPress;
end;

i could't find any mistake

Regards
FEZA
Technical Details
Message-ID: <40151fda@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4012ed90@newsgroups.borland.com> <4012eec6@newsgroups.borland.com> <4012f408@newsgroups.borland.com> <4012fa59$1@newsgroups.borland.com> <4012fe55@newsgroups.borland.com> <40130a29$1@newsgroups.borland.com> <4013115d@newsgroups.borland.com> <40131b3d$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,12a8917f3c14f275
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2004-01-26 06:32:06 PST
From: "Feza" <------>
Newsgroups: borland.public.delphi.language.objectpascal
References: <4012ed90@newsgroups.borland.com> <4012eec6@newsgroups.borland.com> <4012f408@newsgroups.borland.com> <4012fa59$1@newsgroups.borland.com> <4012fe55@newsgroups.borland.com> <40130a29$1@newsgroups.borland.com> <4013115d@newsgroups.borland.com> <40131b3d$1@newsgroups.borland.com>
Subject: Re: A simple quetion
Date: Mon, 26 Jan 2004 16:10:17 +0200
Lines: 102
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 81.6.90.37
Message-ID: <40151fda@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075126234 81.6.90.37 (26 Jan 2004 06:10:34 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail