Solved

Delphi Programming Question

Posted on 1997-09-29
5
159 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

17 Experts available now in Live!

Get 1:1 Help Now