First look at the picture. Implementation function: 1) Drop the color selection dialog. 2) The background window does not lose focus .3) Click more calls Windows Standard color pick dialog Select color. Development background: See some articles online These functions can be basically implemented, but most of the way to transfer the focus to the background window after the front window, or put the front window Show by closing the front desk window, or simply uses a confection (with ordinary Controls If the range exceeds the range of the background window, the Windows built-in menu or drop-down box does not make it, the front desk triggers the event that lost the focus event, and will not be blocked, holding a programmer Belief, in the 9CBS Forum, have a number of posts (400 points), and the continuous effort has finally been. I would like to thank the colleagues of the 9CBS, there is no such world (Ha) without you. Not much nonsense, enter the topic. Program implementation code analysis: 1) The base Windows API class used by the article. Using system; using system.runtime.interopservices; ///
001C
; // public const int WM_ERASEBKGND = 0x0014; [DllImport ( "user32.dll", CharSet = CharSet.Auto)] public static extern long SetWindowLong (IntPtr hWnd, int nIndex, long dwNewLong); [DllImport ( "user32.dll" , CharSet = CharSet.Auto)] public static extern long GetWindowLong (IntPtr hWnd, int nIndex); //[DllImport("user32.dll ", CharSet = CharSet.Auto)] // public static extern int SendMessage (IntPtr hWnd, int msg, int wParam, int lParam); //[DllImport("user32.dll ", CharSet = CharSet.Auto)] // public static extern int GetWindowRect (IntPtr hWnd, ref System.Drawing.Rectangle lpRect); private SystemShell () {// // TODO: Add constructor logic //}} This article pops up the base class (code processing flow in accordance with the label navigation) ///
/// summary> private void initializecomponent () {/// noactform // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (292, 273 ); // (1) Do not title icon and text attribute, this.ControlBox = false; this.formo.formorderstyle = system.windows.forms.formorderstyle.FixedDialog; this.name = "noactform"; this.startPosition = system.windows. Forms.FormStartPosition.Manual; this.Load = new System.EventHandler (this.NoActForm_Load);} #endregion private void NoActForm_Load (object sender, System.EventArgs e) {// if not in design mode if (this.DesignMode! ) {// No Owner is not possible (this.owner == null) {throw new applicationException ("not owner form");} this.showintaskbar = false; // (2) The key here Any window should be added WS_CHILDWINDOW style can be long style = systemsh ell.GetWindowLong (this.Handle, SystemShell.GWL_STYLE); Style | = SystemShell.WS_CHILDWINDOW; SystemShell.SetWindowLong (this.Handle, SystemShell.GWL_STYLE, Style);}} ///
Screen.primaryScreen.Workingarea; IF (this.right> ScreenRect.width || this.bottom> ScreenRect.Height) {this.left = Rect.width; this.top = Rect.Top - This.height;} this.show ();} ///
/// summary> private system.componentmodel.container component = null; public colorselectform (): base () {// // Windows Form Designer Support for // InitializeComponent (); this.mousedown = New MouseEventHandler (ColorSelectForm_MouseDown); this.MouseMove = new MouseEventHandler (ColorSelectForm_MouseMove); // // TODO: Add any constructor code after InitializeComponent call //} ///
/// summary> private void InitializeComponent () {System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (ColorSelectForm)); this.pictureBox1 = new System.Windows.Forms.PictureBox (); this. label1 = new System.Windows.Forms.Label (); this.colorDialog1 = new System.Windows.Forms.ColorDialog (); this.SuspendLayout (); // // pictureBox1 // this.pictureBox1.Cursor = System.Windows .Forms.cursors.cross; this.picturebox1.dock = system.windows.Forms.dockStyle.top; // (3) Place the PictureBox1.Image This.PictureBox1.image = ((System.drawing.Image ("PictureBox1.image"))))); this.picturebox1.location = new system.drawing.point (0, 0); this.picturebox1.name = "picturebox1"; this.picturebox1.size = new System.drawing.size (194, 289); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // // label1 // this.label1.BackColor = System.Drawing.SystemColors.Control; this.label1.BorderStyle = System.Windows.Forms.BorderStyle .Fixed3d; this.label1.dock = system.windows.forms.dockstyle.fill; this.label1.location = new system.drawing.point (0, 289); this.label1.name = "label1"; this.Label1 .Size = new system.drawing.size (194, 25); this.label1.tabindex = 1; this.label1.text = "More ..."
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // ColorSelectForm // this.AutoScale = false; this.AutoScaleBaseSize = new System.Drawing.Size (6, 14); this.ClientSize = new System. Drawing.size (194, 314); this.controlbox = false; this.controls.add (this.label1); this.Controls.add (this.PictureBox1); this.cursor = system.windows.Forms.cursors.cross This.formBorderstyle = system.windows.Forms.FormBorderstyle.FixedDialog; this.name = "colorselectform"; this.text = ""; this.ResumeLayout (false);} #ENDREGION ///
this.right || pt.x