Solved

Delphi Programming Question

Posted on 1997-09-29
5
163 Views
Last Modified: 2010-04-04
I want to capitalize the first letter of each word entered in a comboxbox - while the user types.  I don't want to do it on exit so I know I have to catch the keystroke, I just don't know how to just capitaize the first letter only using one of the 'Upper' functions.

Secondly, the Delphi manaual says to use the Abort procedure to cancel Post actions if used in the BeforePost event.  I get a compile error when I try - if "if edit1.text = '' then abort;" and "Statement expected, but expression of type 'Integer' found.  What is the correct syntax?
0
Comment
Question by:d4jaj1
[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
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1346451
Hi d4jaj1,

Q1 :

procedure TForm1.ComboBox1Change(Sender: TObject);
var HelpStr : String;
begin
 if ComboBox1.GetTextLen = 1 then
  begin
   HelpStr := UpperCase(ComboBox1.text[1]);
   ComboBox1.Text := HelpStr;
   ActiveControl := ComboBox1;
  end;
end;

But that's not all, because now the cursor is back in the beginning of the line. You need a SendKey function. With this you can send the VK_END. You can find sendkey functions on every delphi site.
Maybe there is another solution (easier), I don't know.

Q2 : I don't get that error?

 if edit1.text = '' then Abort;

 Are you sure you're using the correct syntax?
0
 
LVL 4

Expert Comment

by:itamar
ID: 1346452
Q1) If you increase the points i can give you a piece of code of just ONE line that really works without the use of sendkeys.

Believe me, it works !

Q2)isn't it the old ; missing in the previous line ?? ;)
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1346453
itamar,

Unfortunately, I only had 20 points when I posted the question, so that's all I could give. Also, I figured it was an easy question, i.e., most experienced Delphi developers would have the answer without needing to think about it or look it up.  I believe I was correct in my assumption since you answer is only one line of code.  The 5 points I added is all I have.  Please help.

Zifnab,

Thanks for your effort, I guess I will use you response if itamar won't help.

0
 
LVL 4

Accepted Solution

by:
itamar earned 20 total points
ID: 1346454
Ok, that is it: (for the challenge - yes i thought about- , not the points)
>>>
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
 if ComboBox1.SelStart = 0 then key := UpperCase(string(key))[1];
end;

You have about 20 questions answered for low points !
I suggest you ask for more to Experts-Exchange or click in the banner to get more points.
(http://www.experts-exchange.com/topics/bin/GenQuiz).
Remember: the default number for Easy questions is 50.
At least give me an A ;) (I hope this helps)
Regards,
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1346455
Your answer worked perfectly!!  Since you looked at th ereast of my answers, I'm sure you noticed I allways give A's - as long as you answer the question correctly.  Thanks for the 'Gift' and I will remember your efforts the next time I post a question with a significant amount of points.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Mdi application Child forms get behind control 7 359
RESTRequest Parameter 4 81
enhance the following code 3 53
shape, triangle, dbctrlgrid 3 46
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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