Solved

Trying to indent text in CRichEditCtrl

Posted on 2000-04-22
8
576 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
How to know only "File created" with EventLog 3 32
if loop in java 3 130
maven archtype selection in eclipse 1 53
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now