[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Detect when I have to refill the richtextbox vb6

Catharinus van der werf

6/5/2012 11:39:00 AM

Hello my friends

I have a vb6--form that contains a richtextbox and a command-button
with the capion 'Next Page'. On this form, I want to show the content
a a vb-string. The string can vary in length, it could contain 30
lines of text, but also 120 or 240 etc.
At a certain point I need a new page, that is emptying the richtextbox
and fill it with the next part of lines from the string. That should
be done by pressing the command-button
How can I easily and accurate detect the neccesity for a new page,
that contains the next part of the string that I want to show this
way.

Thanks in advantage,

Catharinus
21 Answers

Mayayana

6/5/2012 1:11:00 PM

0



--
--
"Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com...
| Hello my friends
|
| I have a vb6--form that contains a richtextbox and a command-button
| with the capion 'Next Page'. On this form, I want to show the content
| a a vb-string. The string can vary in length, it could contain 30
| lines of text, but also 120 or 240 etc.
| At a certain point I need a new page, that is emptying the richtextbox
| and fill it with the next part of lines from the string. That should
| be done by pressing the command-button
| How can I easily and accurate detect the neccesity for a new page,
| that contains the next part of the string that I want to show this
| way.
|
Isn't that what the button is for? I read your question
several times, but I still don't get it. If you mean that
you need to find out how far down it's scrolled, you can
use something like the following to get the bottom line
number and then check the total number of lines by
using EM_EXLINEFROMCHAR and sending len(RTB.text)
for the last parameter.

Function GetBottomLine(hRTB as long) As Long '-- hRTB is RTB hWnd
'--get bottom line number by getting bottom point, then
'-- getting charfrompos for that point. returns nearest
'-- line number in high word.(?? supposed to but apparently doesn't.
'-- seems to only return character offset.)
Dim Pt1 As Point
Dim R1 As RECT
Dim LRet As Long, CPos As Long
On Error Resume Next
LRet = SendMessageAny(hRTB, EM_GETRECT, 0&, R1)
Pt1.X = 1
Pt1.Y = (R1.Bottom - R1.Top) - 1
LRet = SendMessageAny(hRTB, EM_CHARFROMPOS, 0&, Pt1)
GetBottomLine = SendMessageLong(hRTB, EM_EXLINEFROMCHAR, 0&, LRet)
End Function


Catharinus van der werf

6/5/2012 1:46:00 PM

0

Op dinsdag 5 juni 2012 15:11:28 UTC+2 schreef Mayayana het volgende:
> --
> --
> "Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
> news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com...
> | Hello my friends
> |
> | I have a vb6--form that contains a richtextbox and a command-button
> | with the capion 'Next Page'. On this form, I want to show the content
> | a a vb-string. The string can vary in length, it could contain 30
> | lines of text, but also 120 or 240 etc.
> | At a certain point I need a new page, that is emptying the richtextbox
> | and fill it with the next part of lines from the string. That should
> | be done by pressing the command-button
> | How can I easily and accurate detect the neccesity for a new page,
> | that contains the next part of the string that I want to show this
> | way.
> |
> Isn't that what the button is for? I read your question
> several times, but I still don't get it. If you mean that
> you need to find out how far down it's scrolled, you can
> use something like the following to get the bottom line
> number and then check the total number of lines by
> using EM_EXLINEFROMCHAR and sending len(RTB.text)
> for the last parameter.
>
> Function GetBottomLine(hRTB as long) As Long '-- hRTB is RTB hWnd
> '--get bottom line number by getting bottom point, then
> '-- getting charfrompos for that point. returns nearest
> '-- line number in high word.(?? supposed to but apparently doesn't.
> '-- seems to only return character offset.)
> Dim Pt1 As Point
> Dim R1 As RECT
> Dim LRet As Long, CPos As Long
> On Error Resume Next
> LRet = SendMessageAny(hRTB, EM_GETRECT, 0&, R1)
> Pt1.X = 1
> Pt1.Y = (R1.Bottom - R1.Top) - 1
> LRet = SendMessageAny(hRTB, EM_CHARFROMPOS, 0&, Pt1)
> GetBottomLine = SendMessageLong(hRTB, EM_EXLINEFROMCHAR, 0&, LRet)
> End Function

Hello Mayayana

I reread me question and indeed I didn't explain good what I want The fact is that I have already created a form like this, but I cannot get the form
show the next part of the string propertly in the richtextbox on the
form after pressing the command button. There are often a couple of empty lines on the next page, sometimes none. This is proberly because I have made a mistake in the sub that I created. The sub contains ao. the following code:

lclmaxlinesonthepagina = 360 / lclFontsize
If lclLineNr = lclmaxlinesonthepagina Or lcllineNr = 2 * (lclmaxlinesonthepagina) Or lclLineNr = 3 * (lclmaxLinesonthepagina) Or lclRegelNr = 4 * (lclmaxLinesonthepagina) Then
For X = 0 To 21
cpTekst = cpTekst & vbCrLf
Next X

In this way the sub puts 22 empty lines in the string cptekst. This 21 empty lines fill the pagebottom and so moves the string to the next page. So what I do in this way is enlarge the string and so let it move to the next page.
Not a good way I guess???
Thanks
Catharinus

GS

6/5/2012 5:40:00 PM

0

Catharinus van der werf explained on 6/5/2012 :
> Hello my friends
>
> I have a vb6--form that contains a richtextbox and a command-button
> with the capion 'Next Page'. On this form, I want to show the content
> a a vb-string. The string can vary in length, it could contain 30
> lines of text, but also 120 or 240 etc.
> At a certain point I need a new page, that is emptying the richtextbox
> and fill it with the next part of lines from the string. That should
> be done by pressing the command-button
> How can I easily and accurate detect the neccesity for a new page,
> that contains the next part of the string that I want to show this
> way.
>
> Thanks in advantage,
>
> Catharinus

Would it be helpful to track page numbers against an array index, where
your strings are stored in an array and your button clears the rtb and
loads the next element's string?

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Catharinus van der werf

6/5/2012 6:02:00 PM

0

Op dinsdag 5 juni 2012 13:39:16 UTC+2 schreef Catharinus van der werf het volgende:
> Hello my friends
>
> I have a vb6--form that contains a richtextbox and a command-button
> with the capion 'Next Page'. On this form, I want to show the content
> a a vb-string. The string can vary in length, it could contain 30
> lines of text, but also 120 or 240 etc.
> At a certain point I need a new page, that is emptying the richtextbox
> and fill it with the next part of lines from the string. That should
> be done by pressing the command-button
> How can I easily and accurate detect the neccesity for a new page,
> that contains the next part of the string that I want to show this
> way.
>
> Thanks in advantage,
>
> Catharinus

Catharinus van der werf

6/5/2012 6:04:00 PM

0

Op dinsdag 5 juni 2012 19:40:13 UTC+2 schreef GS het volgende:
> Catharinus van der werf explained on 6/5/2012 :
> > Hello my friends
> >
> > I have a vb6--form that contains a richtextbox and a command-button
> > with the capion 'Next Page'. On this form, I want to show the content
> > a a vb-string. The string can vary in length, it could contain 30
> > lines of text, but also 120 or 240 etc.
> > At a certain point I need a new page, that is emptying the richtextbox
> > and fill it with the next part of lines from the string. That should
> > be done by pressing the command-button
> > How can I easily and accurate detect the neccesity for a new page,
> > that contains the next part of the string that I want to show this
> > way.
> >
> > Thanks in advantage,
> >
> > Catharinus
>
> Would it be helpful to track page numbers against an array index, where
> your strings are stored in an array and your button clears the rtb and
> loads the next element's string?
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup!
> comp.lang.basic.visual.misc
> microsoft.public.vb.general.discussion

Catharinus van der werf

6/5/2012 6:10:00 PM

0

Op dinsdag 5 juni 2012 20:03:36 UTC+2 schreef csvand...@gmail.com het volgende:
> Op dinsdag 5 juni 2012 19:40:13 UTC+2 schreef GS het volgende:
> > Catharinus van der werf explained on 6/5/2012 :
> > > Hello my friends
> > >
> > > I have a vb6--form that contains a richtextbox and a command-button
> > > with the capion 'Next Page'. On this form, I want to show the content
> > > a a vb-string. The string can vary in length, it could contain 30
> > > lines of text, but also 120 or 240 etc.
> > > At a certain point I need a new page, that is emptying the richtextbox
> > > and fill it with the next part of lines from the string. That should
> > > be done by pressing the command-button
> > > How can I easily and accurate detect the neccesity for a new page,
> > > that contains the next part of the string that I want to show this
> > > way.
> > >
> > > Thanks in advantage,
> > >
> > > Catharinus
> >
> > Would it be helpful to track page numbers against an array index, where
> > your strings are stored in an array and your button clears the rtb and
> > loads the next element's string?
> >
> > --
> > Garry
> >
> > Free usenet access at http://www.eternal-sep...
> > ClassicVB Users Regroup!
> > comp.lang.basic.visual.misc
> > microsoft.public.vb.general.discussion

Hell Gary

I have been thinking about that, but no, I don't think so.
Because the text should scroll up or down when the font changes
The text is an invoice, that looks like this:

C.S van der Laan
StreetLane 123
1234 AA Amsterdam
clientnumber: 1234

art.number artname amount price totalprice
1 apple 30 0,50 15,00
2 orange 40 0,60 24,00
3 peache 100 0,45 45,00

etc, etc

unknown

6/5/2012 6:17:00 PM

0

"Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com...
> Hello my friends
>
> I have a vb6--form that contains a richtextbox and a command-button
> with the capion 'Next Page'. On this form, I want to show the content
> a a vb-string. The string can vary in length, it could contain 30
> lines of text, but also 120 or 240 etc.
> At a certain point I need a new page, that is emptying the richtextbox
> and fill it with the next part of lines from the string. That should
> be done by pressing the command-button
> How can I easily and accurate detect the neccesity for a new page,
> that contains the next part of the string that I want to show this
> way.

The way I understand your question is that you have a String, but you only
want to show one page at a time, and I am not sure why you don't want to use
scroll bars. You can send EM_SCROLL message with SB_PAGEDOWN to simulate
scrolling to the next page, or you have to slice your string variable into
lines by using InStrB(), or Split() functions, so which method do you want?
This is assuming that you are using a fixed size font.


Catharinus van der werf

6/5/2012 6:36:00 PM

0

Op dinsdag 5 juni 2012 20:17:10 UTC+2 schreef Farnsworth het volgende:
> "Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
> news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com...
> > Hello my friends
> >
> > I have a vb6--form that contains a richtextbox and a command-button
> > with the capion 'Next Page'. On this form, I want to show the content
> > a a vb-string. The string can vary in length, it could contain 30
> > lines of text, but also 120 or 240 etc.
> > At a certain point I need a new page, that is emptying the richtextbox
> > and fill it with the next part of lines from the string. That should
> > be done by pressing the command-button
> > How can I easily and accurate detect the neccesity for a new page,
> > that contains the next part of the string that I want to show this
> > way.
>
> The way I understand your question is that you have a String, but you only
> want to show one page at a time, and I am not sure why you don't want to use
> scroll bars. You can send EM_SCROLL message with SB_PAGEDOWN to simulate
> scrolling to the next page, or you have to slice your string variable into
> lines by using InStrB(), or Split() functions, so which method do you want?
> This is assuming that you are using a fixed size font.

Hello Farnsworth

You understood it correctly:
I have a method that I have once (a few years ago) found on www.activevb.de and that I have incorporated on a form with a richtextbox and buttons to go back to the earlier page and forward to go to the next page. Now I just count the lines and then add a couple of empty lines (the bottomlines) and then move to the next page. ANd it had a scrollbar to only scroll the text on the current page. Maybe I could use some of your suggestions, I will consider and try them. Thanks
But still I do not understand why my method doesn't work.

Catharinus

Catharinus van der werf

6/5/2012 6:42:00 PM

0

Op dinsdag 5 juni 2012 20:17:10 UTC+2 schreef Farnsworth het volgende:
> "Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
> news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com...
> > Hello my friends
> >
> > I have a vb6--form that contains a richtextbox and a command-button
> > with the capion 'Next Page'. On this form, I want to show the content
> > a a vb-string. The string can vary in length, it could contain 30
> > lines of text, but also 120 or 240 etc.
> > At a certain point I need a new page, that is emptying the richtextbox
> > and fill it with the next part of lines from the string. That should
> > be done by pressing the command-button
> > How can I easily and accurate detect the neccesity for a new page,
> > that contains the next part of the string that I want to show this
> > way.
>
> The way I understand your question is that you have a String, but you only
> want to show one page at a time, and I am not sure why you don't want to use
> scroll bars. You can send EM_SCROLL message with SB_PAGEDOWN to simulate
> scrolling to the next page, or you have to slice your string variable into
> lines by using InStrB(), or Split() functions, so which method do you want?
> This is assuming that you are using a fixed size font.

Yes you are correct Farnsworth, that's how it works. I will consider and try your suggenstions. Thanks
Cathairnus

Catharinus van der werf

6/6/2012 4:08:00 PM

0

Op dinsdag 5 juni 2012 20:35:37 UTC+2 schreef csvand...@gmail.com het volgende:
> Op dinsdag 5 juni 2012 20:17:10 UTC+2 schreef Farnsworth het volgende:
> > "Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
> > news:e4aa9517-c52e-4fa2-885f-c4c27f718f37@b26g2000vbt.googlegroups.com....
> > > Hello my friends
> > >
> > > I have a vb6--form that contains a richtextbox and a command-button
> > > with the capion 'Next Page'. On this form, I want to show the content
> > > a a vb-string. The string can vary in length, it could contain 30
> > > lines of text, but also 120 or 240 etc.
> > > At a certain point I need a new page, that is emptying the richtextbox
> > > and fill it with the next part of lines from the string. That should
> > > be done by pressing the command-button
> > > How can I easily and accurate detect the neccesity for a new page,
> > > that contains the next part of the string that I want to show this
> > > way.
> >
> > The way I understand your question is that you have a String, but you only
> > want to show one page at a time, and I am not sure why you don't want to use
> > scroll bars. You can send EM_SCROLL message with SB_PAGEDOWN to simulate
> > scrolling to the next page, or you have to slice your string variable into
> > lines by using InStrB(), or Split() functions, so which method do you want?
> > This is assuming that you are using a fixed size font.
>
> Hello Farnsworth
>
> You understood it correctly:
> I have a method that I have once (a few years ago) found on www.activevb..de and that I have incorporated on a form with a richtextbox and buttons to go back to the earlier page and forward to go to the next page. Now I just count the lines and then add a couple of empty lines (the bottomlines) and then move to the next page. ANd it had a scrollbar to only scroll the text on the current page. Maybe I could use some of your suggestions, I will consider and try them. Thanks
> But still I do not understand why my method doesn't work.
>
> Catharinus

I have to add some extra comments. What I want is to show a WYSIWYW richttextbox. This means that the richtextbox should show exactly what I want to print. Secondly, because the print is an invoice, every page after the first page should have at first columnnames. That is the mean reason that I need to know how many lines are printed, because after a cerain number of lines p;rinted, the rest of the lines should be on the next page and also on an empied Richtextbox. Hope this makes it clear. So what I want is a method to exactly count the number of lines on the screen, depending the size of the font and the printertype. There is also a button on the form to print the stuff, that why,

Cathairnus