TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mastersmoke
NA
1
0
DragDrop+Transparent Panel == BLINKing
Apr 30 2005 4:04 PM
here is full code: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace wg2h { /// /// Summary description for WYSIWYG. /// public class WG : System.Windows.Forms.Form { private Panel DraggingPanel; private int offX; private int offY; private Point loc=new Point(1000,1000); public static Form wf=new WG(); private wg2h.DivPanel p0; private System.Windows.Forms.Label label1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public WG() { ResizeRedraw = true; SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.p0 = new wg2h.DivPanel(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // p0 // this.p0.AllowDrop = true; this.p0.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.p0.Dock = System.Windows.Forms.DockStyle.Fill; this.p0.Location = new System.Drawing.Point(0, 0); this.p0.Name = "p0"; this.p0.Size = new System.Drawing.Size(610, 475); this.p0.TabIndex = 0; this.p0.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter); this.p0.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver); // // label1 // this.label1.Location = new System.Drawing.Point(0, 0); this.label1.Name = "label1"; this.label1.TabIndex = 0; // // WG // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.ControlLightLight; this.ClientSize = new System.Drawing.Size(610, 475); this.Controls.Add(this.p0); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "WG"; this.Text = "WYSIWYG"; this.Load += new System.EventHandler(this.WG_Load); this.ResumeLayout(false); } #endregion [STAThread] public static void Main(){Application.Run(wf);} private void OnPanelMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { this.offX=e.X; this.offY=e.Y; Panel tsender=(Panel)sender; this.DraggingPanel=tsender; this.DoDragDrop(tsender,DragDropEffects.Move); } private void OnPanelMouseLeave(object sender, System.EventArgs e) { } private void OnPanelDragEnter(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect=DragDropEffects.Move; } private void OnPanelDragOver(object sender, System.Windows.Forms.DragEventArgs e) { DivPanel d_panel = sender as DivPanel; Point cu=Cursor.Position; cu=DraggingPanel.Parent.PointToClient(cu); cu.Offset(-this.offX,-this.offY); d_panel.Parent.Invalidate(new Rectangle(d_panel.Parent.PointToClient(DraggingPanel.Parent.PointToScreen(DraggingPanel.Location)),DraggingPanel.Size),true); this.DraggingPanel.Location=new Point(cu.X,cu.Y); } private void WG_Load(object sender, System.EventArgs e) { Control px=new DivPanel(); px.Location=new Point(0,0); px.Size=new Size(100, 200); px.AllowDrop=false; this.p0.Controls.Add(px); px.BringToFront(); px.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter); px.MouseHover += new System.EventHandler(this.OnPanelMouseLeave); px.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver); px.MouseLeave += new System.EventHandler(this.OnPanelMouseLeave); px.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnPanelMouseDown); px=new DivPanel(); px.Location=new Point(0,0); px.Size=new Size(100, 200); px.AllowDrop=false; this.p0.Controls.Add(px); px.BringToFront(); px.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnPanelDragEnter); px.MouseHover += new System.EventHandler(this.OnPanelMouseLeave); px.DragOver += new System.Windows.Forms.DragEventHandler(this.OnPanelDragOver); px.MouseLeave += new System.EventHandler(this.OnPanelMouseLeave); px.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnPanelMouseDown); } } public class DivPanel:System.Windows.Forms.Panel { public DivPanel() { //??? ???????????? ????????? ????? SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.DoubleBuffer,true); SetStyle(ControlStyles.UserPaint,true); this.BorderStyle=BorderStyle.FixedSingle; } //??????? ? ????, ??? ??? ????????, WS_EX_TRANSPARENT ??? ????????????: protected override CreateParams CreateParams { get { const int WS_EX_TRANSPARENT = 0x00000020; CreateParams createParams = base.CreateParams; createParams.ExStyle |= WS_EX_TRANSPARENT; return createParams; } } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { // TODO: Add DivPanel.OnPaint implementation //?????? ?????? base.OnPaint (e); this.BorderStyle=BorderStyle.FixedSingle; if(this.Parent is DivPanel)e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Red)),0, 0, Width, Height); } //???????? ??????? ?????: protected override void OnBackColorChanged(EventArgs e) { // TODO: Add DivPanel.OnBackColorChanged implementation //base.OnBackColorChanged (e); } } } DivPanels blinking ,as you see... and nobody can tell me what's the ...
Reply
Answers (
0
)
Monitoring data into a winform
MDI application with fixed panes?