Autoscroll to bottom in EDITBOX
Moderator: Rathinagiri
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Autoscroll to bottom in EDITBOX
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?
Is there a way to have the editbox automatically scroll down when you add lines beyond the height of the editbox?
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Autoscroll to bottom in EDITBOX
Did you try this?
form.editbox.caretpos := len( form.editbox.value )
form.editbox.caretpos := len( form.editbox.value )
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Autoscroll to bottom in EDITBOX
Mr Rathinagiri,
Adding piece of code attached.
The caret-position is indeed at the end, but the editbox doesn't scroll to the bottom...Did you try this?
form.editbox.caretpos := len( form.editbox.value )
Adding piece of code attached.
- Attachments
-
- Scroll.zip
- (1.32 KiB) Downloaded 489 times
Re: Autoscroll to bottom in EDITBOX
Hi,Clip2Mania wrote: Adding piece of code attached.
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
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Autoscroll to bottom in EDITBOX
Unfortunately, don't know any C myself ...
Thanks for this solution Grigory!
Thanks for this solution Grigory!
- Agil Abdullah
- Posts: 204
- Joined: Mon Aug 25, 2014 11:57 am
- Location: Jakarta, Indonesia
- Contact:
Re: Autoscroll to bottom in EDITBOX
For me, it's very useful, coz not only reading text/memo but also showing line numbers at every line.
Thanks Gregory.
Thanks Gregory.
Agil Abdullah Albatati (just call me Agil)
Programmer Never Surrender
Programmer Never Surrender
- serge_girard
- Posts: 3173
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Autoscroll to bottom in EDITBOX
Thanks Gregory !
Serge
Serge
There's nothing you can do that can't be done...
-
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: Autoscroll to bottom in EDITBOX
Gracias Gregory Filatov,
Excelente ejemplo!
Saludos
Excelente ejemplo!
Saludos
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Autoscroll to bottom in EDITBOX
Hi ErikClip2Mania wrote:Unfortunately, don't know any C myself ...
...
I agree with you
We need something like HMG_KeyPut() same as HB_KeyPut()
Happy HMG'ing
Viva INTERNATIONAL HMG