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

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

Postby Ollie » Tue Jun 10, 2008 3:42 pm

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  Expand view

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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Thu Jun 12, 2008 7:30 am

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Ollie » Thu Jun 12, 2008 8:18 am

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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests