Solved

Delphi Programming Question

Posted on 1997-09-29
5
160 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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