Trying to indent text in CRichEditCtrl

I am trying to make a CRichEditCtrl indent lines in the control a set number of spaces. If the window is resized, the indents stay.  (What I really need is to be able to indent selected lines, such as those without a preceding newline char, and not indent others.)  But I can't even get part A to work yet.  I've tried SetParaFormat(), but with no luck.  And I'm not sure if this really does what I want.  I've seen it done smoothly in other apps, so I'm sure it's out there somewhere....

Thanks!
MournbladeAsked:
Who is Participating?
 
mikeblasCommented:
> And I asked "why is it ONLY in twips" - which you didn't answer.  

Oh. Probably because having more than one measurement unit adds needless complexity to the interface.  It's easy to convert from/to twips to any other linear measure--so, why bother putting that into the interface?

 > You noticed this.  

Yep; I left out one line of code. I fixed it--you have a correct solution, here. It took less than two minutes for me to realize the omission and post a correction. So, that mistake had absolutely no effect on you.

 > but your final sentence here earned you the zero.

Offering to write a more complete sample earned me a zero? Goodness; it looks like it's _you_ who's suffering from insecurity.

..B ekiM
0
 
mikeblasCommented:

So, you want the first line of the paragraph to be indented more than the rest of the paragraph, right?  Like this:

       blah blah blah blah
   blah blah blah blah blah
   blah blah blah blah blah

That's called a first line indent, it's pretty esay to set up.

You need to set a negative value for the offset and a positive value for the indent.  The value for dxStartIndent is going to be the number of twips for the first line.  The dxOffset needs to be the different between the indentation for the first line and the rest.

These measurements are all in twips, so on inch is 1440 units.

You'd set up the structure like this:

   PARAFORMAT pf;
   pf.cbSize = sizeof(pf);
   pf.wNumbering = 0;
   pf.wReserved = 0;
   pf.dxStartIndent = 1440;
   pf.dxRightIndent = 0;
   pf.wAlignment = PFA_LEFT;
   pf.cTabCount = 0;
   pf.dwMask = PFM_OFFSET | PFM_ALIGNMENT | PFM_RIGHTINDENT | PFM_STARTINDENT;

And that'll do it!

..B ekiM
0
 
MournbladeAuthor Commented:
I have not actually rejected this answer.  I just wanted to write a comment real quick, and I don't yet have time to test this.

I actually want the opposite, like this:

blah blah blah blah
    blah blah blah blah
    blah blah blah blah

though i doubt that matters much.  Also, I want everything in the control to come out like this- is this a 'paragraph', or something else?

Talk to you again soon...
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
MournbladeAuthor Commented:
Ok, I've tested it.  You've got to be kidding!  First-why is this done only in twips?  Second, I cannot get it to do anything even close to what I want.  It will indent only at 1440 (and then way more than an inch - though this may merely be dependent on my display settings), and it indents ALL lines.  I cannot get it to distinguish a beginning line.  And what makes up a "beginning" line, anyway?  And why does the MFC documentation, which is basically nonexistant, assume we know what defines these "paragraphs", etc?  "Paragraph?"  Huh?

Frustrating...  but thanks anyhow.  
0
 
mikeblasCommented:
> You've got to be kidding!  

I'm not kidding at all. Why do you need to insult my efforts to help you?

 > First-why is this done only in twips?  

Because that's a standard unit of measure for publishing and page layout disciplines.

 > though this may merely be dependent on my display settings

Yes, it is. What constitues a physical inch on a display device is dependent on a couple of different ratios. You can make it work, but it requires very careful setup--which almost nobody ever does.

 > And what makes up a "beginning" line, anyway?  

The beginning line is the first line of the paragraph. A paragraph is a block of text that ends with a paragraph marker. The rich edit control uses a carriage-return to mark the end of a paragraph.

To do a hanging indent, like you've asked for, you'll need a structure like this:

   PARAFORMAT pf;
   pf.cbSize = sizeof(pf);
   pf.wNumbering = 0;
   pf.wReserved = 0;
   pf.dxStartIndent = 0;
   pf.dxOffset = 1440;
   pf.dxRightIndent = 0;
   pf.wAlignment = PFA_LEFT;
   pf.cTabCount = 0;
   pf.dwMask = PFM_OFFSET | PFM_ALIGNMENT | PFM_RIGHTINDENT | PFM_STARTINDENT;

 > Also, I want everything in the control to come out like this-
 > is this a 'paragraph', or something else?

You'll need to apply the above paragraph formatting to everything in your control.

Do you want me to write a complete application for you as a sample?

..B ekiM
0
 
mikeblasCommented:
> And why does the MFC documentation, which is basically nonexistant,
 > assume we know what defines these "paragraphs", etc?  

As the documentation itself states, you can send feedback to the docs team directly at vcdocs@microsoft.com .

Also, I just noticed that my first posting (for the first-line indented style you didn't want) is incorrect. It's missing a setting for the dxOffset member, which should be -1440.

..B ekiM
0
 
MournbladeAuthor Commented:
No, I'm not kidding.  I was referring to the ridiculousness of the ParaFormat and its documentation in MFC.  If you took that as an insult, it's only your insecurity.  And I asked "why is it ONLY in twips" - which you didn't answer.  I could go on a little bit here, but I don't have the time.  I would have thanked you for your efforts, but your final sentence here earned you the zero.

Thank you for your efforts.

0
 
MournbladeAuthor Commented:
Not to mention that your answer didn't even do what you said it would.   You noticed this.  It was no big deal, but anyhow...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.