?
Solved

How can i use Tab key in RichEdit Delphi

Posted on 2005-03-14
21
Medium Priority
?
633 Views
Last Modified: 2008-01-09
In my application  i am  using a dbRichText Control, i want to use the Tab Key just like word applications do, how can i use this function, when i press the tab key the focus goes to another control,

Best Regards
Thooloon
0
Comment
Question by:thooloon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 5
  • +1
21 Comments
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13532878
Hi,

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #0 then begin
    if (Sender is TDBGrid) then
      TDBGrid(Sender).Perform(WM_KeyDown,VK_Tab,0)
    else
      Perform(Wm_NextDlgCtl,0,0);
  end;
end;


Best regards,
Raisor
0
 
LVL 1

Author Comment

by:thooloon
ID: 13533036
I am using a DBRichEdit Control connected to a database the above solution does not work,
thanks
Thoo
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13533093
Hi,

It wasn't meant to be a working solution ... it was a simple example showing how the tab key works in delphi ... you'll have to apply the example's logic to your own code to make it work!


Best regards,
Raisor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:thooloon
ID: 13533592

i have applied the logic anfd used the code in the keypress event of the richedit control but it does not work

regards
Thooloon
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13533641
Hi,

Could you provide the peace of code you've used, please?


Best regards,
Raisor
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13534625
0
 
LVL 1

Author Comment

by:thooloon
ID: 13537341
Hi,

This is my code, please check

procedure TForm2.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #0 then begin
    if (Sender is TrichEdit) then
      TrichEdit(Sender).Perform(WM_KeyDown,VK_Tab,0)
    else
      Perform(Wm_NextDlgCtl,0,0);
  end;
end;


Best Regards
Thooloon
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13537799
Hi,

I'm not really a crack using Delphi (a friend of mine almost is a crack! ... I can't reach him currently!) ... but one thing I've seen is that you're using:

procedure TForm2.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #0 then begin
    if (Sender is TrichEdit) then
      TrichEdit(Sender).Perform(WM_KeyDown,VK_Tab,0)
    else
      Perform(Wm_NextDlgCtl,0,0);
  end;
end;

... you might try ...

procedure TForm2.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #0 then begin
    if (Sender is TRichEdit) then
      TRichEdit(Sender).Perform(WM_KeyDown,VK_Tab,0)
    else
      Perform(Wm_NextDlgCtl,0,0);
  end;
end;

... just in case there's some "case sensitivity" to respect!


Best regards,
Raisor
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13537919
Hi,

This one should do it as "Key = #9" obviously is the "Tab-Key" ...

procedure TForm2.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #9 then begin
    Key := #0;
    if (Sender is TRichEdit) then
      TRichEdit(Sender).Perform(WM_KeyDown,VK_Tab,0)
    else
      Perform(Wm_NextDlgCtl,0,0);
  end;
end;


Best regards,
Raisor
0
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 500 total points
ID: 13540790
Never really used Delphi before but isnt there a property in the propertys window to allow you to change that like there is in visual basic ?
0
 
LVL 1

Author Comment

by:thooloon
ID: 13542424
thanks all for the help,

Best Regads
Thooloon
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13542426
Thanks for the grade and points ! Very much appreciated :)
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13542482
... my best regards @gecko ;-))
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13542528
what makes you say that Raisor ? :D
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13542539
I cant believe the amount of points I have gotten in the last month and being in that top 15 list is a huge achievment for me :) I must admit :) I thouroughly LOVE programming and I really want to learn as much as possible about programming ! I guess I was always taught that the simplest solutions are to some extent the best ones :) Just depends on the problem at hand :)
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13542765
Hi,

... it was definitely nothing offending that made me state "my best regards @gecko" <- thooloon decided to give the points to you ... and that's absolutely ok for me! ... the only thing astonishing me (positively!) was the simpleness of your answer ... as the original question was about a Tab KEY that should have sent the focus to another control ;-}


Best regards,
Raisor
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13547088
lol - Not sure if you have ever heard of this saying but "KISS" which means " Keep it simple stupid " :) Anyway, Be great to stay in touch with you, I will  most likey learn quite a lot from you not to mention other experts on this forum and by subscribing to other questions :)

I was not offended, I just wasn't expecting the points to start with because I havent really used delphi that much and I wasnt even sure that the property existed in delphi, I just know its a one in visual basic and figured I would put that there just to point it out :)

I gotta admit, personally I love the simple answers :). Call me lazy or w/e but I like them a lot lol :)

In all honesty I thought you or one of the other experts would get the points because all your answers and suggestions were in code and not really having used delphi, the coding made a little bit of sense to me but I would really have to use Delphi for me to really understand what it all did , etc :)

I am working on it though LOL :)
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 13548270
Hi,

... thanks for your feedback, Gecko ... I'm happy that thooloon has received what he was looking for!


Best regards,
Raisor
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13548328
Me 2, I was shocked myself when I opened my email and it said Good Answer! for this question, I was like ok I am fully awake and no Im not on drugs lol. Then I was like ok let me go look to make sure I am not tripping lol.

It was great meeting you though Raisor ! as an expert and as a fellow programmer !

Kind regards

Gecko
0
 
LVL 1

Author Comment

by:thooloon
ID: 13553325
Hi Gecko and Raisor,

Actually i am very thankfull to both of you, coz u both has helped me. specially Raisor took a lot of effort to help me.

Best Regards
Mohamaed Thooloon
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13554638
Raisor is great with helping, sticks with you till you get the problem sorted out !
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 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