C#代码转vb.net
protectedoverridevoidWndProc(refMessagem){switch(m.Msg){case0x46:Rectanglerect=Screen...
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x46:
Rectangle rect = Screen.GetWorkingArea(this);
WINDOWPOS winPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
if (winPos.x + winPos.cx > rect.Right)
{
winPos.x = rect.Right - winPos.cx;
}
if (winPos.y + winPos.cy > rect.Bottom)
{
winPos.y = rect.Bottom - winPos.cy;
}
if (winPos.x < rect.Top)
{
winPos.x = rect.Top;
}
if (winPos.y < rect.Left)
{
winPos.y = rect.Left;
}
Marshal.StructureToPtr(winPos, m.LParam, false);
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
[StructLayout(LayoutKind.Sequential)]
internal struct WINDOWPOS
{
internal IntPtr hWnd;
internal IntPtr hWndInsertAfter;
internal int x;
internal int y;
internal int cx;
internal int cy;
internal int flags;
}
改成vb.net!
小弟怕没人回答,所以不带分,答好了,给上10分! 展开
{
switch (m.Msg)
{
case 0x46:
Rectangle rect = Screen.GetWorkingArea(this);
WINDOWPOS winPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
if (winPos.x + winPos.cx > rect.Right)
{
winPos.x = rect.Right - winPos.cx;
}
if (winPos.y + winPos.cy > rect.Bottom)
{
winPos.y = rect.Bottom - winPos.cy;
}
if (winPos.x < rect.Top)
{
winPos.x = rect.Top;
}
if (winPos.y < rect.Left)
{
winPos.y = rect.Left;
}
Marshal.StructureToPtr(winPos, m.LParam, false);
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
[StructLayout(LayoutKind.Sequential)]
internal struct WINDOWPOS
{
internal IntPtr hWnd;
internal IntPtr hWndInsertAfter;
internal int x;
internal int y;
internal int cx;
internal int cy;
internal int flags;
}
改成vb.net!
小弟怕没人回答,所以不带分,答好了,给上10分! 展开
1个回答
展开全部
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case 0x46
Dim rect As Rectangle = Screen.GetWorkingArea(Me)
Dim winPos As WINDOWPOS = CType(m.GetLParam(Type.GetType(WINDOWPOS)), WINDOWPOS)
If winPos.x + winPos.cx > rect.Right Then
winPos.x = rect.Right - winPos.cx
End If
If winPos.y + winPos.cy > rect.Bottom Then
winPos.y = rect.Bottom - winPos.cy
End If
If winPos.x < rect.Top Then
winPos.x = rect.Top
End If
If winPos.y < rect.Left Then
winPos.y = rect.Left
End If
Marshal.StructureToPtr(winPos, m.LParam, False)
MyBase.WndProc( m)
Exit Sub
Case Else
MyBase.WndProc( m)
Exit Sub
End Select
End Sub
<StructLayout(LayoutKind.Sequential)> _
Friend Structure WINDOWPOS
Friend hWnd As IntPtr
Friend hWndInsertAfter As IntPtr
Friend x As Integer
Friend y As Integer
Friend cx As Integer
Friend cy As Integer
Friend flags As Integer
End Structure
Select Case m.Msg
Case 0x46
Dim rect As Rectangle = Screen.GetWorkingArea(Me)
Dim winPos As WINDOWPOS = CType(m.GetLParam(Type.GetType(WINDOWPOS)), WINDOWPOS)
If winPos.x + winPos.cx > rect.Right Then
winPos.x = rect.Right - winPos.cx
End If
If winPos.y + winPos.cy > rect.Bottom Then
winPos.y = rect.Bottom - winPos.cy
End If
If winPos.x < rect.Top Then
winPos.x = rect.Top
End If
If winPos.y < rect.Left Then
winPos.y = rect.Left
End If
Marshal.StructureToPtr(winPos, m.LParam, False)
MyBase.WndProc( m)
Exit Sub
Case Else
MyBase.WndProc( m)
Exit Sub
End Select
End Sub
<StructLayout(LayoutKind.Sequential)> _
Friend Structure WINDOWPOS
Friend hWnd As IntPtr
Friend hWndInsertAfter As IntPtr
Friend x As Integer
Friend y As Integer
Friend cx As Integer
Friend cy As Integer
Friend flags As Integer
End Structure
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询