From 989b5979a9496c266e59c296463cc7cb2118f23c Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 8 Feb 2011 11:31:56 +0000 Subject: [PATCH] --- PROMS/Volian.Controls.Library/RTBAPI.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PROMS/Volian.Controls.Library/RTBAPI.cs b/PROMS/Volian.Controls.Library/RTBAPI.cs index b43870dd..8a0b73d3 100644 --- a/PROMS/Volian.Controls.Library/RTBAPI.cs +++ b/PROMS/Volian.Controls.Library/RTBAPI.cs @@ -841,6 +841,23 @@ namespace Volian.Controls.Library cft.dwMask |= CharFormatMasks.CFM_BACKCOLOR; SetCharFormat(richTextBox, selection, cft); } + public static void SetSpaceBefore(RichTextBox richTextBox, int spaceBefore) + { + ParaFormatTwo pft = GetParaFormat(richTextBox); + pft.dwMask = 0; + pft.dwMask |= ParaFormatMasks.PFM_SPACEBEFORE; + // get the monitor's resolution in DPI and use it to set the linespacing value for + // the richtextbox. Note that without this, the Arial Unicode font made the appearance of + // almost double linespacing. Using PFS_Exact makes it appear as regular single spacing. + Graphics g = richTextBox.CreateGraphics(); + int dpi = Convert.ToInt32((g.DpiX + g.DpiY) / 2); + g.Dispose(); + // dyLineSpacing is Spacing between lines. the PFS_EXACT sets line spacing as the spacing from one + //line to the next, in twips - thus the 1440. + + pft.dySpaceBefore = spaceBefore * 1440 / dpi; + SetParaFormat(richTextBox, pft); + } public static void SetLineSpacing(RichTextBox richTextBox, ParaSpacing type) { ParaFormatTwo pft = GetParaFormat(richTextBox);