Page 1 of 1
Autoscroll to bottom in EDITBOX
Posted: Mon Jun 30, 2014 11:42 am
by Clip2Mania
I'm "filling up" an editbox (with vertical scrollbar) with data, which is over a hundred lines long, refreshing the display after every line that I add. The default behaviour is that you only see the x number of first lines (depending on height you defined).
Is there a way to have the editbox automatically scroll down when you add lines beyond the height of the editbox?
Re: Autoscroll to bottom in EDITBOX
Posted: Mon Jun 30, 2014 3:30 pm
by Rathinagiri
Did you try this?
form.editbox.caretpos := len( form.editbox.value )
Re: Autoscroll to bottom in EDITBOX
Posted: Tue Jul 01, 2014 7:45 am
by Clip2Mania
Mr Rathinagiri,
Did you try this?
form.editbox.caretpos := len( form.editbox.value )
The caret-position is indeed at the end, but the editbox doesn't scroll to the bottom...
Adding piece of code attached.
Re: Autoscroll to bottom in EDITBOX
Posted: Tue Jul 01, 2014 9:20 am
by gfilatov
Clip2Mania wrote:
Adding piece of code attached.
Hi,
Thanks for your sample code.
Please take a look for the working updated sample below.
Code: Select all
#include <hmg.ch>
#define CRLF chr(13)+chr(10)
function main()
local cSMsg:="Do Something"
DEFINE WINDOW MainForm;
AT 90,90;
WIDTH 780;
HEIGHT 550;
TITLE 'Inventory Renamer';
MAIN;
NOSIZE
DEFINE MAIN Menu of MainForm
DEFINE POPUP "File"
MENUITEM "Select From List" ACTION DoList()
SEPARATOR
MENUITEM "Exit" ACTION ThisWindow.Release
END POPUP
END MENU
DEFINE STATUSBAR
STATUSITEM cSMsg
CLOCK
DATE
END STATUSBAR
@ 005,005 EDITBOX Edit_1 ;
WIDTH 760 HEIGHT 425 ;// READONLY ;
VALUE " ";
FONTCOLOR {000,000,255} ;
FONT "Courier New" SIZE 10
@ 440, 665 BUTTON bn_Go;
OF MainForm;
CAPTION "Rename";
ACTION MsgInfo("Go!")
@ 443, 10 LABEL lb_Stat ;
VALUE " ";
WIDTH 650;
TRANSPARENT
END WINDOW
MainForm.Center
MainForm.Activate
return NIL
//-----------------------
function Dolist()
local cList, n, nTokens
local cStr:=""
if !file("list.txt")
MsgInfo("Didn't find a list.txt")
return NIL
endif
cList:=memoread("list.txt")
nTokens:=numtoken(cList,CRLF)
MsgInfo("List is "+str(len(cList))+" bytes long"+ CRLF + str(nTokens)+" lines in the list")
For n := 1 to nTokens
cDir:=token(cList,CRLF,n)
cStr:=cStr+"File "+strzero(n,3)+" "+cDir+CRLF
MainForm.Edit_1.Value:=cStr
MainForm.Edit_1.Caretpos := len(MainForm.Edit_1.Value)-1
do events
Next
INSERT_CTRL_END()
return NIL
//-------------------
function strzero(nNum,nLen)
return right(replicate("0",nLen)+ltrim(token(str(nNum),".",1)),nLen)
//-------------------
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC( INSERT_CTRL_END )
{
keybd_event(
VK_CONTROL, // virtual-key code
0, // hardware scan code
0, // flags specifying various function options
0 // additional data associated with keystroke
);
keybd_event(
VK_END , // virtual-key code
0, // hardware scan code
0, // flags specifying various function options
0 // additional data associated with keystroke
);
keybd_event(
VK_CONTROL, // virtual-key code
0, // hardware scan code
KEYEVENTF_KEYUP,// flags specifying various function options
0 // additional data associated with keystroke
);
}
#pragma ENDDUMP
Hope that helps
Re: Autoscroll to bottom in EDITBOX
Posted: Tue Jul 01, 2014 2:06 pm
by Clip2Mania
Unfortunately, don't know any C myself ...
Thanks for this solution Grigory!
Re: Autoscroll to bottom in EDITBOX
Posted: Mon Sep 29, 2014 10:07 am
by Agil Abdullah
For me, it's very useful, coz not only reading text/memo but also showing line numbers at every line.
Thanks Gregory.
Re: Autoscroll to bottom in EDITBOX
Posted: Mon Sep 29, 2014 1:21 pm
by serge_girard
Thanks Gregory !
Serge
Re: Autoscroll to bottom in EDITBOX
Posted: Mon Sep 29, 2014 4:26 pm
by Javier Tovar
Gracias Gregory Filatov,
Excelente ejemplo!
Saludos
Re: Autoscroll to bottom in EDITBOX
Posted: Sat Nov 01, 2014 11:57 pm
by esgici
Clip2Mania wrote:Unfortunately, don't know any C myself ...
...
Hi Erik
I agree with you
We need something like
HMG_KeyPut() same as
HB_KeyPut()
Happy HMG'ing