我可以用油漆偶数或不同的东西替换WM_PAINT吗? [英] Can I replace WM_PAINT with paint eventergs or something different?

查看:80
本文介绍了我可以用油漆偶数或不同的东西替换WM_PAINT吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我接近对listview进行嵌入式控制。目前唯一的障碍是使用64x绘画解决方案。



这里是我现在使用的代码:





I am close to making an embedded control to my listview. Right now the only obstacle is using a 64x painting solution.

here is the code I am using now:


 Private Const WM_PAINT As Integer = &HF
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
            Select Case m.Msg
                Case WM_PAINT
                    Dim rc As Rectangle
                    For Each ec As EmbeddedControl In _embeddedControls
                        rc = Me.GetSubItemBounds(ec.Item, ec.Column)
                        ec.Control.Bounds = rc
                    Next
                    Exit Select
            End Select
            MyBase.WndProc(m)
        End Sub





我有考虑使用:





I have thought about using:

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
           Select Case e.Graphics
               Case
           Dim rc As Rectangle
                   For Each ec As EmbeddedControl In _embeddedControls
                       rc = Me.GetSubItemBounds(ec.Item, ec.Column)
                       ec.Control.Bounds = rc
                   Next
                End Select


           MyBase.OnPaint(e)
       End Sub





我遇到的问题是我没有了解什么WM_PAINT不是它有32位系统使用而不是64位,这是我的程序内置。



我试过的:



我已经建立了一个绘制事件,但是,我不知道该如何引用它。



The issue I am having is I do not understand what WM_PAINT is other than it has a 32bit system usage and not a 64 bit, which is what my program is built in.

What I have tried:

I have built a paint event, however, I am not sure what to make the case for it to refer to.

推荐答案

WM_PAINT是告诉窗口绘制控件的消息。 VB.NET控件不应该有任何实际用途。没有理由我可以看到它不能在64位环境中触发,你的控件正在被绘制。



Control.Paint Event(System.Windows.Forms) [ ^ ]



这是.NET等价物,我认为与你说的相同。只需使用.NET版本,除非你需要互操作。
WM_PAINT is the message that tells windows to draw your control. A VB.NET control should not have any real use for it. There's no reason I can see for it not to fire in a 64 bit environment, your controls are being drawn.

Control.Paint Event (System.Windows.Forms)[^]

This is the .NET equivalent, which I think is the same as what you said. Just use the .NET version unless you need interop.


经过几个小时的搜索,我终于发现常规的paint eventgs不是我需要的。显然,我需要使用子项目绘制事件进行受保护的覆盖。



After many hours of searching I finally figured out that a regular paint eventargs was not what I needed. Apparently, I needed a protected overrides using a subitem draw event.

Protected Overrides Sub OnDrawSubItem(ByVal e As System.Windows.Forms.DrawListViewSubItemEventArgs)

      Dim rc As Rectangle
      For Each ec As EmbeddedControl In _embeddedControls
          rc = Me.GetSubItemBounds(ec.Item, ec.Column)
          ec.Control.Bounds = rc
      Next

      With e.Graphics
          .DrawLines(New Pen(SystemColors.ButtonShadow), New Point() {New Point(e.Bounds.Left, e.Bounds.Top - 1), New Point(e.Bounds.Left + e.Bounds.Width, e.Bounds.Top - 1), New Point(e.Bounds.Left + e.Bounds.Width, e.Bounds.Top + e.Bounds.Height), New Point(e.Bounds.Left, e.Bounds.Top + e.Bounds.Height)})
      End With

      e.DrawText()

      MyBase.OnDrawSubItem(e)

  End Sub





这仍然无法解决我的CPU问题,但是,删除了对32位dll的引用,并且现在已经替换了WM_paint事件。



This still didnt solve my CPU issue, however, the reference to the 32bit dll is removed and the WM_paint event has now been replaced.


这篇关于我可以用油漆偶数或不同的东西替换WM_PAINT吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆