SyntaxEditor Doesn't show at first loading

SyntaxEditor for Windows Forms Forum

Posted 9 years ago by Yeochang Yoon
Version: 14.1.0323
Avatar

Hello.

I'm just evaluation user and testing to apply SyntaxEditor to our project.

but, SyntaxEditor doesen't show at first loading.

We applied following code to resolve flickering on WinForm 

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;   // WS_EX_COMPOSITED

        return cp;
    }
}

 if I remove above code, SyntaxEditor works well.

However, We can't remove it.

How can I solve this problem?

 

Thanks.

Comments (4)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Perhaps try calling the editor.Invalidate method after the Form loads to tell it to render again?


Actipro Software Support

Posted 9 years ago by Yeochang Yoon
Avatar

Following is sample problem. I just override System.Windows.Forms.CreateParams property.

editor.Invalidate() doesn't work well as shown below. However, SyntaxEditor work well after Form resize(maximize/minimize too).

 

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

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x02000000;   // WS_EX_COMPOSITED

                return cp;
            }
        }

        private void Form1_Shown(object sender, EventArgs e)
        {
            this.syntaxEditor1.Invalidate();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.syntaxEditor1.Invalidate();
        }

        private void Form1_Activated(object sender, EventArgs e)
        {
            this.syntaxEditor1.Invalidate();
        }
    }
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We've been playing with this for a while and are not sure what can be done to fix it.  We use some GDI-based double-buffering for the control.  That seems to be related here when you set WS_EX_COMPOSITED.  When you call SyntaxEditor.ResetDoubleBufferCanvas(false), it seems like that should reset everything and allow it to work again (because it re-creates the double-buffer from scratch) but it doesn't.  Resizing the editor control calls that exact method.  And as you saw, resizing the control gets it drawing again.  Thus it seems like there might be something lower-level than our code that is preventing this from working until a control resize occurs.

I'm not sure what to suggest other than possibly delaying the creation of the control. Does that help if you add it later on instead of as the Form is created?  Or do you still see the same problem?

Or you could manually resize the control and resize it back to try and get it painting again.


Actipro Software Support

Answer - Posted 9 years ago by Yeochang Yoon
Avatar

I solved this problem. To solve that, I must create child class inherited from SyntaxEditor class and override CreateParams.

following is my test code.

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

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x02000000;   // WS_EX_COMPOSITED

            return cp;
        }
    }
}

class MySyntaxEditor : SyntaxEditor
{
    public MySyntaxEditor()
    {
    }

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ClassStyle |= 0x0040; // CS_CLASSDC

            return cp;
        }
    }
}

 

and below is references.

               - Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 2000: This style is not supported.

  • CS_CLASSDC decscription

               - Allocates one device context to be shared by all windows in the class. Because window classes are process specific, it is possible for multiple threads of an application to create a window of the same class. It is also possible for the threads to attempt to use the device context simultaneously. When this happens, the system allows only one thread to successfully finish its drawing operation.

 

thanks.

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.