Code Monkey home page Code Monkey logo

Comments (11)

elachlan avatar elachlan commented on September 27, 2024 2

Is it something that can be tested with MFC? That would isolate it, wouldn't it?

from winforms.

SteffenSchwaiger avatar SteffenSchwaiger commented on September 27, 2024 1

@Nora-Zhou01 Interesting! I was not able to reproduce it with .NET Framework 4.5.2 (our current target framework version), but did not try it with .NET Framework 4.8 tho.

It looks like the bug was introduced between .NET Framework 4.5.2 and 4.8.

image

Also I was able to reproduce the bug with an last letter of "a" and a initial width of 292.

image

from winforms.

John-Qiao avatar John-Qiao commented on September 27, 2024 1

@merriemcgaw @elachlan @SteffenSchwaiger we can add below quirk in App.config file to disable richedit30.dll for RichTextBox control when project target to .NET Framework 4.8 or 4.8.1.

	<runtime>
		<AppContextSwitchOverrides value="Switch.System.Windows.Forms.DoNotLoadLatestRichEditControl=true"/>
	</runtime>

Framework

In .NET Project, we can create a new RichTextBox2 class to use the richedit20.dll version. Like below code snippet:

    public class RichTextBox2 : RichTextBox
    {
        protected override CreateParams CreateParams
        {
            get
            {
                if (moduleHandle == IntPtr.Zero)
                {
                    moduleHandle = LoadLibrary("Riched20.dll");
                    if ((long)moduleHandle < 0x20) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not load Riched20.dll");
                }
                var cp = base.CreateParams;
                cp.ClassName = "RichEdit20W";
                return cp;
            }
        }
        private static IntPtr moduleHandle;

        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr LoadLibrary(string lpFileName);
    }

Core

from winforms.

elachlan avatar elachlan commented on September 27, 2024

Excellent bug report! Thank your for the image diff.

@Olina-Zhang can your team please test this?

from winforms.

Nora-Zhou01 avatar Nora-Zhou01 commented on September 27, 2024

This issue is reproduced in both .NET framework4.8.1 projects and .NET Core projects, if there is a rendering, it will disappear after adjusting the size of the form.the results are as follows:
image
Trying to change the last character "r" to other characters does not reproduce this issue.
The issue is not reproduced in the TextBox control. After clicking the resize button, the character line does not change and no rendering occurs,the results are as follows:
image

from winforms.

merriemcgaw avatar merriemcgaw commented on September 27, 2024

We updated the version of riched20.dll that we wrapped sometime around 4.6 if memory serves. @Tanya-Solyanik do you recall? I wouldn't be surprised if this is more of a Windows/Richedit issue than something WinForms is able to control directly.

from winforms.

merriemcgaw avatar merriemcgaw commented on September 27, 2024

@Olina-Zhang can your team go ahead and test this in MFC?
@KlausLoeffelmann - you said you were touching the RichTextBox potentially so keep this in mind when you do.

from winforms.

elachlan avatar elachlan commented on September 27, 2024

@John-Qiao can you please test MFC to verify it is indeed a newer richedit version issue?

from winforms.

John-Qiao avatar John-Qiao commented on September 27, 2024

@elachlan I'm not familiar with MFC project, I will try to create a MFC project and test it, but I'm not sure if it will work.

from winforms.

elachlan avatar elachlan commented on September 27, 2024

Maybe @Olina-Zhang can help?

from winforms.

merriemcgaw avatar merriemcgaw commented on September 27, 2024

@SteffenSchwaiger this bug is about which version of the Rich Text Box control is loaded at runtime by WinForms. @John-Qiao has provided instructions above to reference the earlier versions, which may not produce this issue. This is something that would need a fix from the Office team and Windows to take the fix. I would recommend following @John-Qiao's approach instead.

from winforms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.