移動無邊框的Form

這篇是回應網友問題便測試看看,語言是用C#,有興趣的朋友可以參考看看

using System.Runtime.InteropServices;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
const int WM_SYSCOMMAND = 0x112;
const int SC_MOVE = 0xF012;

[DllImport("user32",EntryPoint="ReleaseCapture",CharSet=CharSet.Ansi)]
private extern static int ReleaseCapture ();

[DllImport("user32",EntryPoint="SendMessageA",CharSet=CharSet.Ansi)]
private extern static int SendMessage (IntPtr hwnd , int wMsg , int wParam, int lParam ) ;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
int i ;
i = ReleaseCapture();
i = SendMessage(this.Handle , WM_SYSCOMMAND, SC_MOVE, 0);
}
}
}

留言

這個網誌中的熱門文章

開啟cshtml檔案時,出現『並未將物件參考設定為物件執行個體』的錯誤訊息

無法設定中斷點 尚未載入符號檔

DataGridView欄位計算總合