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分!
展开
 我来答
小Case啊
2011-01-07 · 超过11用户采纳过TA的回答
知道答主
回答量:33
采纳率:0%
帮助的人:6.7万
展开全部
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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式