Help

Rich text box

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 4260 Views - Last Post: 03 October 2006 - 06:25 AM Rate Topic: -----

#1 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Help

Posted 27 September 2006 - 03:23 AM

Hi,

Would like to know how to get a richtext box to display graphics correctly.
The example below is what I get, but I need this to display the actual graphic of the character. (Ä = -)

This works fine in a standard text box with the font set to Terminal, but the rich text box refuses to display the correct chracter.

The obvious advantage is that the rich text box allows character colour change, allowing me to show different things in different colours in the same text box.

Is there a way to do this, either by setting properties or progromatically adding embedded control characters?
The text is a return from the Comm port, returned by a communications device attached.

Any help would be appreciated.


ÚÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ ³ Programming Options ³
ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ 1 ³ Program Serial Port Speed (saved) ³
ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ 2 ³ Display Current Programming ³
ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

Is This A Good Question/Topic? 0
  • +

Replies To: Help

#2 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 27 September 2006 - 03:44 AM

The Ä Symbol looks fine in the Rich Text box.
Was This Post Helpful? 0
  • +
  • -

#3 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Re: Help

Posted 27 September 2006 - 04:21 AM

View Postborn2c0de, on 27 Sep, 2006 - 03:44 AM, said:

The Ä Symbol looks fine in the Rich Text box.

Hi,

Thanks for the reply. Could you show me the code that you used to send the text to the box ? It may be that the code coming from my serial port is not being interperted correctly.

Thanks again!
Was This Post Helpful? 0
  • +
  • -

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 27 September 2006 - 12:26 PM

rtxtbox.Text = "Ä"
' OR
rtxbox.Text = Chr(196)


Was This Post Helpful? 0
  • +
  • -

#5 evilbeatfarmer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 08-September 06

Re: Help

Posted 27 September 2006 - 02:39 PM

You want the extended ASCII characters to show up correct? Like the lines and boxes (ANSI art stuff).

Try setting the RTF textbox control's font to Terminal or System or some other font that has the ANSI character graphics set.
Was This Post Helpful? 0
  • +
  • -

#6 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Re: Help

Posted 28 September 2006 - 12:44 AM

View Postborn2c0de, on 27 Sep, 2006 - 12:26 PM, said:

rtxtbox.Text = "Ä"
' OR
rtxbox.Text = Chr(196)


Hi,

Thanks very much, I tried it like that, but for some reason, I still dont get the character I am looking for. I managed to get it by doing the following:

'Add the text to the box
txtTerm.SelStart = Len(txtTerm.Text)
txtTerm.SelText = vbCrLf & Chr(196)

' then selected the box's text and applied the font/colour
txtTerm.SelStart = 0
txtTerm.SelLength = Len(txtTerm)
txtTerm.SelColor = &HFF0000
txtTerm.SelFontName = "Terminal"

This then applied the terminal font to the box changing the characters. The box is already set for terminal font, so I am not sure why it is not being treated as terminal font straight away.

I am still trying to figure out why.

Thanks for your reply, I appreciate it.
Was This Post Helpful? 0
  • +
  • -

#7 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 28 September 2006 - 09:39 AM

The RichTextBox on my PC uses MS Sans Serif by default.
And try using this code to see if the control uses any other font by default on loading.
Private Sub Form_load()
MsgBox rtxtbx.Font
End Sub


Was This Post Helpful? 0
  • +
  • -

#8 shainab88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-September 06

Re: Help

Post icon  Posted 28 September 2006 - 09:52 PM

[font=Arial][size=3][b]

hi i don't know how to post a question on this site, so i decided i would post it here. sorry if i messed w/ someones post, but heres my question, and if u know how to do it plz send me a personal message! thank u!! the problem is that in my class we have to create a program in visual stdio, but i don't know how to create it...heres what u have to do:

1) Create the main program file. At the top of this file, the following comment block
is required to receive full credit.
/*
Your Name
Your Class
Today’s Date
Programming Assignment #1
*/
After which, create a main function, with a return type of void and a parameter
list of type void.
2) Create a function and name it OutputHeader, which has a void return type and a
parameter list of void. Create a prototype for this function and put it at the
beginning of your program.
Inside of OutputHeader, use a series of printf statements to produce the following
output
Your Name
Your Class
Today’s Date
Programming Assignment #1
Call this function from your main function
3) Create a function and name it InputData, which has an int return type and a
parameter list of an array of type double.
Using a for loop, input 10 doubles from the keyboard and store them in the array
from the parameter list. Remember, to read in a type double, a format string of
“%Lf” must be used in the scanf statement. The function should keep a count of
the number of entries, and this value should be returned by the function.
4) Create a function and name it ShowData, which has a void return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array. Use a for loop to show the contents of the array. Show each index
and the associated value.
5) Create a function and name it FindAverage, which has a double return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array. Use a for loop to find the average of the data in the array. The
average should be returned by the function
6) Create a function and name it FindMinium, which has a double return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array. Use a for loop to find the minimum value stored in the array. The
minimum should be returned by the function.
7) Create a function and name it FindMaxium, which has a double return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array. Use a for loop to find the maximum value stored in the array. The
maximum should be returned by the function.
8) Create a function and name it FindVariance, which has a double return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array. Use a for loop to find the maximum value stored in the array. The
maximum should be returned by the function.
Variance is a statistical function, which contains several steps. First, the
difference between each data value and the average of all the data values is taken.
Next, this difference is squared to make a positive number. Then, each of these
squared values is summated. Finally, after the sum is complete, the total is
divided by the number of data points. This final value is the variance.
2 ) x (x
n
1 variance ∑ − =
The FindAverage function may be used to solve this section.
9) Create a function and name it FindStdDev, which has a double return type, and a
parameter list of an array of type double and an integer. The integer is the length
of the array.
At the beginning of the program, just after the #include<stdio.h>, and the
statement #include<math.h>. The math.h is the header to the C math routines
library, and contains many useful tools. For standard deviation, the square root
function must be used.
The square root command is:
StdDev=sqrt(Variance);
Standard Deviation is the square root of the Variance. The FindVariance function
may be used to solve for the Standard Deviation.
10) Create a function called Menu, which has a void parameter list and a void return
type.
The menu should look something like this:
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
Create a while loop that runs the menu until the ‘q’ character is
pressed. In this menu, however, a string is to be used.
Create some character array, for example, InputString, and then
use a scanf to read the user input.
Once this is done, take only the first character of the string
and use it to check which option from the menu.
For example:
char InputString[80];
char key=’0’;
scanf(“%s”,InputString);
key=InputString[0];
Use the menu routine to call each of the previous functions that
have been created. An if-then-else tree or a switch statement may
be used to call the functions.
After the function is called, print the result of the function to
the screen along with the name of the Menu Item
Call this function from your main function
Example Output:
Eric Becker
CSE 1311
September 18, 2006
Program Assignment 2
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
1
Please enter 10 doubles
10.0
1.0
1.45
-3.33
1.223
3.33
22.2
3.33
-22.23
12.3
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
2
The Array is
Array[0]=10
Array[1]=1
Array[2]=1.45
Array[3]=-3.33
Array[4]=1.223
Array[5]=3.33
Array[6]=22.2
Array[7]=3.33
Array[8]=-22.23
Array[9]=12.3
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
3
Average is 2.9273
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
4
Minimum is -22.23
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
5
Maximum is 22.2
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
6
Variance is 119.048
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
7
StdDev is 10.9109
Menu
1-Input Data
2-Show Array
3-Find Average
4-Find Minimum
5-Find Maximum
6-Find Variance
7-Find Standard Deviation
q-quit
Was This Post Helpful? 0
  • +
  • -

#9 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Re: Help

Posted 29 September 2006 - 12:20 AM

View Postborn2c0de, on 28 Sep, 2006 - 09:39 AM, said:

The RichTextBox on my PC uses MS Sans Serif by default.
And try using this code to see if the control uses any other font by default on loading.
Private Sub Form_load()
MsgBox rtxtbx.Font
End Sub




Hi,
Thanks, the text box reports terminal font just prior to the character being put into the text box! I dont understand how its possible, but its happening :)

Anyway, thanks so much for all the help so far.
Was This Post Helpful? 0
  • +
  • -

#10 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Help

Posted 29 September 2006 - 08:14 AM

View Postshainab88, on 29 Sep, 2006 - 10:22 AM, said:

hi i don't know how to post a question on this site, so i decided i would post it here. sorry if i messed w/ someones post, but heres my question, and if u know how to do it plz send me a personal message!

You post a question by clicking the 'NEWTOPIC' button.

This post has been edited by Louisda16th: 01 October 2006 - 11:11 AM

Was This Post Helpful? 0
  • +
  • -

#11 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 29 September 2006 - 10:45 AM

Quote

Hi,Thanks, the text box reports terminal font just prior to the character being put into the text box! I dont understand how its possible, but its happening Anyway, thanks so much for all the help so far.

Surprising...which Runtime Files are you using for VB6.
I know this might be irrelevant but I'd like to know which Windows OS and processor you are using...It might lead to something.

And have you tried using other Fonts for this?
Do they display the character or is it the same story for the rest too?
Was This Post Helpful? 0
  • +
  • -

#12 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Re: Help

Posted 02 October 2006 - 12:48 AM

View Postborn2c0de, on 29 Sep, 2006 - 10:45 AM, said:

Quote

Hi,Thanks, the text box reports terminal font just prior to the character being put into the text box! I dont understand how its possible, but its happening Anyway, thanks so much for all the help so far.

Surprising...which Runtime Files are you using for VB6.
I know this might be irrelevant but I'd like to know which Windows OS and processor you are using...It might lead to something.

And have you tried using other Fonts for this?
Do they display the character or is it the same story for the rest too?

Hi,

I am using vb6 SP 6 Running on XP professional.

I have tried other fonts, but none seem to give me exactly what I want. I must admit, I have not gone intensively into other fonts, as I have always been using Terminal font.
I thought perhaps it was my project that somehow was causing the issue, so I wrote a standalone app that basically loaded the characters into 4 text box's. 2 were standard text box's and 2 were rich text box's. I set 1 text box and 1 rich text box to courier and set the other 2 with Terminal font. The rich text box with the terminla font does not show the correct characters above code 127. I then again use the procedure to re-load the font as terminal after selecting the text and it then displayed it correctly. I am at a loss to understand it.

I have attached my code so that you can see it. Let me know how it works for you!. Thanks very much.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#13 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 02 October 2006 - 02:08 AM

Here's what happens on my PC.
  • Rich Text Box with MS Sans Serif : WORKS
  • Rich Text Box with Terminal : WORKS
  • Std. Text Box with MS Sans Serif : WORKS
  • Std. Text Box with Terminal : FAILS
It's strange how the RichTextbox displays it for me while the Standard Text Box displays a -.

Start Character Map and check out both the Fonts.
THE ASCII Character differs for the two.
I tried setting it using Chr(142) and it works.

Let me know how it performs for you.
Was This Post Helpful? 0
  • +
  • -

#14 Marc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-September 06

Re: Help

Posted 02 October 2006 - 05:15 AM

View Postborn2c0de, on 2 Oct, 2006 - 02:08 AM, said:

Here's what happens on my PC.
  • Rich Text Box with MS Sans Serif : WORKS
  • Rich Text Box with Terminal : WORKS
  • Std. Text Box with MS Sans Serif : WORKS
  • Std. Text Box with Terminal : FAILS
It's strange how the RichTextbox displays it for me while the Standard Text Box displays a -.

Start Character Map and check out both the Fonts.
THE ASCII Character differs for the two.
I tried setting it using Chr(142) and it works.

Let me know how it performs for you.

HI.

I see what you mean. Thats just crazy.
I found a note in the MSDN Library that is as follows:

Note Available fonts depend on your system configuration, display devices, and printing devices, and therefore may vary from system to system.

I wonder if that is the clue? My PC is setup for South Africa etc. I wonder if regional settings affect it?

I will keep on trying to find the issue and if I find anything I will come back to you.

Thanks again for all the time taken in this.
Was This Post Helpful? 0
  • +
  • -

#15 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Help

Posted 02 October 2006 - 11:45 AM

Hmm...I wonder too.
It could also be a different Font Version.

Do let me know if you find anything...I'll do the same.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2