English 中文(简体)
C#中的阳性文字滚动
原标题:Smooth text scrolling in C#

i 希望在我的“玻璃窗”表中有滚动字。

i 试图用正文界定这一标签,用正文把颜色带上,但是这并不顺利,因为它就像在闪电中制造的动画。

如何设法实现这种平稳的估算?

事先感谢你!

问题回答

我试图这样做,我听到一些好消息和一些坏消息。

好消息是,这是可能的。 我现在正在测试该守则,我甚至可以与全球发展指数+一道实现绝对sil的平稳案文。

困难的方面是,你必须保证/执行以下几个方面:

  1. Set DoubleBuffered to true on your rendering surface (e.g. your form).
  2. You have to draw the text yourself, the Label class will not do (see next point as to why).
  3. You need floating point resolution in your drawing (positioning) code, which means you must use TextRenderingHint.AntiAlias in your DrawString() calls and bigger font sizes (>10-12 pt) to make it look good.
  4. You need a very high resolution timer component. I am using a component based on Win32 multimedia timers in winmm.dll that allows for timer event rates up to 1000 Hz and almost absolute accuracy (standard deviation below 0.1 ms). Google for MultimediaTimer component. (BTW, I know it is no longer the solution recommended by MS, but it works perfectly even in Windows 7.)
  5. Also, the Windows multimedia timer has a millisecond resolution, which cannot give you perfect 60 Hz refresh (1000/60 is not an integer), so you will need to implement some kind of a floating point display refresh counting mechanism to get as close to the display refresh rate as possible. Something along the lines of

    float tickCount = 0.0f;
    float tickDelta = 1000.0f / 60.0f;
    
    
    void mmTimer_Tick(object sender, EventArgs e)
    {
        tickCount++;
        if (tickCount >= tickDelta)
        {
            tickCount -= tickDelta;
            // scroll your text here 
            Invalidate();
        }
    }
    

    这样做。

  6. Finally, some minor tearing might happen occasionally. This is all but inevitable, as you have no access to vertical sync video registers. Experiment with timings to eliminate tearing.

我真诚地希望这一帮助。 让我知道,你是否有任何问题执行。

我假定,你使用双重缓冲,因为没有这种缓冲,你的案文是 W的,赢得的只是一味。

与此相关的是,你可能与全球发展趋势调查有关,而且你动速与监测复读率相提并论。

例如,如果你有60Hz LCD监测器,你就应当更新每1000/60毫秒的文本,但如果你使用时间,你现在和现在都经历过妇女。

如果你凌驾于仅读的财产,就会在你的形式上制造Params,并将WX_COMPOSITE(0x2000 000,我想这是复合物)添加到头盔中。 这只是冲锋枪,但停止了双双双双双鞋 t的浮油。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签