Need to see the length of MEMO Edit box as it is filled.

Post Reply
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Need to see the length of MEMO Edit box as it is filled.

Post by Ollie »

Hi all.

I am writing an application that sends an SMS. The maximum characters I want the user to enter is 160. I would like to show the user how many chars he has typed so far.

The code below doesn't work because it moves the cursor to the start of the memo field everytime a key is pressed, so typing "ABC" produces "CBA".

How can I do this?

Code: Select all

 
DEFINE DIALOG oDlg RESOURCE "SMS"
REDEFINE GET cCellnumber ID 4001 OF oDlg UPDATE
REDEFINE GET cMessage MEMO ID 4002 OF oDlg UPDATE on CHANGE oDlg:UPDATE()
REDEFINE SAY ID 4003 PROMPT ALLTRIM(STR(LEN(cMessage)))+" of 160 characters used" UPDATE

REDEFINE BUTTON ID 10 of oDlg ACTION ( sendsms( cCellnumber, cMessage ), oDlg:END() ) ) )  //OK

REDEFINE BUTTON ID 20 of oDlg ACTION ( oDlg:END() )  //Cancel
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Ollie,

Try it this way:

REDEFINE GET cMessage MEMO ID 4002 OF oDlg ON CHANGE oSay:Refresh()

REDEFINE SAY oSay ID 4003 PROMPT ALLTRIM(STR(LEN(cMessage)))+" of 160 characters used"
regards, saludos

Antonio Linares
www.fivetechsoft.com
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Post by Ollie »

Works perfectly.

Thanks.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Post Reply