473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

changing font type in RTB

Hi all,

I know now how to change the font name of a RTF file in a RTB control using,
for example:
RTextBox1.SelFontName = cmbFonts.Text

I have a RTF file -created with Word- displayed in a RTB control. Whenever I
change the font type during the runtime by selecting a font name from a
combobox -of all system fonts, the text changes its font correctly but I
loose some formatting such as a bold text and/or titles become normal text.
Is there any way of changing the font type/name without touching the
formatting of the text (e.g. a title of 15pts will still be the same but
only its fontname will change). So the users of the app, have only access to
change the font type not the font size..

Thanks,
--
Cengiz Ulku
ce*****@bluewin.ch
Jul 17 '05 #1
3 6615
> I know now how to change the font name of a RTF file in a RTB control
using,
for example:
RTextBox1.SelFontName = cmbFonts.Text

I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a
combobox -of all system fonts, the text changes its font correctly but I
loose some formatting such as a bold text and/or titles become normal text. Is there any way of changing the font type/name without touching the
formatting of the text (e.g. a title of 15pts will still be the same but
only its fontname will change). So the users of the app, have only access to change the font type not the font size..


I just tried this (after changing the default control names to match yours)

Private Sub Command1_Click()
RTextBox1.SelFontName = cmbFonts.Text
End Sub

Private Sub Form_Load()
For X = 0 To 100
cmbFonts.AddItem Screen.Fonts(X)
Next
End Sub

on a RTF that I produced in Word a couple of years ago that has different
font sizes, italics and bolds in it. All of that formatting was preserved no
matter what I highlighted before clicking the button... even when the
highlight included only part of the bold title, all of the italic sub-title
and part of the normal body text. Do you have any other code being activated
besides the font change that might be getting in the way?

Rick - MVP
Jul 17 '05 #2
I think you can do that using SendMessage with
EM_SETCHARFORMAT.
There's a CHARFORMAT structure you send in with
your new format values, and a dwMask parameter that's
used to indicate which of your CHARFORMAT values are
relevant. If the mask includes only font name then the rest
should be left alone.

--
--
Cengiz Ulku <ce*****@bluewin.ch> wrote in message
news:3f**********@news.bluewin.ch...
Hi all,

I know now how to change the font name of a RTF file in a RTB control using, for example:
RTextBox1.SelFontName = cmbFonts.Text

I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a
combobox -of all system fonts, the text changes its font correctly but I
loose some formatting such as a bold text and/or titles become normal text. Is there any way of changing the font type/name without touching the
formatting of the text (e.g. a title of 15pts will still be the same but
only its fontname will change). So the users of the app, have only access to change the font type not the font size..

Thanks,
--
Cengiz Ulku
ce*****@bluewin.ch

Jul 17 '05 #3
Ok I found what was wrong !!

What I used in my code was:

RTextBox1.Font.Name = cmbFonts.Text

So this causes a total formatting, with a default font size, I think... When
I try with SeLFontName it works!

Thanks for your help,

--
Cengiz Ulku
cengizu at bluewin.ch


"Cengiz Ulku" <ce*****@bluewin.ch> wrote in message
news:3f**********@news.bluewin.ch...
Hi all,

I know now how to change the font name of a RTF file in a RTB control using, for example:
RTextBox1.SelFontName = cmbFonts.Text

I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a
combobox -of all system fonts, the text changes its font correctly but I
loose some formatting such as a bold text and/or titles become normal text. Is there any way of changing the font type/name without touching the
formatting of the text (e.g. a title of 15pts will still be the same but
only its fontname will change). So the users of the app, have only access to change the font type not the font size..

Thanks,
--
Cengiz Ulku
ce*****@bluewin.ch

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
6
by: Ioannis Demetriades | last post by:
Hi, I need to change the printer's font to "control" -a printer font, and then send a sequence of characters to the printer. My problem is that I cannot change the printer's font. Can this be...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
4
by: Siah | last post by:
Hi, I wanted to dynamically update pieces of my page in the following fashion. Look at the following html code: <span id='person_23_name'> Mike </span> <span id='person_28_name'> Siah </span>...
15
by: mart2006 | last post by:
Hi, This is probably really simple to most of you but I have a PHP based website that I want to change the font (of the outputted HTML) and I'm really struggling! Here is a snippet of my code: ...
15
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px;...
1
by: Blasting Cap | last post by:
I am having trouble changing the font for a PushButton control in a datagrid button column. I have seen several posts refer to styles and simple changes to the HTML for font changes but most of...
1
by: Markw | last post by:
Hi folks, I probably used the term 'report' incorrectly. Sorry for that in advance. The below code produces a 2 column web page that shows in the first column a picture and the 2nd column shows...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.