Drstein99
Junior Contributor
Any1 know how 2 increase the space between lines in a rich text box?
// PARAFORMAT 2.0 masks and effects
#define PFM_SPACEBEFORE 0x00000040
#define PFM_SPACEAFTER 0x00000080
#define PFM_LINESPACING 0x00000100
[StructLayout( LayoutKind.Sequential )]
private struct PARAFORMAT
{
public int cbSize;
public uint dwMask;
public short wNumbering;
public short wReserved;
public int dxStartIndent;
public int dxRightIndent;
public int dxOffset;
public short wAlignment;
public short cTabCount;
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )]
public int[] rgxTabs;
// PARAFORMAT2 from here onwards
public int dySpaceBefore;
public int dySpaceAfter;
public int dyLineSpacing;
public short sStyle;
public byte bLineSpacingRule;
public byte bOutlineLevel;
public short wShadingWeight;
public short wShadingStyle;
public short wNumberingStart;
public short wNumberingStyle;
public short wNumberingTab;
public short wBorderSpace;
public short wBorderWidth;
public short wBorders;
}
[DllImport( "user32", CharSet = CharSet.Auto )]
private static extern IntPtr SendMessage( HandleRef hWnd, int msg,
int wParam, ref PARAFORMAT lParam );
PARAFORMAT fmt = new PARAFORMAT();
fmt.cbSize = Marshal.SizeOf( fmt );
fmt.dwMask = PFM_LINESPACING; // Or whatever
fmt.dyLineSpacing = 2; // Or whatever
// This assumes you will be calling from a class derived from RichTextBox
SendMessage( new HandleRef( this, Handle ), EM_SETPARAFORMAT,
SCF_SELECTION, ref fmt );
const int SCF_SELECTION = 1;
const int EM_SETPARAFORMAT = 1095;