下面这个是我弄的c#程序。有bug,高手们可以帮我吗?
public class Form1 : Form
{
public const int WM_USER = 0x0400;
public const int EM_GETPARAFORMAT = WM_USER + 61;
public const int EM_SETPARAFORMAT = WM_USER + 71;
public const long MAX_TAB_STOPS = 32;
public const long PFM_LINESPACING = 256;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.ListBox listBox1;
public struct PARAFORMAT2
{
public long cbSize;
public long dwMask;
public int wNumbering;
public int wEffects;
public long dxStartIndent;
public long dxRightIndent;
public long dxOffset;
public int wAlignment;
public int cTabCount;
public long rgxTabs(MAX_TAB_STOPS-1); //一直提示这行有问题,rgxTabs()在vb 中是指什么呀??
public long dySpaceBefore;
public long dySpaceAfter;
public long dyLineSpacing;
public int sStyle;
public byte bLineSpacingRule;
public byte bOutlineLevel;
public int wShadingWeight;
public int wShadingStyle;
public int wNumberingStart;
public int wNumberingStyle;
public int wNumberingTab;
public int wBorderSpace;
public int wBorderWidth;
public int wBorders;
};
[DllImport("User32.dll")]
public static extern long SendMessage(IntPtr hWnd,uint Msg,uint wParam,PARAFORMAT2 IParam);
private void button1_Click(object sender, System.EventArgs e)
{
PARAFORMAT2 pf2 = new PARAFORMAT2();
Random r = new Random();
long retval;
this.richTextBox1.SelectionStart = this.richTextBox1.TextLength;
string str;
str = pf2.ToString();
pf2.cbSize = str.Length; //我这样子处理LenB()函数 可以吗?
pf2.bLineSpacingRule = 3;
pf2.dyLineSpacing= (long)r.Next(500,3000)+500;
pf2.dwMask = PFM_LINESPACING;
retval = SendMessage(this.richTextBox1.Handle,EM_SETPARAFORMAT,0,pf2);
}