Solved

Trying to indent text in CRichEditCtrl

Posted on 2000-04-22
8
577 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 137
sum28 challenge 31 112
Path of Workbook 3 78
Making an alias 7 95
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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