May 04, 2024, 08:49:39 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Automatic Vertical Scrolling in a RichEdit Control

Started by tbohon, April 06, 2007, 01:59:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tbohon

Have the following code which is great so far other than it won't scroll down to keep the last line entered in the richedit control visible until I manually move the scrollbar slider down ... then it acts 'normally'.

CONST EDIT_1 = 1
CONST RICHEDIT_2 = 2
CONST BUTTON_3 = 3
INT Infocus

DIALOG d1

CREATEDIALOG d1,0,0,788,413,0x80C80080,0,"crscroll test",&d1_handler
CONTROL d1,@EDIT,"",6,384,773,20,0x50800000,EDIT_1
CONTROL d1,@RICHEDIT,"",6,6,775,370,0x50B00844|@CTEDITAUTOV,RICHEDIT_2
CONTROL d1,@BUTTON,"",6,384,70,20,0x40080001,BUTTON_3

DOMODAL d1

END

'================ subroutines follow ================

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
/* Initialize any controls here */

CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK

CASE @IDCONTROL
SELECT @CONTROLID
CASE EDIT_1
Infocus = 1
CASE RICHEDIT_2
Infocus = 2
CASE BUTTON_3
IF GETKEYSTATE(13) <> 0
SELECT Infocus
CASE 1
printm(d1,GETCONTROLTEXT(d1,1))
SETCONTROLTEXT d1,EDIT_1,""

CASE 2
SETFOCUS d1,EDIT_1
ENDSELECT
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB

SUB printm(dlg:dialog,text:string)

length = CONTROLCMD(dlg, 2, @RTGETTEXTLENGTH)

CONTROLCMD dlg, 2, @RTSETSELECTION, length, length

CONTROLCMD dlg, 2, @RTREPLACESEL, text + CHR$(13)+CHR$(10)

RETURN
ENDSUB


Would appreciate thoughts/comments on how to fix this irritating little issue ...

Tnx in advance.

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

GJ

Hi Tom


change the printm subroutine a bit....


SUB printm(dlg:dialog,text:string)

length = CONTROLCMD(dlg, 2, @RTGETTEXTLENGTH)

CONTROLCMD dlg, 2, @RTSETSELECTION, length, length

CONTROLCMD dlg, 2, @RTREPLACESEL, text + CHR$(13)+CHR$(10)
        CONTROLCMD dlg, 2, @RTSCROLL, 0,1
RETURN
ENDSUB





Gertjan (GJ)


tbohon

 :-\  Works just fine ... and I swear, I read every single line of the parts of the documentation that had anything to do with CONTROLCMD.

I'm going to close up shop, go home, turn my computer into an aquarium, and go grow flowers for a living ...  ;)

Thanks so much ... you're a great help!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)