Solved

RichTextBox Problem

Posted on 2001-09-16
23
346 Views
Last Modified: 2013-12-03
Is there a bug in the RTF (I am using VB6, service pack 5) which is unsolveable?

I am using a special phonetic font. Normal alphabet characters are mapped to the normal keys; however, phonetic characters are assigned to other codes. Out of the entire phonetic font, there is one character which will not display properly.

Here is what I have tried to troubleshoot in a simple way:

1. I put a text box and a Rich Text Box on my form. Both have the font set for the special one I am using.
2. According to Windows Character Map, the troublesome character has a code of Alt+0140.
    Using the numeric key pad, I enter this code.
3. The text box displays the correct character, while the RTF shows a capital R.
4. If I use the Windows Character Map to select and copy, it can be pasted into the RTF without a problem.
5. If I try to code the character in VB and then paste it in the RTF box, I still get the capital R.
6. I have also noticed that if I try the above procedures in WordPad, I get the same result; however, there is no problem in Microsoft Word 97 or WordPerfect 9.

What exactly is Windows Character Map doing differently so that there is no problem here?

Is there any workaround what appears to be a RTF problem? Again, there is only one character which will not display properly out of the entire font.

Larry
0
Comment
Question by:larkahn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
  • 4
  • +1
23 Comments
 
LVL 14

Accepted Solution

by:
Matti earned 300 total points
ID: 6486276
Hi!

This one shuld add (append one char) as any available font in the rtf box.



Dim x&
x = Len(RichTextBox1.Text)
RichTextBox1.Text = RichTextBox1.Text + Chr(140)
RichTextBox1.SelStart = x
RichTextBox1.SelLength = 1
RichTextBox1.SelFontName = "Webdings"
RichTextBox1.SelLength = 0


Matti
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6486372
larkahn,

Since #4 works without a problem...

"4. If I use the Windows Character Map to select and copy, it can be pasted into the RTF without a problem."

... then I would do that, then programatically save the chr() value to a variable so you can see what the rtb sees that chr as.

In fact, I would assign the rtb.text to a variable to get the chr(), and I would also assign the rtb.RTFText to a variable and just see what the coding looks like in RTF format - may not give you anything, but it's one other thing to look at.

hth.

Wileecoy.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6486628
>> 5. If I try to code the character in VB and then paste it in the RTF box, I still get the capital R.

I had faced a similar problem, but not in RTB, but in VB itself. This I hope is b'cos VB handles characters according to its font settings. I put a character in database table, and then retrieve it through ADO, then the character display was alright, in VB, but, its character code was changed (funny isn't it). It is just a normal font, and not even a special font. The symbol being the Pound sign.

>> 3. The text box displays the correct character, while the RTF shows a capital R.
Did you use the same font for both textbox and RTB, and when you tried Alt+140, did you get diff. characters?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:larkahn
ID: 6486825
Private Sub Command2_Click()
Dim x
Dim myTextRTF
Dim myText
Dim myChr
Dim myAsc


  x = Len(RichTextBox1.Text)
   
  RichTextBox1.Text = RichTextBox1.Text + Chr(140)
I get basically the same result with the R appearing in the RTFB. Here is some modified code as you suggested, along with a debug.print. It appears that the RTFtext character saved is the R which is incorrect while the character for 0140 is correct when it shows ? in a normal font. The RTF box is somehow converting this into a different number character which I don't understand (123) and that is the R that gets printed.

Once again, in my original test before, I used the same font for both a textbox and an RTFB and I got the correct character in the text box but not the RTFB.

  RichTextBox1.SelStart = x
  RichTextBox1.SelLength = 1
  RichTextBox1.SelFontName = "IPAPhon"
 
  RichTextBox1.SelLength = 0
  myTextRTF = RichTextBox1.TextRTF
  myText = RichTextBox1.Text
  myChr = Chr(140)
  myAsc = Asc(RichTextBox1.TextRTF)

  Debug.Print myTextRTF
  Debug.Print myText
  Debug.Print myChr
  Debug.Print myAsc
  Debug.Print Asc("?")

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset2 IPAPhon;}}
\viewkind4\uc1\pard\lang1033\f0\fs29 R
\par }

R
?
 123
 140

0
 

Author Comment

by:larkahn
ID: 6486829
I get basically the same result with the R appearing in the RTFB. Here is some modified code as you suggested, along with a debug.print. It appears that the RTFtext character saved is the R which is incorrect while the character for 0140 is correct when it shows ? in a normal font. The RTF box is somehow converting this into a different number character which I don't understand (123) and that is the R that gets printed.

Once again, in my original test before, I used the same font for both a textbox and an RTFB and I got the correct character in the text box but not the RTFB.

Private Sub Command2_Click()
Dim x
Dim myTextRTF
Dim myText
Dim myChr
Dim myAsc


  x = Len(RichTextBox1.Text)
   
  RichTextBox1.Text = RichTextBox1.Text + Chr(140)
  RichTextBox1.SelStart = x
  RichTextBox1.SelLength = 1
  RichTextBox1.SelFontName = "IPAPhon"
 
  RichTextBox1.SelLength = 0
  myTextRTF = RichTextBox1.TextRTF
  myText = RichTextBox1.Text
  myChr = Chr(140)
  myAsc = Asc(RichTextBox1.TextRTF)

  Debug.Print myTextRTF
  Debug.Print myText
  Debug.Print myChr
  Debug.Print myAsc
  Debug.Print Asc("?")

The debug window shows

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset2 IPAPhon;}}
\viewkind4\uc1\pard\lang1033\f0\fs29 R
\par }

R
?
 123
 140

0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6486834
Hope this should be reverse:

>>RichTextBox1.SelStart = x
>>RichTextBox1.SelLength = 1
0
 
LVL 14

Expert Comment

by:Matti
ID: 6487141
Hi!

What is the OS where these problems comes.
NT systems operate in these font and DBCS SBCS matters a litle different.

Those quick tests I had was on 98SE

I did not have IPAPhon and no bossibility to check whit is, and is this available for test?

****
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}{\f3\fswiss\fcharset1 IPAPhon;}}
{\colortbl\red0\green0\blue0;}
\deflang1035\pard\plain\f2\fs16 RichTextBox1\plain\f3\fs16 \'8c\plain\f2\fs16
\par }

RichTextBox1?
?
 123
 63
****

\viewkind4

>different number character which I don't understand (123) >and that is the R that gets printed

This is the unicode system and how it codes whit twobytes, not purposes to see it directly as "char" in rtf-code.


Matti


0
 

Author Comment

by:larkahn
ID: 6487180
I'm using Windows 98 first edition. The font is available for non-commercial use for free at

http://www.chass.utoronto.ca/~rogers/fonts.html

Larry
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6487185
May be larkahn got the font set, from some other sources...

larkahn,
you set the selection font, but i think no characters are there in the selection range, that is the SelStart and SelLength property don't select any thing, I hope.

0
 
LVL 14

Expert Comment

by:Matti
ID: 6487543
Hi!

That "R" was not chr(140)! that's Alt + 145 in font i downloaded.


Dim x&
x = Len(RichTextBox1.Text)
RichTextBox1.Text = RichTextBox1.Text + Chr(145)
RichTextBox1.SelStart = x
RichTextBox1.SelLength = 1
RichTextBox1.SelFontName = "IPAPhon"
RichTextBox1.SelLength = 0



Matti
0
 

Author Comment

by:larkahn
ID: 6487723
"R" is not the character that I am trying to print. The character I am trying to print looks like a hand printed lower case "a", which is definitely 140. I see the character R that you are talking about (145) which is actually a different character as well. I want the 140 character to print which is located 5 places to the left of 145 on the character map.

I am using the Windows font that was definitely downloaded from the site I listed in the previous comment. In fact, I paid the developer a licensing fee in case I ever want to use the font in a commercial product (which is probably beyond my capabilities). I did send an email to him and am awaiting a reply regarding the problem I am having.

Larry
0
 
LVL 14

Expert Comment

by:Matti
ID: 6487791
Hi!

Huh, what a mesh!

In my system debug window shows:

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}{\f3\fswiss\fcharset2 IPAPhon;}}
{\colortbl\red0\green0\blue0;}
\deflang1035\pard\plain\f2\fs16 RichTextBox1\plain\f3\fs16 \'8c\plain\f2\fs16
\par }

RichTextBox1?
?
 123
 63


The locale difference 1033 or 1035 had now effect tried to load them both as Rtftext.


Matti

0
 
LVL 14

Expert Comment

by:Matti
ID: 6487801
Hi!

There are some characters which do not pass this site postings as same as they do appear in VB debug window.
Those "?" are these!

Matti
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6487865
larkahn,

Sorry to say this, but I pasted your code into a new standard project and when I clicked the button I got a small 'a' in my RTB.

Seems like I got what you want.

I am running W2k w/ VB 6, sp 5.

I'll keep testing to see if I can screw it up, but so far it looks good to me.

Wileecoy.
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6487893
Ok larkahn,

I don't know what you did, but now I only get the 'R'.

Still looking into it <sigh> - that's what I get for braggin'!


Wileecoy.
0
 

Author Comment

by:larkahn
ID: 6487954
The following comment was just received from Hank Rogers, the developer of the IPAPhon font I am using:

"You are way over my head. I know next to nothing about Windows. Sorry I can't be
of help."

I have, though, asked Hank what kind of trouble it would be for him to try mapping the character to a different code number, while still keeping it away from the standard ASCII alphabet keys, if I exhaust all other troubleshooting possibilities.
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6488023
That is just what I was going to suggest.

I found that there was inconsistency in my results.  I started completely over with a new standard exe and got different results again.

For a while I was getting it okay, but when I repeated it, I got "???????a".

Then I just got a black bar when I did it a third time.

Tough to get a solution with so much inconsistency.

Wileecoy.
0
 

Author Comment

by:larkahn
ID: 6489050
I am starting to come to what I feel is a very unelegant solution. I have a second phonetic font "SILDoulos IPA93" which can be obtained as freeware from:

http://www.sil.org/computing/fonts/encore-ipa.html

On the windows character map the coding shows that the same character I am having problems with is coded to "a", even though it is not the lower case "a"
If I copy and paste from the character map, the character inserted is like a capital "A" with an accent of some kind.
I copy and paste this into a command button code as above and use the "SILDoulos IPA93" for the code RichTextBox1.SelFontName = "SILDoulos IPA93" and I now have the proper character in the RTB which can use mixed fonts. I feel it is a little inefficient to have to use an entire font for simply one character. In addition, the freeware obviously cannot be used for commercial purposes.
Here's a question, though. I also have a handwriting font creation software which is fairly easy to use. What if I scan the original IPAPhon problem character and use it as handwriting to create an entire font with just one character, as opposed to a graphic which would be more unwieldy in a wordprocessor-like environment? I could then reference this font and character and use the IPAPhon for the remainder. Anyone's thoughts would be appreciated.
0
 
LVL 14

Expert Comment

by:Matti
ID: 6489091
Hi!

A long time ago I did create some TTF-font's in Corel 6.0 these was just SBCS font's

Just make the font very large and copy the face by face using Word or similar software where you can make font in any size.

It need's a litle practice to make those font's but when i started it from nothing take three days to make one "full" font to distribution status.

Also if you do greate a metafile in paint, you may be sucsess in creating font faces.

Today i do not use SBCS font's in multilingual applications, mainly begause of NT problems.

I did not have "IPAPhon" problems in my 98SE system, one is a the keyboard driver you have there, Office clipboard, is there anything problematic which may cause moving to Unicode/DBCS.

As it's listed as "'8c" in yours.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rtfbox98/html/vbconsupportedrtfcodes.asp

Also check dll and version how they load, and what call's there are.

http://support.microsoft.com/servicedesks/fileversion/dllinfo.asp?fr=0&sd=msdn

Free dll and api tools from http://www.sysinternals.com   


Matti

0
 

Author Comment

by:larkahn
ID: 6489227
There is a very cheap software I used before called Data Becker, which is extremely easy to use and non technical (not having to worry about glyphs, etc.)I'm going to see if I can use this to create not the entire font set, but simply one character. The IPAPhon set has been very useful before the normal alphabet characters are mapped to standard keyboard keys, while the phonetics are with other codes. I don't want to have to recreate a whole font set this way simply for one character. The Data Becker software can probably do the job in a couple of hours, even though it's really intended to convert scanned handwriting into a custom handwriting font.
0
 

Author Comment

by:larkahn
ID: 6490596
I downloaded a trial version of a program called The Font Creator Program by High-Logic. It costs U.S.$50.

I probably shouldn't have done this; however, In 5 minutes, I was able to open up the IPAPhon, copy the troublesome character, paste it over what I felt was an obscure character I would not need, and then save the font with a new name. I then deleted the original font (after copying it to a safe place) and installed my doctored font. It works fine without any problems.

I should probably contact the font developer and ask him for permission to make this very small change. Even though I did pay a licensing fee, I should check. This, though, was an incredibly simple procedure.

My other procedure of mixing fonts would have worked fine in the Rich Text Box; however, it would have created chaos in my database which uses text boxes and also includes a search engine. I wouldn't have been able to paste my database entries into the RTFB.  It would have been a disaster.

Should I give myself the points (just joking). I will consider giving points to Matti, who seemed to put in the most effort in giving me suggestions.

Also, any final comments would be appreciated.

Larry
0
 
LVL 14

Expert Comment

by:Matti
ID: 6490948
Hi!

>My other procedure of mixing fonts would have worked fine >in the Rich Text Box; however, it would have
>created chaos in my database which uses text boxes and >also includes a search engine. I wouldn't have
>been able to paste my database entries into the RTFB.  It >would have been a disaster.

Did not say that this is coming from database, Acc2000 Unicode String do clear much this, in Acc97 format such problem does not exist.


>I should probably contact the font developer and ask him >for permission to make this very small change.
>Even though I did pay a licensing fee, I should check. >This, though, was an incredibly simple procedure.

If you do use modified files most likely yes, but if you do create own font most of the traditional font faces are so old that there are no copyright's, font's do exist in Guttenberg era. Later desings might have copyright's

Matti
 

0
 

Author Comment

by:larkahn
ID: 6503225
Thanks for your efforts.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question