SetCursorPos(old_x,old_y);
我們注重客戶提出的每個要求,我們充分考慮每一個細(xì)節(jié),我們積極的做好做網(wǎng)站、成都網(wǎng)站設(shè)計服務(wù),我們努力開拓更好的視野,通過不懈的努力,創(chuàng)新互聯(lián)贏得了業(yè)內(nèi)的良好聲譽,這一切,也不斷的激勵著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計,微信小程序開發(fā),網(wǎng)站開發(fā),技術(shù)開發(fā)實力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫的技術(shù)開發(fā)工程師。
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
SetCursorPos(pt_x,pt_y);
1.在mouse事件中實現(xiàn)
2.調(diào)用windows API
實現(xiàn)方式為:
1.在mouse事件中實現(xiàn)
[csharp] view plain copy
Point mouseOff;//鼠標(biāo)移動位置變量
bool leftFlag;//標(biāo)簽是否為左鍵
private void groupControl1_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)
{
leftFlag = false;//釋放鼠標(biāo)后標(biāo)注為false;
}
}
private void groupControl1_MouseMove(object sender, MouseEventArgs e)
{
if (leftFlag)
{
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //設(shè)置移動后的位置
Location = mouseSet;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標(biāo)注為true;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標(biāo)注為true;
}
}
2.調(diào)用windows API
調(diào)用前需要添加using System.Runtime.InteropServices;
[csharp] view plain copy
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); //釋放鼠標(biāo)捕捉
//發(fā)送左鍵點擊的消息至該窗體(標(biāo)題欄)
SendMessage(Handle, 0xA1, 0x02, 0);
}
}
很簡單,加入全局變量中有一個變量,mousedown事件中設(shè)為1,在mouseup事件中置為0。這樣就能實現(xiàn)你說的功能。
以下參考
Private Sub 天平左移按鈕_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles 天平左移按鈕.PreviewMouseDown
a=true
End Sub
Private Sub 天平左移按鈕_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)Handles 天平左移按鈕.PreviewMouseUp
a=false
End Sub
看圖片背景,我又試了下資源管理器,文件是選中的狀態(tài)
選中文件和選中文字,背景色是不同的