【问题标题】:Resize Form from the Drawn Shape of Panel - VB.NET从面板的绘制形状调整窗体大小 - VB.NET
【发布时间】:2016-09-12 13:35:24
【问题描述】:

我正在尝试通过拖动在面板角落绘制的自定义形状来调整表单的大小。我有一个代码,如果它在主窗体中绘制,效果很好,但是如果我试图在面板的一角绘制它不起作用,我无法调整窗体的大小。代码经过优化以在表单中绘制,有人可以帮助我并更新它以在面板中工作吗?

    Protected Overrides Sub WndProc(ByRef m As Message)
    MyBase.WndProc(m)
    If m.Msg = &H84 Then
        Dim pos = Me.PointToClient(New System.Drawing.Point(m.LParam.ToInt32() And &HFFFF, m.LParam.ToInt32() >> 16))
        If pos.X >= Me.Width - grab AndAlso pos.Y >= Me.Height - grab Then
            m.Result = New IntPtr(17)
        End If
    End If
End Sub
Private Const grab As Integer = 14

Protected Overrides Sub OnPaint(e As PaintEventArgs)
    MyBase.OnPaint(e)
    Dim rc = New System.Drawing.Rectangle(Me.Width - grab, Me.Height - grab, grab, grab)
    ControlPaint.DrawSizeGrip(e.Graphics, System.Drawing.Color.FromArgb(250, 250, 250), rc)
End Sub

看起来像这样:

Here

【问题讨论】:

  • 谷歌“需要署名”。往往是让此代码的作者帮助您的好方法。
  • 我从 Hackforums.net 的用户那里得到代码,我真的不知道作者是谁。对不起!

标签: vb.net resize draw shape


【解决方案1】:

我设法通过使用 GDI 构建自己的自定义控件来将形状绘制为独立控件来解决问题,而不是将其绘制到已经构建的控件(例如面板)上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-18
    • 2023-04-02
    • 2011-06-25
    相关资源
    最近更新 更多