using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace GetLineCount_CS
{
    
    public partial class Form1 : Form
    {

        [DllImport("coredll.dll")]
        static extern int SendMessage(IntPtr hwnd, 
            int msg, int wParam, int lParam);
        
        const int EM_GETLINECOUNT = 0x00BA;


        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else       
                MinimizeBox = true;
            #endif
        }

        private void butGetNumber_Click(object sender, EventArgs e)
        {
            // Узнаем число строк в текстовом поле
            int numberOfLines = SendMessage(textBox1.Handle, EM_GETLINECOUNT, 0, 0);
            sbInfo.Text = "Число строк: " + numberOfLines.ToString();
          }
    }
}