Re: Is it possible to edit the font in a single text box?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Wed, 3 Jan 2007 15:46:07 -0000, "Mike Williams"
<Mike@xxxxxxxxxxxxxxxxx> wrote:

"PeterD" <peter2@xxxxxxxxxx> wrote in message
news:aaenp2l9q8cs4g0mrim4p3ca7co495bj9d@xxxxxxxxxx

Ideal would be either drop in RTF at design time. Next best would
be go grab a resource string and drop it in at run time, but I hate the
performance hit of initializing frequently which could happen.

What do you mean about "hating the performance hit"? You drop the RTF from
your resource into the RichTextBox just once in the Form's Load event. I've
just timed the act of doing exactly that job using a typical medium sized
rtf file and on my machine the combined total time of loading the rtf data
from the resource file and then dropping into an RTB takes about half a
millisecond, and that includes the time it takes for the RTB to format the
data! Half a millisecond, just once when your Form loads!

Oh, I'm just ultra conservative! <g>

Besides, even if
VB did have a facility for you to insert the rtf at design time it would
still need to create the RTB and carry out a similar task itself as the Form
loads. There is no performance hit.

All you need to do is create your rtf file (in Microsoft Word perhaps or
some other suitable editor) and then use the VB Resource Editor to add that
rtf file as a custom resource in your VB resource file. The file's data will
be inserted into the resource and will of course be compiled as part of your
VB program, and you can use the following simple code to place it into the
RichTextBox at run time (assuming the number of the resource is 101):

Private Sub Form_Load()
RichTextBox1.TextRTF = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
End Sub

Mike


I'll try that out and see what I get.
.



Relevant Pages

  • Re: Is it possible to edit the font in a single text box?
    ... performance hit of initializing frequently which could happen. ... your resource into the RichTextBox just once in the Form's Load event. ... I've just timed the act of doing exactly that job using a typical medium sized rtf file and on my machine the combined total time of loading the rtf data from the resource file and then dropping into an RTB takes about half a millisecond, and that includes the time it takes for the RTB to format the data! ...
    (microsoft.public.vb.general.discussion)
  • Web Site embedded resource
    ... How do I embedd a resource (.rtf file) in a Web Site ?? ... but how do I do with a Web Site project? ...
    (microsoft.public.dotnet.framework)
  • Re: RichTextBox
    ... I have a rtf file "abc.rtf", namespace is MyNamespace. ... Is that the correct way to specify the resource name? ... > You can include the RTF file as an embedded resource and load it from ...
    (microsoft.public.dotnet.languages.csharp)
  • Howto create a new resource type
    ... Does anyone know how to create a new resource type? ... What I am trying to do is add an rtf file to my resources file. ... being able to see the resource in the resource editor. ...
    (microsoft.public.vc.mfc)
  • Re: general performance question
    ... Sometimes I declare a variable that is to point to a resource and set ... Connection conn = null; ... If a performance hit is claimed it should ... final Connection connection = getConnections; ...
    (comp.lang.java.programmer)