How to proper case all words in a DCMULTILINE

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

How to proper case all words in a DCMULTILINE

#1 Post 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
The eXpress train is coming - and it has more cars.

Post Reply