ListBox、ComboBoxをWindows Mobile 6.5ライクな表示にする

Form1のコンストラクタで、各種EnableVisualStyleメソッドを使っている事を前提としています。
ListBoxには、LBS_EX_THEMEという別の定義があるけど、値が同じ(0×0004)なのでまとめています

C#

  [DllImport("coredll")]
  private static extern int GetWindowLong(IntPtr hwnd, int nIndex);
 
  [DllImport("coredll")]      
  private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
 
  private const int GWL_STYLE = -16;
  private const int GWL_EXSTYLE = -20;
 
  // ListBoxには、LBS_EX_THEMEという別の定義があるけど、
  // 値が同じ(0x0004)なのでまとめています
  private const int CBS_EX_THEME = 0x0004;
 
  public void EnableVisualStyle(ListControl listBox)
  {
      int exstyle = GetWindowLong(listBox.Handle, GWL_EXSTYLE);
      SetWindowLong(listBox.Handle, GWL_EXSTYLE, exstyle | CBS_EX_THEME);
  }

適用前

適用後/h3>