title: C# "SendMessage" code error
body: <p>I needed to convert the following code from VB.NET to C#:</p>
  
  <pre><code>Public Class Form1
      Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
      Enum ProgressBarColor
          Green = &amp;H1
          Red = &amp;H2
          Yellow = &amp;H3
      End Enum
      Private Shared Sub ChangeProgBarColor(ByVal ProgressBar_Name As Windows.Forms.ProgressBar, ByVal ProgressBar_Color As ProgressBarColor)
          SendMessage(ProgressBar_Name.Handle, &amp;H410, ProgressBar_Color, 0)
      End Sub
  End Class
  </code></pre>
  
  <p>VB.NET code source: <a href="http://www.ultimateprogrammingtutorials.info/2012/12/changing-progress-bar-colors-on-vbnet.html" rel="nofollow">Ultimate Programming Tutorials</a></p>
  
  <p>I used <a href="http://www.developerfusion.com/tools/convert/vb-to-csharp/" rel="nofollow">developerFusion's online code converter</a> to convert the code, and this is the C# code that it produced:</p>
  
  <pre><code>using Microsoft.VisualBasic;
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Data;
  using System.Diagnostics;
  using System.Runtime.InteropServices;
  public class Form1
  {
      [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
      public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
      public enum ProgressBarColor
      {
          Green = 0x1,
          Red = 0x2,
          Yellow = 0x3
      }
      private static void ChangeProgBarColor(System.Windows.Forms.ProgressBar ProgressBar_Name, ProgressBarColor ProgressBar_Color)
      {
          SendMessage(ProgressBar_Name.Handle, 0x410, ProgressBar_Color, 0);
      }
  }
  </code></pre>
  
  <p>EDIT: Removed "ExactSpelling = true" from the DllImport, as it causes an error.</p>
  
  <p>However, that auto-converted code fails to compile due to the following line:</p>
  
  <pre><code>SendMessage(ProgressBar_Name.Handle, 0x410, ProgressBar_Color, 0);
  </code></pre>
  
  <p>The error that is displayed by the C# compiler is:</p>
  
  <blockquote>
    <p>Error: The best overloaded method for 'Jyrka98_Modpack_CS.Form1.SendMessage(System.IntPtr, int, int, int)' has some invalid arguments.</p>
  </blockquote>
  
  <p>It also shows this error:</p>
  
  <blockquote>
    <p>Argument 3: cannot convert from 'Jyrka98_Modpack_CS.Form1.ProgressBarColor' to 'int'</p>
  </blockquote>
  
  <p>I don't understand what it means by those error messages.  How can I fix that line in C#?</p>