473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

FIFO Text Control

I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???

Cheers,
Russ

Jun 10 '06 #1
5 3243
It sounds to me just few lines a code adding to a winform with textbox
control around. I don't think creating user control will make it work
better.

chanmm

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???

Cheers,
Russ

Jun 10 '06 #2
SP

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array that
you can join using String.Join. You can then set the Text of a control like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP
Jun 10 '06 #3
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.

SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array that
you can join using String.Join. You can then set the Text of a control like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP


Jun 11 '06 #4
SP

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.
You can try using SuspendLayout and ResumeLayout. The problem is that the
scroll bar is adjusting it's size as the text changes although once it gets
to a certain number of lines the number of lines should then remain
constant.. I use a third party edit box control that seems to not be so
"jumpy" as the text is changed and it allows you to scroll back while text
is being added. As such I have never implemented the queue idea. Your
question made me think of a better implementation than what I am currently
doing which is similar to what you are currently doing. One idea is to turn
off the scroll bars in the text box and implement your own scroll bar
control.

SP


SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
>I have an application that recieves text data via external input (i.e.
> serial) and displays it on the screen (we use carraige return as a
> delimiter). At this point I use a regular old text box and when the
> text size gets too big I truncate the string and re-set the
> TextBox.Text property. This solution is very crappy as it creates a
> flickering scroll bar when I re-set the text. Scrolling is also
> difficult because the position in the text jumps to the end when I
> append something new.
>
> So, I have decided that I need to write a user control that will allow
> me to do the following:
>
> - Display text as it is received by the application
> - Set the max number of characters (or lines) that can be displayed
> - Create a FIFO style of adding text, so once the max number of
> characters are reached, the display text is truncated from the
> beginning and added at the end, without having the scroll bar jump
> around
> - Have a way of controlling the position displayed so I can scroll up
> and view older text while new text is being added (i.e. you can hold
> the scroll bar and the text stays put until you let go. I saw this in
> Tera Term. Neat feature.)
> - Nice to have: Select a truncate character (i.e. Carriage Return) so
> that instead of loosing x number of characters, the text is truncated
> by "line".
>
> I'm totally stumped as I've never had to try this sort of thing before.
> I'm considering a Panel of Labels that displays each "line" separately
> and then adds/removes the controls to create the FIFO effect. I could
> use a scroll bar to scroll up and down in the panel...maybe? The
> problem is when I want to start re-sizing forms, the text won't really
> format correctly unless I start doing some pretty wierd calculations
> and grow the height of the label when the width shrinks.
>
> So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array
that
you can join using String.Join. You can then set the Text of a control
like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP

Jun 12 '06 #5
I'll keep you posted on my progress. This isn't a high priority item so
please be patient; I only have so much personal time to devote to my
geekiness.

:-)

Russ

SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.


You can try using SuspendLayout and ResumeLayout. The problem is that the
scroll bar is adjusting it's size as the text changes although once it gets
to a certain number of lines the number of lines should then remain
constant.. I use a third party edit box control that seems to not be so
"jumpy" as the text is changed and it allows you to scroll back while text
is being added. As such I have never implemented the queue idea. Your
question made me think of a better implementation than what I am currently
doing which is similar to what you are currently doing. One idea is to turn
off the scroll bars in the text box and implement your own scroll bar
control.

SP


SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
>I have an application that recieves text data via external input (i.e.
> serial) and displays it on the screen (we use carraige return as a
> delimiter). At this point I use a regular old text box and when the
> text size gets too big I truncate the string and re-set the
> TextBox.Text property. This solution is very crappy as it creates a
> flickering scroll bar when I re-set the text. Scrolling is also
> difficult because the position in the text jumps to the end when I
> append something new.
>
> So, I have decided that I need to write a user control that will allow
> me to do the following:
>
> - Display text as it is received by the application
> - Set the max number of characters (or lines) that can be displayed
> - Create a FIFO style of adding text, so once the max number of
> characters are reached, the display text is truncated from the
> beginning and added at the end, without having the scroll bar jump
> around
> - Have a way of controlling the position displayed so I can scroll up
> and view older text while new text is being added (i.e. you can hold
> the scroll bar and the text stays put until you let go. I saw this in
> Tera Term. Neat feature.)
> - Nice to have: Select a truncate character (i.e. Carriage Return) so
> that instead of loosing x number of characters, the text is truncated
> by "line".
>
> I'm totally stumped as I've never had to try this sort of thing before.
> I'm considering a Panel of Labels that displays each "line" separately
> and then adds/removes the controls to create the FIFO effect. I could
> use a scroll bar to scroll up and down in the panel...maybe? The
> problem is when I want to start re-sizing forms, the text won't really
> format correctly unless I start doing some pretty wierd calculations
> and grow the height of the label when the width shrinks.
>
> So, any ideas where to start with this???

I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array
that
you can join using String.Join. You can then set the Text of a control
like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP


Jun 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Tobias Pfeiffer | last post by:
Hi! I want to write a "client-server-application" (only running on the same machine) or actually I've already begun with and have problems with the interprocess communication. The server, when...
4
by: Luca | last post by:
I have the need of a container of integers showing both the characteristics of an associative container (all integer elements different from each other) and the FIFO behaviour. Do you know if...
2
by: Michele Moccia | last post by:
How can I implement a "time critical" fifo in c++ ? I just have to manage sequences of raw bytes, no user defined types. An std::queue<unsigned char> or std::deque<unsigned char> seems to be slow....
8
by: Jack | last post by:
I want to implement a fixed-size FIFO queue for characters. I only want to use array not linked list. For example, const int N = 10; char c_array; The question is when the queue is full,...
1
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The...
3
by: Polatrite | last post by:
I'm working on a project currently that needs to have a fast FIFO text box that displays output from a serial device. It also needs to have fast refresh rate as the data can stream in at about 50...
2
by: Spoon | last post by:
Hello, I'm wondering whether the STL defines a data structure with the following features: o provides push_front() and pop_back() (like std::list) to implement a FIFO buffer. o allows fast...
5
by: doxtor | last post by:
Hi all..I'm a little bit confuse with this problem. I have 3 tables, stock_in, stock_level, and stock_out. stock_in used for save the data product when there's new purchase. stock_out used for...
40
by: sazd1 | last post by:
Hi Student2 I am working on similar kind of thing for stock calculation but could not find any solution to my problem even after putting my problem to different forums. I saw your post that you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.