PC Review


Reply
Thread Tools Rate Thread

Displaying text without using labels?

 
 
Andrew Roxburgh
Guest
Posts: n/a
 
      3rd Dec 2003
Hi,

I have an monitoring application that displays various
pieces of data, which are changing, within a form. The
data is displayed in different colours (i.e. they are not
all the same colour), and the various items are shown in
different positions on the form. It's a status panel
basically.

I'm using labels to represent each data item.

I don't want to use labels because:
(1) I'm using the .Net Compact Framework which only allows
around 100 controls before bombing out. I have multiple
panels showing quite a few labels.
(2) more importantly, it takes too long to draw on the
screen. This is a real-time monitoring application. With
data conversions, it takes around 300ms to draw about 20
floating-point data values on the screen (I'm using WinCE
on a Hitachi SH4 processor).

So is there another method? Harking back to heady BBC
BASIC days of the 1980s, this complex task was achievable
with the PRINTAT(x,y) statement! I need to display text at
specific positions on the form, without updating all the
data simultaneously, and I need to be able to display in
different colours. It should also paint quicker than a
label control.

Anyone got any ideas?

Thanks

Andy

 
Reply With Quote
 
 
 
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      3rd Dec 2003
Sure, override OnPaint for the Form and just paint the text where you want
it.

-Chris


"Andrew Roxburgh" <(E-Mail Removed)> wrote in message
news:bacd01c3b947$afdf2800$(E-Mail Removed)...
> Hi,
>
> I have an monitoring application that displays various
> pieces of data, which are changing, within a form. The
> data is displayed in different colours (i.e. they are not
> all the same colour), and the various items are shown in
> different positions on the form. It's a status panel
> basically.
>
> I'm using labels to represent each data item.
>
> I don't want to use labels because:
> (1) I'm using the .Net Compact Framework which only allows
> around 100 controls before bombing out. I have multiple
> panels showing quite a few labels.
> (2) more importantly, it takes too long to draw on the
> screen. This is a real-time monitoring application. With
> data conversions, it takes around 300ms to draw about 20
> floating-point data values on the screen (I'm using WinCE
> on a Hitachi SH4 processor).
>
> So is there another method? Harking back to heady BBC
> BASIC days of the 1980s, this complex task was achievable
> with the PRINTAT(x,y) statement! I need to display text at
> specific positions on the form, without updating all the
> data simultaneously, and I need to be able to display in
> different colours. It should also paint quicker than a
> label control.
>
> Anyone got any ideas?
>
> Thanks
>
> Andy
>



 
Reply With Quote
 
John Kirk
Guest
Posts: n/a
 
      3rd Dec 2003
If you're after a code snippet, this is what I use to put text on a picture box. I use a picture box so I can put a bitmap in the background.
After you've updated the text variable(s) just refresh the control. Not sure how fast this is but as you can see it's not much more complex than your old BBC Basic.


Private mstrMessage as String

Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If mstrMessage <> "" Then
Dim f As Font
Dim b As Brush
Dim r As RectangleF

r = New RectangleF(5, 5, 200, 20)
f = New Font("Arial", 10, FontStyle.Bold)
b = New SolidBrush(Color.White)
e.Graphics.DrawString(mstrMessage, f, b, r)
End If
End Sub


"Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Sure, override OnPaint for the Form and just paint the text where you want
> it.
>
> -Chris
>
>
> "Andrew Roxburgh" <(E-Mail Removed)> wrote in message
> news:bacd01c3b947$afdf2800$(E-Mail Removed)...
> > Hi,
> >
> > I have an monitoring application that displays various
> > pieces of data, which are changing, within a form. The
> > data is displayed in different colours (i.e. they are not
> > all the same colour), and the various items are shown in
> > different positions on the form. It's a status panel
> > basically.
> >
> > I'm using labels to represent each data item.
> >
> > I don't want to use labels because:
> > (1) I'm using the .Net Compact Framework which only allows
> > around 100 controls before bombing out. I have multiple
> > panels showing quite a few labels.
> > (2) more importantly, it takes too long to draw on the
> > screen. This is a real-time monitoring application. With
> > data conversions, it takes around 300ms to draw about 20
> > floating-point data values on the screen (I'm using WinCE
> > on a Hitachi SH4 processor).
> >
> > So is there another method? Harking back to heady BBC
> > BASIC days of the 1980s, this complex task was achievable
> > with the PRINTAT(x,y) statement! I need to display text at
> > specific positions on the form, without updating all the
> > data simultaneously, and I need to be able to display in
> > different colours. It should also paint quicker than a
> > label control.
> >
> > Anyone got any ideas?
> >
> > Thanks
> >
> > Andy
> >

>
>

 
Reply With Quote
 
Justin Weinberg
Guest
Posts: n/a
 
      3rd Dec 2003
What Chris said.

I would add that you should be aware that the overloads for
System.Drawing.DrawString on CF are quite limited compared to the full
framework. For example, there is no StringFormat object in the CF. I would
also incrementally test performance as you go to make sure you're happy.

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com


"Andrew Roxburgh" <(E-Mail Removed)> wrote in message
news:bacd01c3b947$afdf2800$(E-Mail Removed)...
> Hi,
>
> I have an monitoring application that displays various
> pieces of data, which are changing, within a form. The
> data is displayed in different colours (i.e. they are not
> all the same colour), and the various items are shown in
> different positions on the form. It's a status panel
> basically.
>
> I'm using labels to represent each data item.
>
> I don't want to use labels because:
> (1) I'm using the .Net Compact Framework which only allows
> around 100 controls before bombing out. I have multiple
> panels showing quite a few labels.
> (2) more importantly, it takes too long to draw on the
> screen. This is a real-time monitoring application. With
> data conversions, it takes around 300ms to draw about 20
> floating-point data values on the screen (I'm using WinCE
> on a Hitachi SH4 processor).
>
> So is there another method? Harking back to heady BBC
> BASIC days of the 1980s, this complex task was achievable
> with the PRINTAT(x,y) statement! I need to display text at
> specific positions on the form, without updating all the
> data simultaneously, and I need to be able to display in
> different colours. It should also paint quicker than a
> label control.
>
> Anyone got any ideas?
>
> Thanks
>
> Andy
>



 
Reply With Quote
 
Andrew Roxburgh
Guest
Posts: n/a
 
      3rd Dec 2003
Thanks for the help.

Is it much more complicated to do it on a page within the
TabControl? I guess it's the same principle?

Andy




>-----Original Message-----
>What Chris said.
>
>I would add that you should be aware that the overloads

for
>System.Drawing.DrawString on CF are quite limited

compared to the full
>framework. For example, there is no StringFormat object

in the CF. I would
>also incrementally test performance as you go to make

sure you're happy.
>
>--
>
>Justin Weinberg
>Designing a PrintDocument? Drawing to forms?
>Check out GDI+ Architect at www.mrgsoft.com
>
>
>"Andrew Roxburgh" <(E-Mail Removed)>

wrote in message
>news:bacd01c3b947$afdf2800$(E-Mail Removed)...
>> Hi,
>>
>> I have an monitoring application that displays various
>> pieces of data, which are changing, within a form. The
>> data is displayed in different colours (i.e. they are

not
>> all the same colour), and the various items are shown in
>> different positions on the form. It's a status panel
>> basically.
>>
>> I'm using labels to represent each data item.
>>
>> I don't want to use labels because:
>> (1) I'm using the .Net Compact Framework which only

allows
>> around 100 controls before bombing out. I have multiple
>> panels showing quite a few labels.
>> (2) more importantly, it takes too long to draw on the
>> screen. This is a real-time monitoring application. With
>> data conversions, it takes around 300ms to draw about

20
>> floating-point data values on the screen (I'm using

WinCE
>> on a Hitachi SH4 processor).
>>
>> So is there another method? Harking back to heady BBC
>> BASIC days of the 1980s, this complex task was

achievable
>> with the PRINTAT(x,y) statement! I need to display text

at
>> specific positions on the form, without updating all the
>> data simultaneously, and I need to be able to display in
>> different colours. It should also paint quicker than a
>> label control.
>>
>> Anyone got any ideas?
>>
>> Thanks
>>
>> Andy
>>

>
>
>.
>

 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      3rd Dec 2003
It's the same process. Get a Graphics object, then draw on it.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Andrew Roxburgh" <(E-Mail Removed)> wrote in message
news:c2de01c3b9c0$c47e3250$(E-Mail Removed)...
> Thanks for the help.
>
> Is it much more complicated to do it on a page within the
> TabControl? I guess it's the same principle?
>
> Andy
>
>
>
>
> >-----Original Message-----
> >What Chris said.
> >
> >I would add that you should be aware that the overloads

> for
> >System.Drawing.DrawString on CF are quite limited

> compared to the full
> >framework. For example, there is no StringFormat object

> in the CF. I would
> >also incrementally test performance as you go to make

> sure you're happy.
> >
> >--
> >
> >Justin Weinberg
> >Designing a PrintDocument? Drawing to forms?
> >Check out GDI+ Architect at www.mrgsoft.com
> >
> >
> >"Andrew Roxburgh" <(E-Mail Removed)>

> wrote in message
> >news:bacd01c3b947$afdf2800$(E-Mail Removed)...
> >> Hi,
> >>
> >> I have an monitoring application that displays various
> >> pieces of data, which are changing, within a form. The
> >> data is displayed in different colours (i.e. they are

> not
> >> all the same colour), and the various items are shown in
> >> different positions on the form. It's a status panel
> >> basically.
> >>
> >> I'm using labels to represent each data item.
> >>
> >> I don't want to use labels because:
> >> (1) I'm using the .Net Compact Framework which only

> allows
> >> around 100 controls before bombing out. I have multiple
> >> panels showing quite a few labels.
> >> (2) more importantly, it takes too long to draw on the
> >> screen. This is a real-time monitoring application. With
> >> data conversions, it takes around 300ms to draw about

> 20
> >> floating-point data values on the screen (I'm using

> WinCE
> >> on a Hitachi SH4 processor).
> >>
> >> So is there another method? Harking back to heady BBC
> >> BASIC days of the 1980s, this complex task was

> achievable
> >> with the PRINTAT(x,y) statement! I need to display text

> at
> >> specific positions on the form, without updating all the
> >> data simultaneously, and I need to be able to display in
> >> different colours. It should also paint quicker than a
> >> label control.
> >>
> >> Anyone got any ideas?
> >>
> >> Thanks
> >>
> >> Andy
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
=?Utf-8?B?QW5kcmV3IFJveGJ1cmdo?=
Guest
Posts: n/a
 
      4th Dec 2003
Thanks for the code John - that's really helped for the static text.

However I could vastly improve things if I could draw the text without having to refresh the whole form every time - I'm updating around (on average) 10 times a second so if I repaint the whole form it flickers and is quite slow.

Anyone know a way to just refresh individual pieces of text?

Thanks

Andy


----- John Kirk wrote: -----

If you're after a code snippet, this is what I use to put text on a picture box. I use a picture box so I can put a bitmap in the background.
After you've updated the text variable(s) just refresh the control. Not sure how fast this is but as you can see it's not much more complex than your old BBC Basic.


Private mstrMessage as String

Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If mstrMessage <> "" Then
Dim f As Font
Dim b As Brush
Dim r As RectangleF

r = New RectangleF(5, 5, 200, 20)
f = New Font("Arial", 10, FontStyle.Bold)
b = New SolidBrush(Color.White)
e.Graphics.DrawString(mstrMessage, f, b, r)
End If
End Sub


"Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Sure, override OnPaint for the Form and just paint the text where you want
> it.
>> -Chris
>>> "Andrew Roxburgh" <(E-Mail Removed)> wrote in message

> news:bacd01c3b947$afdf2800$(E-Mail Removed)...
>> Hi,
>>>> I have an monitoring application that displays various

>> pieces of data, which are changing, within a form. The
>> data is displayed in different colours (i.e. they are not
>> all the same colour), and the various items are shown in
>> different positions on the form. It's a status panel
>> basically.
>>>> I'm using labels to represent each data item.
>>>> I don't want to use labels because:

>> (1) I'm using the .Net Compact Framework which only allows
>> around 100 controls before bombing out. I have multiple
>> panels showing quite a few labels.
>> (2) more importantly, it takes too long to draw on the
>> screen. This is a real-time monitoring application. With
>> data conversions, it takes around 300ms to draw about 20
>> floating-point data values on the screen (I'm using WinCE
>> on a Hitachi SH4 processor).
>>>> So is there another method? Harking back to heady BBC

>> BASIC days of the 1980s, this complex task was achievable
>> with the PRINTAT(x,y) statement! I need to display text at
>> specific positions on the form, without updating all the
>> data simultaneously, and I need to be able to display in
>> different colours. It should also paint quicker than a
>> label control.
>>>> Anyone got any ideas?
>>>> Thanks
>>>> Andy
>>>>

 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      4th Dec 2003
You could draw all the static stuff into a buffer bitmap once, then in
OnPaint blit that to another bitmap, draw you non-static text, then blit
that to the Graphics object. I've done this a lot and performance is pretty
good. The other option is to repaint and invalidate just sections of your
image.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Andrew Roxburgh" <(E-Mail Removed)> wrote in message
news:790B3E06-6A70-467F-A14D-(E-Mail Removed)...
> Thanks for the code John - that's really helped for the static text.
>
> However I could vastly improve things if I could draw the text without

having to refresh the whole form every time - I'm updating around (on
average) 10 times a second so if I repaint the whole form it flickers and is
quite slow.
>
> Anyone know a way to just refresh individual pieces of text?
>
> Thanks
>
> Andy
>
>
> ----- John Kirk wrote: -----
>
> If you're after a code snippet, this is what I use to put text on a

picture box. I use a picture box so I can put a bitmap in the background.
> After you've updated the text variable(s) just refresh the control.

Not sure how fast this is but as you can see it's not much more complex than
your old BBC Basic.
>
>
> Private mstrMessage as String
>
> Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As

System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
> If mstrMessage <> "" Then
> Dim f As Font
> Dim b As Brush
> Dim r As RectangleF
>
> r = New RectangleF(5, 5, 200, 20)
> f = New Font("Arial", 10, FontStyle.Bold)
> b = New SolidBrush(Color.White)
> e.Graphics.DrawString(mstrMessage, f, b, r)
> End If
> End Sub
>
>
> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message

news:%(E-Mail Removed)...
> > Sure, override OnPaint for the Form and just paint the text where

you want
> > it.
> >> -Chris
> >>> "Andrew Roxburgh" <(E-Mail Removed)> wrote in

message
> > news:bacd01c3b947$afdf2800$(E-Mail Removed)...
> >> Hi,
> >>>> I have an monitoring application that displays various
> >> pieces of data, which are changing, within a form. The
> >> data is displayed in different colours (i.e. they are not
> >> all the same colour), and the various items are shown in
> >> different positions on the form. It's a status panel
> >> basically.
> >>>> I'm using labels to represent each data item.
> >>>> I don't want to use labels because:
> >> (1) I'm using the .Net Compact Framework which only allows
> >> around 100 controls before bombing out. I have multiple
> >> panels showing quite a few labels.
> >> (2) more importantly, it takes too long to draw on the
> >> screen. This is a real-time monitoring application. With
> >> data conversions, it takes around 300ms to draw about 20
> >> floating-point data values on the screen (I'm using WinCE
> >> on a Hitachi SH4 processor).
> >>>> So is there another method? Harking back to heady BBC
> >> BASIC days of the 1980s, this complex task was achievable
> >> with the PRINTAT(x,y) statement! I need to display text at
> >> specific positions on the form, without updating all the
> >> data simultaneously, and I need to be able to display in
> >> different colours. It should also paint quicker than a
> >> label control.
> >>>> Anyone got any ideas?
> >>>> Thanks
> >>>> Andy
> >>>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Displaying text boxes for labels Beetle Microsoft Access Forms 1 8th Jun 2009 10:47 PM
Excel 2007 text labels in category axis - missing labels Boris Microsoft Excel Charting 3 5th Dec 2008 04:33 PM
Re: Displaying Labels Used In A Chart Bob Phillips Microsoft Excel Discussion 0 15th May 2008 02:18 PM
Pie Chart displaying 0% labels =?Utf-8?B?amVuMjU=?= Microsoft Access Reports 1 30th May 2006 04:58 PM
Access 2002 Form Labels not displaying Vertical Text Gary A. Hollenbeck Microsoft Access Forms 0 16th Dec 2003 07:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 PM.