| |

VerySource

 Forgot password?
 Register
Search
View: 754|Reply: 6

I want to reload KEYDOWN to move the focus with the arrow keys. Why isn't it easy to use?

[Copy link]

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-2 10:00:01
| Show all posts |Read mode
unit SunEdit;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Mask, Windows, Graphics, Messages, RzEdit;

type
// TSunEdit = class (TRzEdit)
  TSunEdit = class (TEdit)
  private
    {Private declarations}
  protected
    {Protected declarations}
    procedure KeyDown (var Key: Word; Shift: TShiftState); override;
  public
    {Public declarations}
    constructor Create (AOwner: TComponent); override;
  published
    {Published declarations}
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents ('SunComponent', [TSunEdit]);
end;

constructor TSunEdit.Create (AOwner: TComponent);
begin
  inherited Create (AOwner);
// self.FrameVisible: = true;
end;

procedure TSunEdit.KeyDown (var Key: Word; Shift: TShiftState);
begin

  inherited;

 IF ((KEY = Windows.VK_DOWN) or (KEY = Windows.VK_RETURN)) THEN
  begin
   perform (WM_NEXTDLGCTL, 0,0); // move to the next control
    self.Caption: = inttostr (ord (key));
  end;
  {
 else
 IF (KEY = Windows.VK_up) THEN
   perform (WM_NEXTDLGCTL, 1,0); // Move to the previous control
   }

end;


end.
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-24 17:15:01
| Show all posts
procedure TForm1.FormCreate (Sender: TObject);
begin
  KeyPreview: = True;
end;

procedure TForm1.FormKeyDown (Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    VK_DOWN: if ActiveControl is TEdit then Perform (WM_NEXTDLGCTL, 0, 0);
    VK_UP: if ActiveControl is TEdit then Perform (WM_NEXTDLGCTL, 1, 0);
  end;
end;
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-25 10:15:01
| Show all posts
This should be written on each FROM, I want to put this function directly on TEDIT, can it be achieved?
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-25 12:45:01
| Show all posts
I mean, I want to put the function of using the direction to move the focus on my own EDIT control, how do I achieve it
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-28 15:30:01
| Show all posts
Which big brother helps me, I want to put the function of using the arrow keys to move the focus on my EDIT control, so that it will be convenient for later use, is there a way?
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-28 20:45:01
| Show all posts
IF ((KEY=Windows.VK_DOWN) or (KEY=Windows.VK_RETURN)) THEN
  begin
   Parent.Perform(WM_NEXTDLGCTL,0,0);//Move to the next control
// ~~~~~~
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-28 22:00:01
| Show all posts
Thank youGuderian(expert outpatient cleaner)
I'm so touched
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list