<small id='A3Zwx'></small><noframes id='A3Zwx'>

<tfoot id='A3Zwx'></tfoot>
  • <i id='A3Zwx'><tr id='A3Zwx'><dt id='A3Zwx'><q id='A3Zwx'><span id='A3Zwx'><b id='A3Zwx'><form id='A3Zwx'><ins id='A3Zwx'></ins><ul id='A3Zwx'></ul><sub id='A3Zwx'></sub></form><legend id='A3Zwx'></legend><bdo id='A3Zwx'><pre id='A3Zwx'><center id='A3Zwx'></center></pre></bdo></b><th id='A3Zwx'></th></span></q></dt></tr></i><div id='A3Zwx'><tfoot id='A3Zwx'></tfoot><dl id='A3Zwx'><fieldset id='A3Zwx'></fieldset></dl></div>

        <bdo id='A3Zwx'></bdo><ul id='A3Zwx'></ul>
    1. <legend id='A3Zwx'><style id='A3Zwx'><dir id='A3Zwx'><q id='A3Zwx'></q></dir></style></legend>
      1. 调整窗口大小会导致黑条

        Resizing window causes black strips(调整窗口大小会导致黑条)
        <i id='SWbyr'><tr id='SWbyr'><dt id='SWbyr'><q id='SWbyr'><span id='SWbyr'><b id='SWbyr'><form id='SWbyr'><ins id='SWbyr'></ins><ul id='SWbyr'></ul><sub id='SWbyr'></sub></form><legend id='SWbyr'></legend><bdo id='SWbyr'><pre id='SWbyr'><center id='SWbyr'></center></pre></bdo></b><th id='SWbyr'></th></span></q></dt></tr></i><div id='SWbyr'><tfoot id='SWbyr'></tfoot><dl id='SWbyr'><fieldset id='SWbyr'></fieldset></dl></div>

        <small id='SWbyr'></small><noframes id='SWbyr'>

          • <bdo id='SWbyr'></bdo><ul id='SWbyr'></ul>
            • <legend id='SWbyr'><style id='SWbyr'><dir id='SWbyr'><q id='SWbyr'></q></dir></style></legend>

                <tbody id='SWbyr'></tbody>

                <tfoot id='SWbyr'></tfoot>
                  本文介绍了调整窗口大小会导致黑条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个表单,它在构造函数中设置这些样式:

                  I have a form, which sets these styles in constructor:

                  this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                  this.SetStyle(ControlStyles.UserPaint, true);
                  this.SetStyle(ControlStyles.ResizeRedraw, true);
                  this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                  

                  我在 Paint 事件中绘制了一些矩形.表单上没有控件.但是,当我调整表格大小时,表格的右侧和底部都有黑色条纹.有没有办法摆脱它们?我什么都试过了,在WndProc中监听WM_ERASEBKGND,在WM_PAINT上手动绘制表格,实现自定义双缓冲等等.有什么否则我可以试试吗?

                  And I draw some rectangles in Paint event. There are no controls on the form. Hovewer, when I resize the form, there are black strips at right and bottom of the form. Is there any way to get rid of them? I've tried everything, listening for WM_ERASEBKGND in WndProc, manually drawing the form on WM_PAINT, implementing custom double buffer, etc. Is there anything else I could try?

                  我发现了这个:https://connect.microsoft.com/VisualStudio/feedback/details/522441/custom-resizing-of-system-windows-window-flickers看起来这是 DWM 中的一个错误,但我只是希望我能做一些解决方法.

                  I've found this: https://connect.microsoft.com/VisualStudio/feedback/details/522441/custom-resizing-of-system-windows-window-flickers and it looks like it is a bug in DWM, but I just hope I can do some workaround.

                  请注意,我必须使用双缓冲,因为我想在 Paint 事件中绘制非常强烈的图形表示.我在 C# .NET 2.0、Win7 中开发.

                  Please note that I must use double buffering, since I want to draw pretty intense graphic presentation in the Paint event. I develop in C# .NET 2.0, Win7.

                  通过自己实现调整大小功能,我已经设法消除了大部分黑色条纹.但是,仍然存在一些小故障.有没有办法同时进行 resizepaint 操作?这是我需要做的伪代码:

                  I've managed to get rid of most of the black stripes by implementing the resize functionality by myself. Hovewer there are still some minor glitches. Is there any way to do resize and paint operation at once? Here is a pseudo-code of what I need to do:

                  IntPtr hDC;
                  var size = new Size(250, 200);
                  IntPtr handle = API.PaintAndResizeBegin(this.Handle /* Form.Handle */,
                                                          size.Width, size.Height, out hDC);
                  using (var g = Graphics.FromHdc(hDC)) {
                      this.backBuffer.Render(g, size);
                  }
                  API.PaintAndResizeCommit(handle);
                  

                  有没有办法实现上面的代码?

                  Is there any way to implement the above code?

                  第二种解决方案可能是回缓冲整个表单,包括非客户区.但是怎么做呢?我不想自己绘制非客户区域,因为我想在 Vista/7 上保持良好的航空效果.任何帮助将不胜感激.

                  The second solution could be to back-buffer whole form, including non-client area. But how to do that? I don't want to paint the non-client area by myself, as I want to keep the nice aero effect on Vista/7. Any help will be deeply appreciated.

                  看起来这个问题是无法解决的,因为它在 Windows 上无处不在,在每个应用程序中.我们只能希望 MS 在 Mac OS X 中获得一些灵感,并在新的 Windows 中提供适当的 API.

                  It looks like this problem is unsolvable, since it is omnipresent on Windows, in every application. We can just hope that MS will take some inspiration in Mac OS X and will provide appropriate APIs in new Windows.

                  推荐答案

                  我找到了可以同时绘制和调整窗口大小的功能 - UpdateLayeredWindow.

                  I've found the function which can paint and resize window at the same time - UpdateLayeredWindow.

                  所以现在应该可以创建可调整大小的窗口,这些窗口在调整大小时没有任何条带.但是,您需要自己绘制窗口内容,因此有点不方便.但是我认为使用WPFUpdateLayeredWindow应该没有问题.

                  So now it should be possible to create resizable windows, which do not have any strips while being resized. However, you need to paint the window content yourself, so it is a little inconvenient. But I think that using WPF and UpdateLayeredWindow, there shouldn't be any problem.

                  发现问题.:-) 当使用 UpdateLayeredWindow 时,您必须自己绘制窗口的边框.所以,如果你想在 win7 中使用 UpdateLayeredWindow 绘制具有漂亮玻璃效果的标准窗口,那你就完蛋了.

                  Found problems. :-) When using UpdateLayeredWindow, you must paint the window's border yourself. So, if you want standard window painted using UpdateLayeredWindow with nice glass effect in win7, you are screwed.

                  在 Microsft Connect 甚至是一个关于这个问题的线程,微软说这是一个设计上的错误,如果它得到修复,那么可能在 Win8 或一些更新的系统中.所以我们对此无能为力.

                  On Microsft Connect is even a thread about this problem, where Microsoft says it is a bug by design, and if it ever gets fixed, then probably in Win8 or some newer system. So there isn't much we could do about this.

                  这篇关于调整窗口大小会导致黑条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                    <tbody id='dmQAB'></tbody>
                  <tfoot id='dmQAB'></tfoot>
                  <legend id='dmQAB'><style id='dmQAB'><dir id='dmQAB'><q id='dmQAB'></q></dir></style></legend>

                  <small id='dmQAB'></small><noframes id='dmQAB'>

                  • <i id='dmQAB'><tr id='dmQAB'><dt id='dmQAB'><q id='dmQAB'><span id='dmQAB'><b id='dmQAB'><form id='dmQAB'><ins id='dmQAB'></ins><ul id='dmQAB'></ul><sub id='dmQAB'></sub></form><legend id='dmQAB'></legend><bdo id='dmQAB'><pre id='dmQAB'><center id='dmQAB'></center></pre></bdo></b><th id='dmQAB'></th></span></q></dt></tr></i><div id='dmQAB'><tfoot id='dmQAB'></tfoot><dl id='dmQAB'><fieldset id='dmQAB'></fieldset></dl></div>
                    • <bdo id='dmQAB'></bdo><ul id='dmQAB'></ul>