This is a migrated thread and some comments may be shown as answers.

Form title is blinking

17 Answers 123 Views
TitleBar
This is a migrated thread and some comments may be shown as answers.
Andrew Shyliuk
Top achievements
Rank 1
Andrew Shyliuk asked on 01 Feb 2011, 10:06 AM
Hello, all

I have a RadForm with RadTreeView on it. When user change selected node on tree view I update form header (set node text into header). The header text is blinking when I do it.

Here is the code

private void radTreeView1_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
        {
            RadTreeNode node = this.radTreeView1.SelectedNode;

            if (node == null)
            {
                return;
            }

            Text = "Repository Explorer - " + node.Text;

            //Do something operations
            System.Threading.Thread.Sleep(1000);
        }

Can you help me?

Andrew Shyliuk

17 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 01:24 PM
Hello Andrew,

I've tried this in a small, basic project but was not able to reproduce your issue.
I have used the code that you have provided below.

Here is my full example

Designer File
namespace RadTreeView_C
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components;
  
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
  
        #region Windows Form Designer generated code
  
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Telerik.WinControls.UI.RadTreeNode radTreeNode1 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode2 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode3 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode4 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode5 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode6 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode7 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode8 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode9 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode10 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode11 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode12 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode13 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode14 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode15 = new Telerik.WinControls.UI.RadTreeNode();
            this.radTreeView1 = new Telerik.WinControls.UI.RadTreeView();
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).BeginInit();
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(606, 360);
            // 
            // radTreeView1
            // 
            this.radTreeView1.BackColor = System.Drawing.SystemColors.Window;
            this.radTreeView1.Cursor = System.Windows.Forms.Cursors.Default;
            this.radTreeView1.Font = new System.Drawing.Font("Segoe UI", 8.25F);
            this.radTreeView1.ForeColor = System.Drawing.Color.Black;
            this.radTreeView1.Location = new System.Drawing.Point(12, 12);
            this.radTreeView1.Name = "radTreeView1";
            radTreeNode1.Expanded = true;
            radTreeNode2.Text = "Node14";
            radTreeNode3.Text = "Node15";
            radTreeNode1.Nodes.Add(radTreeNode2);
            radTreeNode1.Nodes.Add(radTreeNode3);
            radTreeNode1.Text = "Node1";
            radTreeNode4.Expanded = true;
            radTreeNode5.Text = "Node6";
            radTreeNode6.Text = "Node7";
            radTreeNode4.Nodes.Add(radTreeNode5);
            radTreeNode4.Nodes.Add(radTreeNode6);
            radTreeNode4.Text = "Node2";
            radTreeNode7.Expanded = true;
            radTreeNode8.Text = "Node8";
            radTreeNode9.Text = "Node9";
            radTreeNode7.Nodes.Add(radTreeNode8);
            radTreeNode7.Nodes.Add(radTreeNode9);
            radTreeNode7.Text = "Node3";
            radTreeNode10.Expanded = true;
            radTreeNode11.Text = "Node10";
            radTreeNode12.Text = "Node11";
            radTreeNode10.Nodes.Add(radTreeNode11);
            radTreeNode10.Nodes.Add(radTreeNode12);
            radTreeNode10.Text = "Node4";
            radTreeNode13.Expanded = true;
            radTreeNode14.Text = "Node12";
            radTreeNode15.Text = "Node13";
            radTreeNode13.Nodes.Add(radTreeNode14);
            radTreeNode13.Nodes.Add(radTreeNode15);
            radTreeNode13.Text = "Node5";
            this.radTreeView1.Nodes.Add(radTreeNode1);
            this.radTreeView1.Nodes.Add(radTreeNode4);
            this.radTreeView1.Nodes.Add(radTreeNode7);
            this.radTreeView1.Nodes.Add(radTreeNode10);
            this.radTreeView1.Nodes.Add(radTreeNode13);
            this.radTreeView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            // 
            // 
            // 
            this.radTreeView1.RootElement.ForeColor = System.Drawing.Color.Black;
            this.radTreeView1.Size = new System.Drawing.Size(582, 329);
            this.radTreeView1.TabIndex = 0;
            this.radTreeView1.Text = "radTreeView1";
            this.radTreeView1.SelectedNodeChanged += new Telerik.WinControls.UI.RadTreeView.RadTreeViewEventHandler(this.radTreeView1_SelectedNodeChanged);
            this.Controls.Add(this.radTreeView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).EndInit();
            this.ResumeLayout(false);
  
        }
  
        #endregion
  
        private Telerik.WinControls.UI.RadTreeView radTreeView1;
  
    }
}

Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using System.Collections.ObjectModel;
  
namespace RadTreeView_C
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
  
        private void Form1_Load(object sender, EventArgs e)
        {
  
        }
  
        private void radTreeView1_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
        {
            RadTreeNode node = this.radTreeView1.SelectedNode;
  
            if (node == null)
            {
                return;
            }
  
            Text = "Repository Explorer - " + node.Text;
  
            //Do something operations
            System.Threading.Thread.Sleep(1000);
  
        }
  
  
  
  
  
  
    }
}

Can I ask what version of the controls you are using (for reference I am using the latest Q3 2010 SP1 release) as there was some flickering issues in very old versions of the controls but this has all now been resolved.

Thanks
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 02:04 PM
Hello, Richard

I'm using last version (Q3 2010).
Here is source code of my sample form

public partial class Form1 : RadForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void radTreeView1_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
        {
            RadTreeNode node = this.radTreeView1.SelectedNode;

            if (node == null)
            {
                return;
            }

            Text = "Repository Explorer - " + node.Text;

            //Do something operations
            System.Threading.Thread.Sleep(100);
        }
    }

partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            Telerik.WinControls.UI.RadTreeNode radTreeNode1 = new Telerik.WinControls.UI.RadTreeNode();
            Telerik.WinControls.UI.RadTreeNode radTreeNode2 = new Telerik.WinControls.UI.RadTreeNode();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.windows7Theme1 = new Telerik.WinControls.Themes.Windows7Theme();
            this.radTreeView1 = new Telerik.WinControls.UI.RadTreeView();
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // radTreeView1
            //
            this.radTreeView1.BackColor = System.Drawing.SystemColors.Window;
            this.radTreeView1.Cursor = System.Windows.Forms.Cursors.Default;
            this.radTreeView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.radTreeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.radTreeView1.ForeColor = System.Drawing.Color.Black;
            this.radTreeView1.Location = new System.Drawing.Point(0, 0);
            this.radTreeView1.Name = "radTreeView1";
            radTreeNode1.Text = "Test Node 1";
            radTreeNode2.Text = "Test Node Test Node 2";
            this.radTreeView1.Nodes.Add(radTreeNode1);
            this.radTreeView1.Nodes.Add(radTreeNode2);
            this.radTreeView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            //
            //
            //
            this.radTreeView1.RootElement.ForeColor = System.Drawing.Color.Black;
            this.radTreeView1.Size = new System.Drawing.Size(587, 501);
            this.radTreeView1.TabIndex = 0;
            this.radTreeView1.Text = "radTreeView1";
            this.radTreeView1.SelectedNodeChanged += new Telerik.WinControls.UI.RadTreeView.RadTreeViewEventHandler(this.radTreeView1_SelectedNodeChanged);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(587, 501);
            this.Controls.Add(this.radTreeView1);
            this.MinimizeBox = false;
            this.Name = "Form1";
            //
            //
            //
            this.RootElement.ApplyShapeToControl = true;
            this.Text = "Form1";
            this.ThemeName = "Windows7";
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private Telerik.WinControls.Themes.Windows7Theme windows7Theme1;
        private Telerik.WinControls.UI.RadTreeView radTreeView1;
    }

For reproducing this bug you have run application and change node selection several times. Form header changing twice when you change selection from first node to second in my sample. New header text is outputed and then the width of the text is changed.

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 02:23 PM
Hi Andrew,

Due to the sleep you have in there to simulate your longer running code below I would kind of expect this as all the messages have not been pumped through.
You could just add a DoEvents to push through the messages which will get over this.

Text = "Repository Explorer - " + node.Text;
Application.DoEvents();

Let me know if that helps
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 02:51 PM
Hello, Richard

This is doesn't change situation. With Application.DoEvents() form header blinking faster in my application. So it doesn't solve the core of the problem.

Do you have another ways to solve it?

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 02:56 PM
Hi Andrew,

Sorry to hear that didn't help. Does this still blink if you remove the sleep (or long running operation in your real code). If not, then I would suggest looking at moving out the longer running code into a background worker / separate thread to ensure the UI stays responsive.
let me know if you need more information
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 03:28 PM
Hello, Richard

If I remove sleep from sample blinking isn't noticeable but it exists. I cannot remove all other operations from my real code. About separated thread - operation executing in 0,5 sec and it isn't long.
Have you seen something like that in standard WinForms controls? This is a bug of Telerik RadForm and problem not in the sleep or longer operations.

Could you provide more universal workaround for this bug (which will work with longer operations or without it)?

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 03:37 PM
Hello Andrew,

Please could you try this, which I've used in the past and have found helpful in this type of situation

Add a new class...
using System.Runtime.InteropServices;
  
    internal sealed class NativeMethods
    {
        private NativeMethods()
        {
        }
  
        [DllImport("User32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        static internal extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
        [DllImport("User32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        static internal extern int LockWindowUpdate(int hWnd);
    }


And then in your code...
NativeMethods.LockWindowUpdate(this.Handle.ToInt32());
Text = "Repository Explorer - " + node.Text;
System.Threading.Thread.Sleep(1000);
NativeMethods.LockWindowUpdate(0);

Let me know how you get on wth this
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 03:56 PM
Hello, Richard

Unfortunately this doesn't help. In my real application I have not only operations but also other events. Some of them fires after form text changing. I have no any posibility to set NativeMethods.LockWindowUpdate(this.Handle.ToInt32()) before all my events and operations and NativeMethods.LockWindowUpdate(0) after them.

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 03:58 PM
Hello,

If you can post a full sample application that replicates your real application as closely as possible, I'll do my best to help.
Regards,
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 04:29 PM
Hello, Richard

I cannot provide full sample because form with this bug has so difficult logic and using many other classes and objects.
I post the sample and you understand the problem...

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 04:37 PM
Hello, 

I look forward to seeing your sample. Please use the code formatting block above to format the code.
Thanks
Richard
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 01 Feb 2011, 04:48 PM
Hello, Richard

I cannot provide full sample because form with this bug has so difficult logic and using many other classes and objects.

Andrew Shyliuk
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 04:51 PM
Hello Andrew,

I'm not sure what else I can suggest. I have offered 3 different suggestions to the issue. My last suggestion would be to open a support ticket and post your full application to Telerik.
My apologies that I was unable to find a suitable solution for you this time
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 01 Feb 2011, 10:19 PM
Hello Andrew,

I've now had the chance to look through the Telerik Public Issue Tracking System and I see that this is already a reported issue. You can see, track and vote for the issue to be fixed at this link

Hope that helps
Richard
0
Stefan
Telerik team
answered on 02 Feb 2011, 04:15 PM
Hello guys

I noticed the described behavior. When the text is changed, it moves a little up and down. However, currently I can not provide you with workaround for this. I have added this issue into our PITS (Public Issue Tracking System) where you can subscribe for its status updates.

A possible solution for this is to set the AllowTheming of RadForm to false. As the name implies, this will disable the theming functionality of RadForm, avoiding the reported behavior.

@Andrew: I have updated your Telerik points for this report.
 
Greetings,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
Richard Slade
Top achievements
Rank 2
answered on 02 Feb 2011, 04:20 PM
Hi,

I know that my LockWindowsUpdate solution could not be used to resolve this particular case, but if it helps at all, I did notice that on a test project based on the exmaples posted here, this did workaround the problem correctly.
Hope that helps
Richard
0
Stefan
Telerik team
answered on 07 Feb 2011, 01:21 PM
Hello guys,

On my end Richard's suggestion works around this. Feel free to try it as well.

Regards,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
TitleBar
Asked by
Andrew Shyliuk
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Andrew Shyliuk
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or