大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
DllImport("user32.dll", ExactSpelling:=True) _
创新互联是专业的洪江网站建设公司,洪江接单;提供成都网站建设、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行洪江网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
ByVal uFlags As UInteger) As Integer
End Function
Private Const GWL_STYLE As Integer = -16
Private Const GWL_EXSTYLE As Integer = -20
Private Const WS_BORDER As Integer = H800000
Private Const WS_EX_CLIENTEDGE As Integer = H200
Private Const SWP_NOSIZE As UInteger = H1
Private Const SWP_NOMOVE As UInteger = H2
Private Const SWP_NOZORDER As UInteger = H4
Private Const SWP_NOREDRAW As UInteger = H8
Private Const SWP_NOACTIVATE As UInteger = H10
Private Const SWP_FRAMECHANGED As UInteger = H20
Private Const SWP_SHOWWINDOW As UInteger = H40
Private Const SWP_HIDEWINDOW As UInteger = H80
Private Const SWP_NOCOPYBITS As UInteger = H100
Private Const SWP_NOOWNERZORDER As UInteger = H200
Private Const SWP_NOSENDCHANGING As UInteger = H400
Public Sub ChangeMdiClientBorderStyle(ByVal Value As System.Windows.Forms.BorderStyle, ByVal Handle As IntPtr)
Dim style As Integer = GetWindowLong(Handle, GWL_STYLE)
Dim exStyle As Integer = GetWindowLong(Handle, GWL_EXSTYLE)
' Add or remove style flags as necessary.
Select Case Value
Case BorderStyle.Fixed3D
exStyle = exStyle Or WS_EX_CLIENTEDGE
style = style And Not WS_BORDER
Exit Select
Case BorderStyle.FixedSingle
exStyle = exStyle And Not WS_EX_CLIENTEDGE
style = style Or WS_BORDER
Exit Select
Case BorderStyle.None
style = style And Not WS_BORDER
exStyle = exStyle And Not WS_EX_CLIENTEDGE
Exit Select
End Select
' Set the styles using Win32 calls
SetWindowLong(Handle, GWL_STYLE, style)
SetWindowLong(Handle, GWL_EXSTYLE, exStyle)
' Update the non-client area.
SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, _
SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOOWNERZORDER Or SWP_FRAMECHANGED)
End Sub
''' summary
''' 获取MDIClient句柄
''' /summary
''' returns/returns
''' remarks/remarks
Private Function getMdiClientHandle() As IntPtr
Dim Obj As MdiClient = Nothing
Dim t As Type
For Each Item As Control In Me.Controls
t = Item.[GetType]()
If t.Name = "MdiClient" Then
Obj = DirectCast(Item, MdiClient)
Exit For
End If
Next
If Obj IsNot Nothing Then
Return Obj.Handle
Else
Return IntPtr.Zero
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Me.IsMdiContainer Then
ChangeMdiClientBorderStyle(BorderStyle.None, getMdiClientHandle)
End If
End Sub
1、无边框窗体也就是无标题栏窗体,对于这样的窗体移动需要编程实现。
2、vb有两种办法实现,一直接编程实现,二调用windows API编程实现。
3、这里示例直接编程实现:
Option Explicit
Dim BolIsMove As Boolean, MousX As Long, MousY As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then BolIsMove = True
MousX = X
MousY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim CurrX As Long, CurrY As Long
If BolIsMove Then
CurrX = Me.Left - MousX + X
CurrY = Me.Top - MousY + Y
Me.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
BolIsMove = False
End Sub
设置窗体的text为空,设置窗体的controlbox属性为false,设置窗体的FormBorderStyle 属性为Sizable,就可以改变窗体大小了,并且可以在任务栏点击。
private const int GWL_STYLE = (-16);
private const int GWL_EXSTYLE = (-20);
private const uint WS_EX_LAYERED = 0x80000;
private const uint WS_EX_TRANSPARENT = 0x20;
private const uint WS_THICKFRAME = 262144;
private const uint WS_BORDER = 8388608;
/// summary使指定 「 see cref="IntPtr"/ 句柄」 窗体 边框样式变为无边框。/summary
public static uint 无边框窗体(IntPtr 句柄) {
uint style = API_窗口.GetWindowLong(句柄, GWL_STYLE);
style = ~WS_BORDER;
style = ~WS_THICKFRAME;
return API_窗口.SetWindowLong(句柄, GWL_STYLE, style); ;
}
API窗口静态类
[DllImport("user32", EntryPoint = "SetWindowLong")]
public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
[DllImport("user32", EntryPoint = "GetWindowLong")]
public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
修改窗口位置
/// summary
/// 设置窗体的位置和大小。
/// /summary
/// param name="hWnd"/param
/// param name="hWndInsertAfter"用于标识在z-顺序的此 CWnd 对象之前的 CWnd 对象。
/// para/para如果uFlags参数中设置了SWP_NOZORDER标记则本参数将被忽略。可为下列值之一:
/// para/paraHWND_BOTTOM:值为1,将窗体置于Z序的底部。如果参数hWnd标识了一个顶层窗体,则窗体失去顶级位置,并且被置在其他窗体的底部。
/// para/paraHWND_NOTOPMOST:值为-2,将窗体置于所有非顶层窗体之上(即在所有顶层窗体之后)。如果窗体已经是非顶层窗体则该标志不起作用。
/// para/paraHWND_TOP:值为0,将窗体置于Z序的顶部。
/// para/paraHWND_TOPMOST:值为-1,将窗体置于所有非顶层窗体之上。即使窗体未被激活窗体也将保持顶级位置。/param
/// param name="x"窗体新的x坐标。如hwnd是一个子窗体,则x用父窗体的客户区坐标表示/param
/// param name="y"窗体新的y坐标。如hwnd是一个子窗体,则y用父窗体的客户区坐标表示/param
/// param name="Width"指定新的窗体宽度/param
/// param name="Height"指定新的窗体高度/param
/// param name="wFlags"/param
/// returns/returns
[DllImport("user32.dll", CharSet = CharSet.Ansi, EntryPoint = "SetWindowPos")]
public static extern int SetWindowPos(IntPtr hWnd, hWndInsertAfter hWndInsertAfter, int x, int y, int Width, int Height, wFlags wFlags);
/// summary
/// 调整指定 「 see cref="IntPtr"/ 句柄」 窗体的位置和尺寸。
/// /summary
/// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗体/param
/// param name="x"横坐标/param
/// param name="y"纵坐标/param
/// param name="w"宽/param
/// param name="h"高/param
public static int 调整窗体(IntPtr 句柄, int x, int y, int w, int h) {
return API_窗口.SetWindowPos(句柄, 0, x, y, w, h, wFlags.SWP_NOZORDER);
}
/// summary
/// 调整指定 「 see cref="IntPtr"/ 句柄」 窗体的位置。
/// /summary
/// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗体/param
/// param name="x"横坐标/param
/// param name="y"纵坐标/param
public static int 调整窗体位置(IntPtr 句柄, int x, int y) {
return API_窗口.SetWindowPos(句柄, 0, x, y, 0, 0, wFlags.SWP_NOSIZE | wFlags.SWP_NOZORDER);
}
当用户按下左键时,为按下对象的MouseMove事件绑定处理方法,并记录鼠标坐标(窗体左上角为原点,在事件的MouseEventArgs类型的e参数中提供)。此时用户移动鼠标,保持窗体原点与鼠标新坐标的相对位置不变。当用户释放左键时,撤销按下对象的MouseMove事件处理方法
如果要做漂亮的界面的话,我建议你用WPF来做。所有的控件都可以用模板来定义样式。
虚线的话,只需要定义一个矩形,设置一个属性就可以了。前提是,WPF应用程序只能用VS2008或者VS2010来做