Solved

how to simulate key press on button click?

Posted on 2004-09-08
33
8,098 Views
Last Modified: 2008-01-09
My form have 11 labelededits and 10 buttons from 0..9
i will use touchscreen monitor and i want to simulate keybord clicks
i want to make key 1 press if button1 clicked ... make key 0 press if button 10 pressed
How can i do so?
0
Comment
Question by:selas
  • 10
  • 6
  • 5
  • +4
33 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12006431
you could use the keybd_event-api
or thw wm_keydoen/wm_keyup-messages

it depends, if you want to send the key to a control (then messages)
or not (keybd_event will apply the key to the focused control)

explain a bit more

meikl ;-)
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12006438
Possible solution

procedure TForm1.Button1Click(Sender: TObject);
begin
 SelectedLabeledEdit.Text :=SelectedLabeledEdit.Text + inttostr(TButton(Sender).Tag);
end;

Just give each edit the appropriate Tag ranging 0..9
And add this to each OnEnter event of each edit:

procedure TForm1.Edit1Enter(Sender: TObject);
begin
 SelectedLabeledEdit :=TEdit(Sender);
end;

with SelectedLabeledEdit:

private
property SelectedLabeledEdit: TEdit read fSelectedLabeledEdit write fSelectedLabeledEdit;

I've included the unit for 1 button and 1 edit:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Edit1Enter(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    fSelectedLabeledEdit: TEdit;
  public
    { Public declarations }
    property SelectedLabeledEdit: TEdit read fSelectedLabeledEdit write fSelectedLabeledEdit;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 fSelectedLabeledEdit :=nil;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
 SelectedLabeledEdit :=TEdit(Sender);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if SelectedLabeledEdit = nil then exit;
 SelectedLabeledEdit.Text :=SelectedLabeledEdit.Text + inttostr(TButton(Sender).Tag);
end;

end.

Set the SelectedLabeledEdit to nil when the form is created...

Kind regards,
Evarest
0
 
LVL 4

Accepted Solution

by:
Evarest earned 250 total points
ID: 12006488
And a complete example:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Edit2: TEdit;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Edit1Enter(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    fSelectedLabeledEdit: TEdit;
  public
    { Public declarations }
    property SelectedLabeledEdit: TEdit read fSelectedLabeledEdit write fSelectedLabeledEdit;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 fSelectedLabeledEdit :=nil;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
 SelectedLabeledEdit :=TEdit(Sender);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if SelectedLabeledEdit = nil then exit;
 SelectedLabeledEdit.Text :=SelectedLabeledEdit.Text + inttostr(TButton(Sender).Tag);
end;

end.


[DFM CODE]
object Form1: TForm1
  Left = 192
  Top = 162
  Width = 783
  Height = 540
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Shell Dlg 2'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Edit1: TEdit
    Left = 8
    Top = 8
    Width = 121
    Height = 21
    TabOrder = 0
    OnEnter = Edit1Enter
  end
  object Button1: TButton
    Tag = 1
    Left = 168
    Top = 72
    Width = 25
    Height = 25
    Caption = '1'
    TabOrder = 1
    OnClick = Button1Click
  end
  object Edit2: TEdit
    Left = 8
    Top = 32
    Width = 121
    Height = 21
    TabOrder = 2
    OnEnter = Edit1Enter
  end
  object Button2: TButton
    Tag = 2
    Left = 192
    Top = 72
    Width = 25
    Height = 25
    Caption = '2'
    TabOrder = 3
    OnClick = Button1Click
  end
  object Button3: TButton
    Tag = 3
    Left = 216
    Top = 72
    Width = 25
    Height = 25
    Caption = '3'
    TabOrder = 4
    OnClick = Button1Click
  end
  object Button4: TButton
    Tag = 4
    Left = 168
    Top = 96
    Width = 25
    Height = 25
    Caption = '4'
    TabOrder = 5
    OnClick = Button1Click
  end
  object Button5: TButton
    Tag = 5
    Left = 192
    Top = 96
    Width = 25
    Height = 25
    Caption = '5'
    TabOrder = 6
    OnClick = Button1Click
  end
  object Button6: TButton
    Tag = 6
    Left = 216
    Top = 96
    Width = 25
    Height = 25
    Caption = '6'
    TabOrder = 7
    OnClick = Button1Click
  end
  object Button7: TButton
    Tag = 7
    Left = 168
    Top = 120
    Width = 25
    Height = 25
    Caption = '7'
    TabOrder = 8
    OnClick = Button1Click
  end
  object Button8: TButton
    Tag = 9
    Left = 216
    Top = 120
    Width = 25
    Height = 25
    Caption = '9'
    TabOrder = 9
    OnClick = Button1Click
  end
  object Button9: TButton
    Tag = 8
    Left = 192
    Top = 120
    Width = 25
    Height = 25
    Caption = '8'
    TabOrder = 10
    OnClick = Button1Click
  end
  object Button10: TButton
    Left = 192
    Top = 144
    Width = 25
    Height = 25
    Caption = '0'
    TabOrder = 11
    OnClick = Button1Click
  end
  object Edit3: TEdit
    Left = 8
    Top = 56
    Width = 121
    Height = 21
    TabOrder = 12
    OnEnter = Edit1Enter
  end
  object Edit4: TEdit
    Left = 8
    Top = 80
    Width = 121
    Height = 21
    TabOrder = 13
    OnEnter = Edit1Enter
  end
  object Edit5: TEdit
    Left = 8
    Top = 104
    Width = 121
    Height = 21
    TabOrder = 14
    OnEnter = Edit1Enter
  end
  object Edit6: TEdit
    Left = 8
    Top = 128
    Width = 121
    Height = 21
    TabOrder = 15
    OnEnter = Edit1Enter
  end
  object Edit7: TEdit
    Left = 8
    Top = 152
    Width = 121
    Height = 21
    TabOrder = 16
    OnEnter = Edit1Enter
  end
  object Edit8: TEdit
    Left = 8
    Top = 176
    Width = 121
    Height = 21
    TabOrder = 17
    OnEnter = Edit1Enter
  end
  object Edit9: TEdit
    Left = 8
    Top = 200
    Width = 121
    Height = 21
    TabOrder = 18
    OnEnter = Edit1Enter
  end
  object Edit10: TEdit
    Left = 8
    Top = 224
    Width = 121
    Height = 21
    TabOrder = 19
    OnEnter = Edit1Enter
  end
  object Edit11: TEdit
    Left = 8
    Top = 248
    Width = 121
    Height = 21
    TabOrder = 20
    OnEnter = Edit1Enter
  end
  object Edit12: TEdit
    Left = 8
    Top = 272
    Width = 121
    Height = 21
    TabOrder = 21
    OnEnter = Edit1Enter
  end
end


Just create a new application, rightclick the form, choose View as Text and copypaste the dfm code there.

Evarest
0
 

Author Comment

by:selas
ID: 12006595
if i use Keybd_event(VK_NUMPAD1, 0, 0, 0 );
nothing heppens...
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12006626
That's why I simply use the code above. It's only 6 lines of code (the DPR you don't need to code, it's all the comps on your form)...

Each comp has a Tag and by using this you can add that tag as a character to the selected edit.

Kind regards,
Evarest
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12006647
use SendMessage. SendMessage has format:

SendMessage(Button1.Handle, WM_KEYDOWN, VK_RETURN, 0);

this simulate Enter key pressed on Button1.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12006669
well, you must also release the key like

      keybd_event(VK_NUMPAD1, 0, 0, 0);  //press key
      keybd_event(VK_NUMPAD1, 0,KEYEVENTF_KEYUP,0); //release key

or also

      keybd_event(ord('1'), 0, 0, 0);
      keybd_event(ord('1'), 0,KEYEVENTF_KEYUP,0);

but as i said this event is sent to the focused control,
and as you click on a button, the button will be the focused control

explain a bit more about, where shall the key displayed

maybe, i'm on a wrong track and evarest knows what you want to archive      

meikl ;-)
0
 

Author Comment

by:selas
ID: 12006710
yes on button1 click nothing typed in selected labelededit and button focused...
how to solve this?
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12006759
Personally I'm at a loss :-) As selas posted in his question, his question was to be able to use a touchscreen to input values in an edit. He used 10 buttons which each have a number ranging from 0-9. If a button is touched the value is inserted in the selected Edit.

This all can be achived with the code above. However, as selas doesn't seem to use or try out that code, I'm not sure whether it's of any use or not... Please let me know what you really want, so i might be able to be of some help :-)

Kind regards,
Evarest
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12006763
>yes on button1 click nothing typed in selected labelededit
in this case use the wm_keydown/wm_keyup-messages
-> see ivanov's sample and use the labelededit-handle instead

or, if it is in the same app, you can go with evarest's suggestion

meikl ;-)
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12007277
Doesn't a touchscreen come with a driver that translates touches to mouseclicks?
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12007480
meikl one  is the best one method...

just set your buttons tag from 48 (for 0) to 57 (for 9) then in the buttonclick (the same for all buttons) this:

procedure TForm1.Button1Click(Sender: TObject);
begin
keybd_event(TButton(Sender).tag, 0, 0, 0);
keybd_event(TButton(Sender).tag, 0,KEYEVENTF_KEYUP,0);

end;
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12007577
or better agai using sendmessage to send directly to the selected edit

procedure TForm1.Button2Click(Sender: TObject);
begin
SendMessage(edit1.handle, WM_KEYDOWN, TButton(Sender).tag, 0);
SendMessage(edit1.handle, WM_CHAR, TButton(Sender).tag, 0);
SendMessage(edit1.handle, WM_KEYUP, TButton(Sender).tag, 0);
end;
0
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 250 total points
ID: 12008193
unit Unit1_Q_21122981;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Panel1: TPanel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
  private    { Private declarations }
  public     { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  CH:     Char;
  VK:     DWORD; // Cardinal;
begin
  CH := (Sender as TSpeedButton).Caption[1];
  VK := Ord(CH);
  keybd_event(VK, MapVirtualKey(VK, 0), 0, 0);
end;

end.

//........

object Form1: TForm1
  Left = 224
  Top = 128
  Width = 320
  Height = 352
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Edit1: TEdit
    Left = 128
    Top = 16
    Width = 121
    Height = 21
    TabOrder = 0
  end
  object Edit2: TEdit
    Left = 128
    Top = 46
    Width = 121
    Height = 21
    TabOrder = 1
  end
  object Edit3: TEdit
    Left = 128
    Top = 76
    Width = 121
    Height = 21
    TabOrder = 2
  end
  object Edit4: TEdit
    Left = 128
    Top = 106
    Width = 121
    Height = 21
    TabOrder = 3
  end
  object Edit5: TEdit
    Left = 128
    Top = 136
    Width = 121
    Height = 21
    TabOrder = 4
  end
  object Edit6: TEdit
    Left = 128
    Top = 167
    Width = 121
    Height = 21
    TabOrder = 5
  end
  object Edit7: TEdit
    Left = 128
    Top = 197
    Width = 121
    Height = 21
    TabOrder = 6
  end
  object Edit8: TEdit
    Left = 128
    Top = 227
    Width = 121
    Height = 21
    TabOrder = 7
  end
  object Edit9: TEdit
    Left = 128
    Top = 257
    Width = 121
    Height = 21
    TabOrder = 8
  end
  object Edit10: TEdit
    Left = 128
    Top = 288
    Width = 121
    Height = 21
    TabOrder = 9
  end
  object Panel1: TPanel
    Left = 12
    Top = 16
    Width = 80
    Height = 96
    Caption = ' '
    TabOrder = 10
    object SpeedButton1: TSpeedButton
      Left = 2
      Top = 50
      Width = 23
      Height = 22
      Caption = '1'
      OnClick = SpeedButton1Click
    end
    object SpeedButton2: TSpeedButton
      Left = 26
      Top = 50
      Width = 23
      Height = 22
      Caption = '2'
      OnClick = SpeedButton1Click
    end
    object SpeedButton3: TSpeedButton
      Left = 50
      Top = 50
      Width = 23
      Height = 22
      Caption = '3'
      OnClick = SpeedButton1Click
    end
    object SpeedButton4: TSpeedButton
      Left = 2
      Top = 28
      Width = 23
      Height = 22
      Caption = '4'
      OnClick = SpeedButton1Click
    end
    object SpeedButton5: TSpeedButton
      Left = 26
      Top = 28
      Width = 23
      Height = 22
      Caption = '5'
      OnClick = SpeedButton1Click
    end
    object SpeedButton6: TSpeedButton
      Left = 50
      Top = 28
      Width = 23
      Height = 22
      Caption = '6'
      OnClick = SpeedButton1Click
    end
    object SpeedButton7: TSpeedButton
      Left = 2
      Top = 6
      Width = 23
      Height = 22
      Caption = '7'
      OnClick = SpeedButton1Click
    end
    object SpeedButton8: TSpeedButton
      Left = 26
      Top = 6
      Width = 23
      Height = 22
      Caption = '8'
      OnClick = SpeedButton1Click
    end
    object SpeedButton9: TSpeedButton
      Left = 50
      Top = 6
      Width = 23
      Height = 22
      Caption = '9'
      OnClick = SpeedButton1Click
    end
    object SpeedButton10: TSpeedButton
      Left = 2
      Top = 72
      Width = 23
      Height = 22
      Caption = '0'
      OnClick = SpeedButton1Click
    end
  end
end

<<
following merged from comment ID: 12008712

download my example from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21122981.zip
 
kretzschmar
Page Editor
>>
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12008359
just to append to the suggestion above, by using the keybd_event
(just stealing f68's code above)

procedure TForm1.Button1Click(Sender: TObject);
var control : Tcomponent
begin
  control := findcomponent('Edit'+inttostr(TButton(Sender).tag-47));
  if (assigned(control)) and (control is TEdit) then
  begin
    TEdit(control).SetFocus;  //shift the focus to the control, which should receive the key
    Application.ProcessMessages; //maybe not needed
    keybd_event(TButton(Sender).tag, 0, 0, 0);
    keybd_event(TButton(Sender).tag, 0,KEYEVENTF_KEYUP,0);
  end;
end;

just from head

meikl ;-)
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12008712
download my example from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21122981.zip
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12011389
Hello, I asked: Doesn't a touchscreen come with a driver that translates touches to mouseclicks?

Well, does it?
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12011416
And why do I ask? I just wonder why you would translate mouse messages into key messages so you could then handle the key events. Why not just handle the mouse events?

And one tip. On the MouseDown event you can send the OnKeyDown event and on the MouseUp event you just send the OnKeyUp event. Thus you can even handle repeating keypresses if you really want to simulate them. But I do think it's a bit silly...
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12011672
Workshop_Alex: "Thus you can even handle repeating keypresses if you really want to simulate them"

that's why i can't understand the problem any more...
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12014326
Well, in my opinion....
-->Doesn't a touchscreen come with a driver that translates touches to mouseclicks?
Yes it does. I guess that here he's creating a sort of cash register using a numerical keypad on touchscreen.
So a touch on the screen is treated like a mouse click and it's ok. What he wants is a keybord event to write the values on some edit fields as if he's typing directly on keyboard numerical keypad....That's my guess of course, and i could be completely wrong, but if it's so the way could be that one suggested here by most of us using kb_event or sendmessage...
Also consider that the use of a touchscreen is intended for skip keyboards and mouses, so the link to an event of these become obsolete....

That's just my opinion of course :)

F68 ;-)
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12014403
What I think he wants is some onscreen keyboard that sends keypresses to whatever control that has focus on that moment. Thus, there's an edit-control and key messages must be sent to it. His onscreen keyboard should make this possible.
The problem, I think, is that whenever a button is clicked, the focus changes to this button. Thus any keypress event <i>will be send to this button!</i> (I know html doesn't work but it's for emphatism) This is why nothing happens on the Keybd_event() method. The keys are sent to the button and from there they're just ignored.

What he actually needs, I think, is a way to put the focus back to the original control and send the keyboard events to that control! (And this control could be an external application even.) I could be wrong, though. But I think selas wants the keypresses to be sent to the control that had the focus right before the button got focus...
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12014443
From the initial question "My form have 11 labelededits and 10 buttons from 0..9".

This line indicates that both the edits as the buttons are located _on the same_ form. Thus, no need for "complicated" KeyPress Events,  or messages from any kind, as you simply can write code like you normally do. When the user clicks a button, here touches one, the code behind it will execute and do whatever you want it to do. I really don't see the use for such keybd_event(TButton(Sender).tag, 0, 0, 0);...

Just use
procedure TForm1.Button1Click(Sender: TObject);
begin
 SelectedLabeledEdit.Text :=SelectedLabeledEdit.Text + inttostr(TButton(Sender).Tag);
end;
And all will work just fine, no need to worry about focussed or not, as that focussing is done in the onEnter of each Edit.

Evarest
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12014500
--> as that focussing is done in the onEnter of each Edit.
SO you mean that before you need to find wich is the selected...
Something like
var SelectedLabeledEdit: TLabeledEdit;

procedure TForm1.LabeledEdit1Enter(Sender: TObject);
begin
   SelectedLabeledEdit := TLabeledEdit(Sender);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
 If assigned(SelectedLabeledEdit) then
 SelectedLabeledEdit.Text :=SelectedLabeledEdit.Text + inttostr(TButton(Sender).Tag);
end;

Yes Evarest, if this is the scenario your idea could be easly applied...

F68 ;-)
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12014558
About my last comment: this thread is becoming a bit long, as i've just posted an already full coded example by Evarest (forgotten and misreaded it). Sorry Evarest, i'll keep more attention re-reading threads before to post comments in the future :)

F68 ;-)
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12014936
Notting to worry about, let's maybe now wait for selas to better specify what he needs (if there still is any need for it...)

Evarest
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12015108
> My form have 11 labelededits and 10 buttons from 0..9
> ....
> i want to make key 1 press if button1 clicked ... make key 0 press if button 10 pressed

I think the problem is:
  - when a TButton is pressed the focused TLabeledEdit loses the focus: this is the reason that the simulated key press on button click does not apper into the just-losed focus TLabeledEdit;
 - So my solution is based on using TSpeedButtons instead of TButtons. As is known TSpeedButton never gets the focus, so LabeledEdit1 gets the simulated key-presses until it is focused .... After the user clicks on another LabeledEditX and then clicks a lots of times on SpeedButtons this way LabeledEditX gets the simulated key-presses until it is focused.

Download my solution from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21122981.zip
and you will see it works perfect !
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12015146
Indeed, the buttons will loose focus. But in my example above I used TButtons and that still worked, as i remember the last focused TEdit.
Of course, that's inheritely the same as your example...

Evarest
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12015445
Evarest,
Your example is not a universal one, because you make obligatory next digit to be added after all already existing digits into the TLabeledEdit. This is unnatural behaviour of the TLabeledEdit;
But it is possible in my example to click somewhere between existing characters into the TLabeledEdit ant on the next clicks on TSpeedButtons the new simulated key-presses will be inserted where is the cursor placed: this is the natural behaviour !
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12015475
Something more, I can select some symbols into a TLabeledEdit and when I press a SpeedButton, it will replace selected symbols with a digit: the natural behaviour again ....
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12015919
esoftbg, I'm sorry, but personally I don't know about the TLabeledEdit. I don't use it in any of my projects...

If indeed this can be done with your code, then i gladly accept that. However, you can modify my code too, to accomplish what you're saying...

Kind regards,
Evarest
0
 
LVL 4

Expert Comment

by:Evarest
ID: 12015931
Btw, it's a touchscreen, and i don't think the person's fingers will be able to accurately set the mouse cursor on a selpos :-) Better just to do a TEdit.SelectAll and replace the entire text...
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12016758
Hi Evarest,

TLabeledEdit appears at the Additional tab of the Delphi 7 components palette .... (TLabeledEdit or TEdit) It does not matter about the context of this question ....

I have not been say anything about your solution before your try to explain that:

> Of course, that's inheritely the same as your example...

I just wanted to say that it is not true ;-)) Just my solution (simple and elegant) is different ....

I don't like to change your code, you may do that better ;-))

Best Regards,
Emil
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now