title: C# + Windows CE + Multiline & Align label
body: <p>I need to make a multiline label with vertical and horizontal alignment and I don't know how I can do it !</p>
  
  <p>I have found a way to make any control multiline with this function :</p>
  
  <pre><code>    private const int BS_MULTILINE = 0x00002000;
      private const int BS_CENTER = 0x00000300;
      private const int BS_VCENTER = 0x00000C00;
      private const int GWL_STYLE = -16;
      [DllImport("coredll")]
      private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
      [DllImport("coredll")]
      private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  
      public static void MakeControlMultiline(Control control) {
          IntPtr hwnd = control.Handle;
          int currentStyle = GetWindowLong(hwnd, GWL_STYLE);
          int newStyle = SetWindowLong(hwnd, GWL_STYLE, currentStyle | /*BS_CENTER | BS_VCENTER | */BS_MULTILINE);
      }
  </code></pre>
  
  <p>The "BS_CENTER | BS_VCENTER" is in comment since it doesn't work !</p>
  
  <p>So I try to make a customControl where I realise both alignments, like this : </p>
  
  <pre><code>public partial class ImproveLabel : Control {
      ...
      protected override void OnPaint(PaintEventArgs pe) {
          Graphics g = pe.Graphics;
          // text
          StringFormat drawFormat = new StringFormat();
          drawFormat.Alignment = StringAlignment.Center;
          drawFormat.LineAlignment = StringAlignment.Center;
          g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new Rectangle(0, 0, this.Width, this.Height), drawFormat);
          // Calling the base class OnPaint
          base.OnPaint(pe);
      }
  </code></pre>
  
  <p>The strange thing here is that if I put both alignements to "Center", the multiline doesn't work anymore but if there is only the vertical alignment to "Center" and the horizontal alignment to "near", the multiline works.</p>
  
  <p>I don't understand why it works this way but I need help to figure how I can get the 3 attributes working at the same time !</p>