Re: Text control?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 12 Dec 2006 16:59:20 -0500
There are a number of factors here.
First, you have to decide what attributes you are going to save. Essentially, the entire
LOGFONT structure, plus height and text color (I would suggest always using
SetBkMode(TRANSPARENT) and managing the background color as part of your app, like
PowerPoint does with text in boxes).
If you want all the text in a text object to be the same, then it's easy. Otherwise, you
have to move to a rich edit control and use the ability of the rich edit control to render
complex text on a background to do the drawing (I've not done this, but there have been
discussions in past threads on how to do this). Then what you would serialize to your
file (and probably store in your document) is the StreamOut rtf text, which you would
StreamIn and render on demand for each text object. This means you wouldn't need to store
all the information in an independent structure, but could just have the control magically
encode it in the rtf portion.
When it comes to serializing, you might also consider using XML representations instead of
binary.
There also would be issues about text rotation; I'm not sure how this could be handled but
I'd start to look into the matrix transformation operations, because otherwise I don't
think a rich text control can render text other than horizontally.
To edit the text, such as when you click on it, you would bring up an edit or rich edit
control (note that in most apps, if you edit rotated text, you get a horizontal-only
editing control to change it, which suggests that the controls can't render rotated text
during editing operations, which is different from the rendering operations that you use
to draw the text when it is finally edited.
I'm not sure what you mean by TextOut being good only for rendering "predefined" text. It
is one of the exercises on the third day of our MFC course to write a program that allows
users to key in text and then show it on the screen, and then drag it around with the
mouse. TextOut works perfectly well for rendering text which is typed in dynamically. If
I can teach this on the third day of class, after about an hour's lecture on text input
and displaying, it ain't rocket science.
joe
joe
On Tue, 12 Dec 2006 19:47:26 +0100, Andreas Johansson <fri.radikal@xxxxxxxxx> wrote:
Hi!Joseph M. Newcomer [MVP]
I'm coding a vector based drawing program and have implemented different
shapes. The thing I'm trying to figure out now is how text manipulation
works in MFC. I would like to be able to create a text, select, edit,
resize and delete the text. I also want to save the different texts
attribute when the user closes the program.
I have up to this point only experimented with TextOut but find it to
limiting and only useful for outputting predefined text.
/Thanks
Andreas
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Text control?
- From: Mihai N.
- Re: Text control?
- References:
- Text control?
- From: Andreas Johansson
- Text control?
- Prev by Date: Re: How to properly thread a singleton class?
- Next by Date: Re: create a project without dialog
- Previous by thread: Re: Text control?
- Next by thread: Re: Text control?
- Index(es):
Relevant Pages
|