Page 1 of 1

How to proper case all words in a DCMULTILINE

Posted: Fri Apr 15, 2016 10:47 am
by rdonnay
An eXpress++ user needed a solution for capitalizing the first letter of each word in a DCMULTILINE object as they are being typed. Here is a sample program.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0],  cMemo := '', lCapFirst := .t.


@ 0,0 DCSAY 'Enter text:' SAYSIZE 0

@ 1,0 DCMULTILINE cMemo SIZE 60,10 FONT '10.Lucida Console' ;
      ID 'CAPFIRST_MLE'

DCREAD GUI FIT TITLE 'Proper case all words' ;
   HANDLER TestCapFirst REFERENCE @lCapFirst

RETURN nil

* -----------

PROC appsys ; RETURN

* -----------

STATIC FUNCTION TestCapFirst( nEvent, mp1, mp2, oXbp, oDlg, aGetList, lCapFirst )

LOCAL nKey

IF nEvent == xbeP_Keyboard .AND. oXbp:isDerivedFrom('DC_XbpMle') .AND. oXbp == DC_GetObject(aGetList,'CAPFIRST_MLE')
  nKey := mp1
  IF (Empty(oXbp:editbuffer()) .OR. lCapFirst) .AND. nKey >= 97 .AND. nKey <= 122
    PostAppEvent(xbeP_Keyboard, nKey-32,, oXbp)
    lCapFirst := .f.
    RETURN DCGUI_IGNORE
  ELSEIF nKey == xbeK_SPACE
    lCapFirst := .t.
  ELSE
    lCapFirst := .f.
  ENDIF
ENDIF

RETURN DCGUI_NONE