Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi Programming Question

Posted on 1997-09-29
5
Medium Priority
?
165 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 80 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 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