BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deriving TEdit (TEditNumber)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Matrix
Guest





PostPosted: Tue Jul 20, 2004 12:08 pm    Post subject: Deriving TEdit (TEditNumber) Reply with quote




Hi, I'm writing a new component descendind from TEdit which accepts only numbers.
This component has a new property MaxValue (int type). I'd like to check after every keystroke, that the edit's content never overcomes this value.
I tried to wrap the DoKeyDown, DoKeyPress, DoKeyUp functions but the edit's content still hasn't been updated yet, so when I check the content it still has the previous value.
Have yuo got any advice to check the edit's content using the keyboard????
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Jul 20, 2004 6:45 pm    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote




"Matrix" <f_l_a_v_i_o.ba.ri.so.ne (AT) el_s_a_g (DOT) it> wrote


Quote:
This component has a new property MaxValue (int type).

Why not just use TCSpinEdit? It already does all of that.

Quote:
I tried to wrap the DoKeyDown, DoKeyPress, DoKeyUp
functions but the edit's content still hasn't been updated yet,
so when I check the content it still has the previous value.

That is fine. Simply retreive the current value into a separate AnsiString,
then append the new key to it, then test the new value.


Gambit



Back to top
Matrix
Guest





PostPosted: Wed Jul 21, 2004 7:00 am    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote




Quote:
I tried to wrap the DoKeyDown, DoKeyPress, DoKeyUp
functions but the edit's content still hasn't been updated yet,
so when I check the content it still has the previous value.

That is fine. Simply retreive the current value into a separate AnsiString,
then append the new key to it, then test the new value.

The problem is that you can insert a new number in any place inside the Edit's content not only at the end. I mean: if the Edit's content is 1023 and the caret position (for any reason) is between 0 and 2, and you press "5", the whole number to check (to know if it's over the Max) is 10523 and not 10235. Have you got any idea to solve this problem without writing hundred of lines of code????
TIA.

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Jul 21, 2004 7:17 am    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote


"Matrix" <f_l_a_v_i_o.ba.ri.so.ne (AT) el_s_a_g (DOT) it> wrote


Quote:
The problem is that you can insert a new number in
any place inside the Edit's content not only at the end.

Retreive the current caret position and then insert the keystroke into that
position of the AnsiString.


Gambit



Back to top
Matrix
Guest





PostPosted: Wed Jul 21, 2004 9:03 am    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote


"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:
Quote:

"Matrix" <f_l_a_v_i_o.ba.ri.so.ne (AT) el_s_a_g (DOT) it> wrote in message
news:40fe1483$1 (AT) newsgroups (DOT) borland.com...

The problem is that you can insert a new number in
any place inside the Edit's content not only at the end.

Retreive the current caret position and then insert the keystroke into that
position of the AnsiString.

OK...but I don't know how to find the caret position..sigh

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Jul 21, 2004 5:14 pm    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote


"Matrix" <f_l_a_v_i_o.ba.ri.so.ne (AT) el_s_a_g (DOT) it> wrote


Quote:
OK...but I don't know how to find the caret position.

Use the SelStart property.


Gambit



Back to top
Yoann chaigneau
Guest





PostPosted: Fri Jul 23, 2004 1:12 pm    Post subject: Re: Deriving TEdit (TEditNumber) Reply with quote

Hi,
Why don't you test the whole text of your edit in the onchage event ?


"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> a écrit dans le
message de news:40fea440 (AT) newsgroups (DOT) borland.com...
Quote:

"Matrix" <f_l_a_v_i_o.ba.ri.so.ne (AT) el_s_a_g (DOT) it> wrote in message
news:40fe316e$2 (AT) newsgroups (DOT) borland.com...

OK...but I don't know how to find the caret position.

Use the SelStart property.


Gambit





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.