調(diào)用API是個(gè)好的辦法,給你個(gè)參考網(wǎng)文:
為平桂等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及平桂網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、平桂網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
如果一定要自已用GDI+繪制,很麻煩,比如把窗體設(shè)置成無(wú)邊框,貼圖上去,但可能要自已定義事件來(lái)響應(yīng)缺少標(biāo)題欄后的操作。等等
它們的窗體實(shí)際上就是你截圖出來(lái)的大小,周圍的陰影效果都是自己畫出來(lái)的。
設(shè)置全局變量:
Dim?drag?As?Boolean
Dim?mousex?As?Integer
Dim?mousey?As?Integer
假設(shè)你想拖動(dòng)的是Panel1控件,以及此控件上的?Label1(用于顯示標(biāo)題)和PictureBox4(用于顯示圖標(biāo)):
Private?Sub?TitleMove_MouseDown(sender?As?Object,?e?As?System.Windows.Forms.MouseEventArgs)?Handles?Panel1.MouseDown,?Label1.MouseDown,?PictureBox4.MouseDown
drag?=?True
mousex?=?Windows.Forms.Cursor.Position.X?-?Me.Left
mousey?=?Windows.Forms.Cursor.Position.Y?-?Me.Top
End?Sub
Private?Sub?TitleMove_MouseMove(sender?As?Object,?e?As?System.Windows.Forms.MouseEventArgs)?Handles?Panel1.MouseMove,?Label1.MouseMove,?PictureBox4.MouseMove
If?drag?Then
Me.Top?=?Windows.Forms.Cursor.Position.Y?-?mousey
Me.Left?=?Windows.Forms.Cursor.Position.X?-?mousex
End?If
End?Sub
Private?Sub?TitleMove_MouseUp(sender?As?Object,?e?As?System.Windows.Forms.MouseEventArgs)?Handles?Panel1.MouseUp,?Label1.MouseUp,?PictureBox4.MouseUp
drag?=?False
End?Sub
調(diào)用系統(tǒng)API使窗體下?lián)碛嘘幱靶Ч?/p>
using System.Runtime.InteropServices;
然后再窗口類的隨便哪個(gè)地方加上:
const int CS_DROPSHADOW = 0x20000;
const int GCL_STYLE = (-26);
//聲明Win32 API
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetClassLong(IntPtr hwnd,int nIndex,int dwNewLong);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int GetClassLong(IntPtr hwnd, int nIndex);
最后在窗體的構(gòu)造函數(shù)中加上:
SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DROPSHADOW);
vb.net2008
vb.net API 是將除特殊變量(如H20000)的Long都改成Integer
窗體的右側(cè)和下方有陰影
Public Class Form1
Private Const CS_DROPSHADOW = H20000
Private Const GCL_STYLE = (-26)
Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetClassLong(Me.Handle, GCL_STYLE, GetClassLong(Me.Handle, GCL_STYLE) Or CS_DROPSHADOW)
End Sub
End Class
Public Class Form1
Private Const CS_DROPSHADOW = H20000
Private Const GCL_STYLE = (-26)
Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetClassLong(Me.Handle, GCL_STYLE, GetClassLong(Me.Handle, GCL_STYLE) Or CS_DROPSHADOW)