日期:2014-05-17 浏览次数:21172 次
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
RichTextBox richTextBox = null;
int sf = 0;
int pnlHight = 0;
void richTextBox_Resize(object sender, EventArgs e)
{
int EM_GETLINECOUNT = 0x00BA;//获取总行数的消息号
int lc = SendMessage(richTextBox.Handle, EM_GETLINECOUNT, IntPtr.Zero, "");
sf = richTextBox.Font.Height * (lc + 1) + richTextBox.Location.Y;
richTextBox.Height = sf-30;
richTextBox.Size = new System.Drawing.Size(912, richTextBox.Height);
}
private void createControls(string Message, string SendName, string SendTime, int replyId, int i)
{
Panel pnl = new Panel();
pnl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
richTextBox = new RichTextBox();
richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
richTextBox.Name = "richTextBox" + "_" + i;
richTextBox.TabIndex = 7;
richTextBox.Text = Message;