protected override bool RunDialog(IntPtr hwndOwner) { bool flag; System.Windows.Forms.NativeMethods.WndProc proc = new System.Windows.Forms.NativeMethods.WndProc(this.HookProc); System.Windows.Forms.NativeMethods.CHOOSECOLOR cc = new System.Windows.Forms.NativeMethods.CHOOSECOLOR(); IntPtr destination = Marshal.AllocCoTaskMem(0x40); try { Marshal.Copy(this.customColors, 0, destination, 0x10); cc.hwndOwner = hwndOwner; cc.hInstance = this.Instance; cc.rgbResult = ColorTranslator.ToWin32(this.color); cc.lpCustColors = destination; int num = this.Options | 0x11; if (!this.AllowFullOpen) { num &= -3; } cc.Flags = num; cc.lpfnHook = proc; if (!System.Windows.Forms.SafeNativeMethods.ChooseColor(cc)) { return(false); } if (cc.rgbResult != ColorTranslator.ToWin32(this.color)) { this.color = ColorTranslator.FromOle(cc.rgbResult); } Marshal.Copy(destination, this.customColors, 0, 0x10); flag = true; } finally { Marshal.FreeCoTaskMem(destination); } return(flag); }
protected override bool RunDialog(IntPtr hwndOwner) { bool flag; System.Windows.Forms.NativeMethods.WndProc proc = new System.Windows.Forms.NativeMethods.WndProc(this.HookProc); System.Windows.Forms.NativeMethods.CHOOSECOLOR cc = new System.Windows.Forms.NativeMethods.CHOOSECOLOR(); IntPtr destination = Marshal.AllocCoTaskMem(0x40); try { Marshal.Copy(this.customColors, 0, destination, 0x10); cc.hwndOwner = hwndOwner; cc.hInstance = this.Instance; cc.rgbResult = ColorTranslator.ToWin32(this.color); cc.lpCustColors = destination; int num = this.Options | 0x11; if (!this.AllowFullOpen) { num &= -3; } cc.Flags = num; cc.lpfnHook = proc; if (!System.Windows.Forms.SafeNativeMethods.ChooseColor(cc)) { return false; } if (cc.rgbResult != ColorTranslator.ToWin32(this.color)) { this.color = ColorTranslator.FromOle(cc.rgbResult); } Marshal.Copy(destination, this.customColors, 0, 0x10); flag = true; } finally { Marshal.FreeCoTaskMem(destination); } return flag; }
public static extern bool ChooseColor([In, Out] System.Windows.Forms.NativeMethods.CHOOSECOLOR cc);