472,145 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Displaying semi graphic caracters

Hi,

I'm looking for a way to display semi graphic characters in a multi line
text control or in a rich text control.
I've tried with all the characters of the extended ASCII table (code page
437), they appear correctly except the semi graphic ones.

Please help ...

Thanks a lot
David
Nov 20 '05 #1
2 3604
These are known as "glyph characters". They are not in ASCII (certainly not
in the misnamed "extended ASCII") as they are only a part of a single OEM
code page. The only way to get them to display:

1) Have the text in cp437.

2) PInvoke to MultiByteToWideChar, with a CodePage of 437 and a dwFlags of
MB_USEGLYPHCHARS.

3) You the resultant string in your display.
--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.
"David Scemama" <da***********@wanadoo.fr> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm looking for a way to display semi graphic characters in a multi line
text control or in a rich text control.
I've tried with all the characters of the extended ASCII table (code page
437), they appear correctly except the semi graphic ones.

Please help ...

Thanks a lot
David

Nov 20 '05 #2
Hello, David:

I suggest you use System.Drawing to draw boxes because most of the fonts don't support the graphic characters, some support them through char sets (like Microsoft Sans Serif) and few support it directly (like Arial)

You can learn how to use codepages in the internationalization documentation.

Anyway, here is an example. Create a form with a button and two textboxes. Set the Font property of TextBox1 to Arial and of TextBox2 to Microsoft Sans Serif. Leave the Font.GDICharSet property at the default value of zero for both TextBoxes. Past this code:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
'We need encoding for working with codepages:
Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding(437)

'TextBox1 uses Arial font.
'TextBox2 was assigned Microsoft Sans Serif with GDICharSet=0 at design time.
'TextBox1 is OK, but we must correct the font for TextBox2:
Me.TextBox2.Font = New Font(Me.TextBox2.Font.FontFamily, _
Me.TextBox2.Font.SizeInPoints, _
Me.TextBox2.Font.Style, _
GraphicsUnit.Point, _
255)
'Now the fonts are ready and both TextBoxes display correctly:
'We set from unicode (ChrW),
' from codepage 437 (enc.GetString)
' and inline ("┼═║") (keyboard: Alt+2501, Alt+2509, Alt+2490).
Me.TextBox1.Text = ChrW(&H255E) & ChrW(&H256A) & ChrW(&H256C) & ChrW(&H2563) _
& enc.GetString(New Byte() {32, &HC6, &HD8, &HCE, &HB9}) _
& " ─│┌┐└┘├┤┬┴┼═║╒╓╔ ╖╗╘╙╚╛╜╝╞╟*╡╢╣╤╥ ╧╨╩╪╫╬▀▄█▌▐░▒▓"
Me.TextBox2.Text = ChrW(&H255E) & ChrW(&H256A) & ChrW(&H256C) & ChrW(&H2563) _
& enc.GetString(New Byte() {32, &HC6, &HD8, &HCE, &HB9}) _
& " ─│┌┐└┘├┤┬┴┼═║╒╓╔ ╖╗╘╙╚╛╜╝╞╟*╡╢╣╤╥ ╧╨╩╪╫╬▀▄█▌▐░▒▓"
End Sub

Now, if you delete the "Me.TextBox2.Font = ..." statement, you will see that TextBox2 displays only empty boxes.
Of course, you can set Font.GDICharSet to 255 at design time.

You can use the charmap to see the codes corresponding to the graphic characters and if a font of your system supports them.

Note that this message has been coded with UTF-8 in order to keep the graphic characters. When you use special characters inline, you must save the code file (*.vb) encoding it, for example, with UTF-8, or other coding that supports the special characters.

Note also that Windows 98 and Me TextBoxes are not fully compatible with Unicode and "┼═║" might be displayed as "+-|"

Regards.
"David Scemama" <da***********@wanadoo.fr> escribió en el mensaje news:%2***************@TK2MSFTNGP10.phx.gbl...
| Hi,
|
| I'm looking for a way to display semi graphic characters in a multi line
| text control or in a rich text control.
| I've tried with all the characters of the extended ASCII table (code page
| 437), they appear correctly except the semi graphic ones.
|
| Please help ...
|
| Thanks a lot
| David

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steven | last post: by
2 posts views Thread by pei_world | last post: by
1 post views Thread by natural | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

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.