Rich Text Format

Hi,

My problem is thus,  I want to supply some text and a CHARFORMAT2 struct to 
a method and simply have it return the RTF, you can see below.  I dont want 
to have to create a rich edit control etc.  There must already be a method or 
class that will do this surely?

Using a rich edit control you can take a string "this is a testing string".  
Create a CHARFORMAT2 struct and pass it to the metthod SetCharFormat to 
format that string.  This produces some rtf text like this - although note 
its not the rtf for the "this is a test string" text.  What i want to know is 
how do you generate the rtf below without passing it to SetCharFormat.  I 
want to cut out the CRichEditCtrl for various reasons.

{\rtf1\ansi\ansicpg1252\deff0\deflang1033
	{\fonttbl
		{\f0\fswiss\fprq2\fcharset0 Tahoma;}
		{\f1\fnil\fcharset0 Arial;}
	}
	{\colortbl ;\red255\green128\blue255;
	\red0\green0\blue0;\
	red0\green0\blue255;\
	red255\green128\blue0;
	}
	\viewkind4\uc1\
	pard\cf1\ul\b\f0\fs22 This is a test.\cf2\ulnone\b0\f1\fs20\par
	\pard\qc\cf3\ul\fs40 Even more testing?\cf2\ulnone\fs20\par
	\pard\qr\cf4\i\fs32 and finally further testing.\par
}
0
wdhough (17)
6/30/2006 8:40:02 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
907 Views

Similar Articles

[PageSpeed] 42

Nope, no such luck.  Without the RichEdit control, the whole exercise is pointless,
because it is the RichEdit control that actually implements all this functionality!  There
are methods and classes that do this, and they are the classes and methods that are
involved in Rich Edit controls.  Surely.  Note that SetCharFormat is actually a MESSAGE
(EM_SETCHARFORMAT) to a Rich Edit control and therefore makes no sense unless there is
such a control in existence.

Otherwise, you are free to write your own subroutines that create RTF text, but it is not
at all supported without the control itself.  You are always free to create the control
and make it invisible, but you can't eliminate it.
					joe

On Fri, 30 Jun 2006 01:40:02 -0700, wdhough <wdhough@discussions.microsoft.com> wrote:

>Hi,
>
>My problem is thus,  I want to supply some text and a CHARFORMAT2 struct to 
>a method and simply have it return the RTF, you can see below.  I dont want 
>to have to create a rich edit control etc.  There must already be a method or 
>class that will do this surely?
>
>Using a rich edit control you can take a string "this is a testing string".  
>Create a CHARFORMAT2 struct and pass it to the metthod SetCharFormat to 
>format that string.  This produces some rtf text like this - although note 
>its not the rtf for the "this is a test string" text.  What i want to know is 
>how do you generate the rtf below without passing it to SetCharFormat.  I 
>want to cut out the CRichEditCtrl for various reasons.
>
>{\rtf1\ansi\ansicpg1252\deff0\deflang1033
>	{\fonttbl
>		{\f0\fswiss\fprq2\fcharset0 Tahoma;}
>		{\f1\fnil\fcharset0 Arial;}
>	}
>	{\colortbl ;\red255\green128\blue255;
>	\red0\green0\blue0;\
>	red0\green0\blue255;\
>	red255\green128\blue0;
>	}
>	\viewkind4\uc1\
>	pard\cf1\ul\b\f0\fs22 This is a test.\cf2\ulnone\b0\f1\fs20\par
>	\pard\qc\cf3\ul\fs40 Even more testing?\cf2\ulnone\fs20\par
>	\pard\qr\cf4\i\fs32 and finally further testing.\par
>}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
6/30/2006 12:32:28 PM
Reply:

Similar Artilces:

how do you Create flashing Text
I am creating a newsletter and want one of the titles in the newsletter to flash or blink. How do I do this? Ask this here: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.publisher.webdesign&cat=en_US_1845e149-582a-4e62-8d76-f1c90f948f44&lang=en&cr=US -- Mary Sauer MVP http://msauer.mvps.org/ "lukieguy22" <lukieguy22@discussions.microsoft.com> wrote in message news:0E40D83D-8E98-40A7-ABE1-94307073C79E@microsoft.com... >I am creating a newsletter and want one of the titles in the newsletter to > flash ...

Conditional Formating #18
Dear all, I would like to apply a conditional formating to fill with a red colour some Excel cells when the computer calendar gets some date, I would like to fill that cells when "best before date" of some pruducts gets that date with the computer calendar. Thanks a lot. Pedro Mestre One way: If cell A1 is active: CF1: Formula is =TODAY()>=A1 Format1: Patterns/red In article <13BD3AC5-9DFE-4C53-BA91-440BC506B82E@microsoft.com>, Pedro Mestre <PedroMestre@discussions.microsoft.com> wrote: > Dear all, > > I would like to apply a condition...

Preserve format in pivot table
I have a pivot table where I formated the numbers using the "accounting" format. When I refresh the table, it goes back to the "general" format. How do I keep the "accounting" format when I refresh? Thanks Things to try -- if they don't work, you could record a macro as you refresh and reformat the pivot table. Then, run that when you want to update. Set the pivot table to preserve formatting: --On the pivot toolbar, choose PivotTable>Table Options --Add a check mark to 'Preserve formatting', click OK Depending on your version of Excel, you ...

Formatted text in QuickParts/AutoText
Word 2007 I'm back with another issue. I cannot seem to get my saved QuickParts to hold its formatting, specifically, underlining. So, in reading the boards, I decided to use AutoCorrect instead, and apply formatted text settings. While the text shows up formatted in the little window in the AutoCorrect tab, when I insert it into my document, the underlining ONCE AGAIN is gone! Is anyone else having these issues with autotext / quickparts functionality? This entire feature in Word 2007 just does not work properly in so many ways for me. Of course I'm not discounting us...

How do I extract text content from an exported .rwz file
Outlook 2003, Office Pro - When you export Rules and create a .rwz file, the file is not a pure text file as it seems to be loaded with null chars. I would like to extract the long list of spam words used in a particular rule. Is there a way or a utility which will remove all the nulls from the file so I may edit it to get the contents I want ? The alternative storage location is not any easier - trying to get the same info, as it is similarly stored, out of the registry. :( -Ric Not possible. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Backup and R...

If/then to print text.
I want to use a formula so that when a value over zero is put into one cell, a line of text prints in another cell. I know it is an if then function, but I've forgotten the exact formula and the way to encode the text message in the formula. Shadyhosta wrote: > I want to use a formula so that when a value over zero is put into one cell, > a line of text prints in another cell. I know it is an if then function, but > I've forgotten the exact formula and the way to encode the text message in > the formula. Try this: =IF(A1>0,"print this text","prin...

Getting text from hidden text producing error
I am using code to populate a drop down from hidden text (in text formfields) in a Word form. The code works great, however, I have now hidden the section that contains the text form fields and the code returns an error. Is there something I should be inserting in the code so that it can cope with hidden text/ bookmarks? I don't want to unprotect, unhide, run existing code, and then rehide and reprotect as this is cumbersome. ub Fillnamelist() Select Case ActiveDocument.FormFields("scheme").Result Case "CAMBERWELL" With ActiveDocument.FormFiel...

TEXT problem...
Hello. I have a cell with the following formula: TEXT(e2,"mmmm dd, yyyy (CSC)") cell e2 contains a date formatted value, "March 27, 2004" Question, although the formula appears to work in terms of converting the date to a text datg (for manipulation later), why does the result yield "March 27, 2004 (C0C)" instead of "March 27, 2004 (CSC)"? For some reason, the function is replacing my 'S' for a zero (0). Any ideas? Mark :) Hi Mark! Its because the S is being interpreted as seconds. Since you (presumably) have a naked date in E2...

Extending formulas/formats with imported tata
Hi -- I have a worksheet that includes imported data. Several columns consist of row-specific formulas. How do I get Excel to automatically adjust these columns to account for more or fewer rows whenever I import new data? Example 1: I import a file with 100 rows. I create the formulas on columns outside the imported data and copy these formulas down the 100 rows. The following week, I call up this spreadsheet, and using Data | Import External Data | Edit Text Import, I import a file with 145 rows. The formulas on the first 100 rows recalculate properly. But the final 45 rows don't...

Getting details and adding text to the receipt
Hi... I want to get some details from the Receipt and also want to add some text to the receipt... How can I do this... I tried to this with session.variable was not able to successed. I want to do this through VB.Net... A example in VB will also do for me... Waiting for your reply... :-( Vicky... :-) Can provide a sample of what you have tried? Rob "Vicky" <Vicky@discussions.microsoft.com> wrote in message news:A75FF20D-9549-48DB-8C76-C2A544A321CD@microsoft.com... > Hi... > > I want to get some details from the Receipt and also want to add some > text...

Formatting Cell Text
Can you set a text up to display number's in foot and inches example 12 would appear as 1' 13 would appear as 1'1' etc.? Thanks, Ben Hi Ben this is not possible with formtas. You have to use a helper column for this. see Chip's site for some more information: http://www.cpearson.com/excel/fractional.htm -- Regards Frank Kabel Frankfurt, Germany Ben wrote: > Can you set a text up to display number's in foot and > inches example 12 would appear as 1' 13 would appear as > 1'1' etc.? > > Thanks, > > Ben Thanks, Frank. Ben >----...

Get Rich
Take advantage of a great deal ...

IF to check color of text
I have a calendar made up of my work schedule. I have the days that am working a font color of black. I have the days that I am off a fon color of light gray. I'm looking to use an IF function in which detects the font color, an if true, add eight, otherwise add zero. Is this possible? E -- Message posted from http://www.ExcelForum.com You have to use a userdefined function. See Chip Pearson's site for an example: http://www.cpearson.com/excel/colors.htm "eckaner <" wrote: > > I have a calendar made up of my work schedule. I have the days that I > a...

referencing conditional formatting
Using XL2000, I have made a simple inventory/order workbook consisting of 2 sheets: Food Items and Order Sheet Currently in J4 of 'Food Items' =IF(AND(H4<>"",H4>=G4),"Reorder!","") Copied down to J41 This results in the flag to reorder when inventory reaches a certain level Currently in A6 of 'Order Sheet' =LEFT('Food Items'!I4,1)*COUNTIF('Food Items'!J4,"Reorder!") Copied down to A43 This tells me how many cases to order Works as intended, but I would like something to dazzle others <g> First I would c...

Dupe Text Attachments
All of a sudden, starting yesterday, every message I receive has an attachment with a .TXT file with the contents of the message. It's like getting duplicate messages. How can I correct that? Help... I am having the same problem. I have isolated it to plain text messages sent from Outlook 2000 clients. It doesn't appear to happen with 2003. It also just started happening a couple of weeks ago. "Robert" wrote: > All of a sudden, starting yesterday, every message I receive has an > attachment with a .TXT file with the contents of the message. It's l...

convert text to numeric values
My database (Access 2007) keeps track of bids from FE colleges. These are made in an academic year (these span two 'calendar years e.g. 2009-10 for the current academic year). Sometimes the bids are carried forward to, and paid in, the following academic year. The 'Bid Year' and 'Paid Year’ are text fields. When designing a query that will give me the total sum of bids made, bids approved and bids actually paid, I can do separate ones based on 'Bid Year' and 'Paid Year' but the totals are quite often different if a year has bids that have been carr...

Pasted text splits into separate text boxes.
Recently upgraded my Publisher program. When using a text box from a template, and I try to paste text, it breaks the text, line by line into separate boxes within the text box. I never had this problem with my previous Publisher program. What's up with this? A JackBird <A JackBird@discussions.microsoft.com> was very recently heard to utter: > Recently upgraded my Publisher program. When using a text box from a > template, and I try to paste text, it breaks the text, line by line > into separate boxes within the text box. I never had this problem > with my previo...

Excel Options
Can anyone tell me how I can have the default setting in Excel set to NOT wrap the text? I do a lot of copy/pasting and it drives me nuts to keep having to deselect the wrap text. HELP!!! For me, the default is off. But I think excel tries to help. If you paste text into a cell and that text contains alt-enter, then excel says: you need wraptext on! And does it. You could give up trying to do it after each paste and just do one mighty change (all your cells selected) when you're finished. or you could use a macro and assign it to your favorite shortcut key: Option Explicit Sub t...

Adding text to all outgoing messages...
I would like to add a text message to all outgoing mail messages. How can i do this ? Carlos for your text (assuming you are usaing exchange)... http://www.gfi.com/downloads/downloads.aspx?pid=ME&lid=en They provide a free version that does disclaimers. "Carlos Mendes" wrote: > I would like to add a text message to all outgoing mail messages. How > can i do this ? > > Carlos > check this vbs sample http://www.aloaha.com/article/eventsink.html "Carlos Mendes" <cjmendes@confetil.com> schrieb im Newsbeitrag news:51esu09sh1tpfl4usbfbht083cq970...

conditional formatting question #9
I have a spreadsheet that gets updated monthly and looks like the example below Jan Feb march April May June 21,000 23,500 22,224 22111 20,111 25,000 I've asked this question before and have gotten great tips but each month when refesh the pivot table it looses all the conditional formatting and I start over again. The conditional formatting needed is if #'s go down for three consecutive months in a row they are highlighted in red. I need the first month of dropped revenue example above would be March in yellow and then t...

Unable to use original text prefix character
I want to use a '>' to prefix original text in replies and forwards. I have it set up to do so in my options, but it still just uses the blue bars around the original text. I think the options are just being ignored. Even if I force plain text format, it still composes in HTML unless I change it manually in the new message's toolbar. Anyone have any ideas on this? My IT guy cleared my profile and it had no effect on the problem. Thanks! waterrockets@gmail.com <waterrockets@gmail.com> wrote: > I want to use a '>' to prefix original text in replies and fo...

Get Rich
Take advantage of a great deal ...

.ps1 attachment preview with text previewer
How can I get .ps1 files to preview with the built-in text preview handler. I have unblocked the .ps1 attachments so I can see them (in the registry) and I have associated the .ps1 extension with the built-in text previewer but I still get the message "This file cannot be previewed. Try opening the file in the program in which it was created". I am an instructor and I have students send their homework in via e-mail. Often times I like to quickly view the scripts without saving the attachment. This is not a security risk because you can't execute a powershell script dir...

Automatic colors for text
Can you set excel to automaticly fill in a cell color for specific text entered? yes - check out conditional formatting on the format menu if you'ld like further assistance, please post back with more details -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "mogravy" <mogravy@discussions.microsoft.com> wrote in message news:65C89261-54D6-4E54-9569-0C19AB86DF64@microsoft.com... > Can you set excel to automaticly fill in a cell color for specific text > entered? ...

change color if text is = or not, to text in other column
I am taking practice tests. ColB contains text (the correct answers). ColC contains text (my practice answers). I want the cells in ColC to turn green if my answer is correct (matches the text in ColB) and turn red if it is incorrect (does not match the text in ColB). I can't figure out how to get it to apply Conditional Formating on the columns. It wants me to apply it to only a single cell. I've also tried copying and pasting special just the formatting. It turns the cells in ColC green if they match cell B2 (not the corresponding answer that is in the same row). Please ...