Solved

Trying to indent text in CRichEditCtrl

Posted on 2000-04-22
8
598 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:Mournblade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 2740952

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
 

Author Comment

by:Mournblade
ID: 2741017
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
 

Author Comment

by:Mournblade
ID: 2741517
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:mikeblas
ID: 2741737
> 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
 
LVL 11

Expert Comment

by:mikeblas
ID: 2741743
> 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
 

Author Comment

by:Mournblade
ID: 2742693
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
 

Author Comment

by:Mournblade
ID: 2742694
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
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 2919615
> 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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question