title: How to customize file dialog in wpf
body: <p>In Windows7 I am using  a customized Open File Dialog( WPF application). My Open File dialog is derived from <code>Microsoft.Win32.CommonDialog</code>.
  The dialog have old look, how to change this to new look (windows7 file dialog look(Explorer style)). </p>
  
  <p>Code portion:</p>
  
  <pre><code>private const int OFN_ENABLESIZING = 0x00800000;
  private const int OFN_EXPLORER = 0x00080000;
  private const int OFN_ENABLEHOOK = 0x00000020;       
  protected override bool RunDialog(IntPtr hwndOwner)
  {
      OPENFILENAME_I.WndProc proc = new OPENFILENAME_I.WndProc(this.HookProc);
                      OPENFILENAME_I ofn = new OPENFILENAME_I();
      this._charBuffer = CharBuffer.CreateBuffer(0x2000);
      if (this._fileNames != null)
      {
           this._charBuffer.PutString(this._fileNames[0]);
      }
      ofn.lStructSize = Marshal.SizeOf(typeof(OPENFILENAME_I));
      ofn.hwndOwner = hwndOwner;
      ofn.hInstance = IntPtr.Zero;
      ofn.lpstrFilter = MakeFilterString(this._filter, this.DereferenceLinks);
      ofn.nFilterIndex = this._filterIndex;
      ofn.lpstrFile = this._charBuffer.AllocCoTaskMem();
      ofn.nMaxFile = this._charBuffer.Length;
      ofn.lpstrInitialDir = this._initialDirectory;
      ofn.lpstrTitle = this._title;
      ofn.Flags =  OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK;
      ofn.lpfnHook = proc;
      ofn.FlagsEx = 0x1000000 ;    
      NativeMethods.GetOpenFileName(ofn); // 
   }
  
  [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("comdlg32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  internal static extern bool GetOpenFileName([In, Out] OPENFILENAME_I ofn);    
  </code></pre>