FormBorderStyle为None的时候如何拖动窗体

 1 //为DllImport导出命名空间,
 2 using System.Runtime.InteropServices;
 3 public partial class Form1 : System.Windows.Forms.Form
 4 {
 5 #region FormBorderStyle为None,拖放窗体
 6 [DllImport("user32.dll")]
 7 public static extern bool ReleaseCapture();
 8 [DllImport("user32.dll")]
 9 public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
10 public const int WM_SYSCOMMAND = 0x0112;
11 public const int SC_MOVE = 0xF010;
12 public const int HTCAPTION = 0x0002;
13 private void Form_MouseDown(object sender, MouseEventArgs e)
14 {
15 ReleaseCapture();
16 SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
17 }
18 #endregion
19 #region 构造函数
20 public Form1()
21 {
22 //初始化窗体信息
23 //InitializeComponent();
24 //绑定鼠标拖动窗体事件
25 this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
26 }
27 #endregion
28 }

参考:

http://www.dxper.net/thread-2525-1-1.html

http://www.cnblogs.com/rogation/p/3508266.html

DllImport:http://blog.csdn.net/jame_peng/article/details/4387906

FormBorderStyle为None的时候如何拖动窗体

时间: 2024-08-07 13:12:40

FormBorderStyle为None的时候如何拖动窗体的相关文章

WPF无边框可拖动窗体

下面主要记录下创建无边框窗体,并且可以拖动.这种窗体主要用于弹出小窗体时. <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http

非标题区域拖动窗体VB

窗体空白区域按下鼠标左键即可任意拖动窗体,不需要拖动标题栏. Dim MoveScreen As Boolean Dim MousX As Integer Dim MousY As Integer Dim CurrX As Integer Dim CurrY As Integer Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then

鼠标拖动窗体

1.鼠标在客户区拖动窗口 重载消息函数 procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST; procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest); begin inherited; //不可缺少 if (=Message.Result = HTCLIENT) then Message.Result := HTCAPTION; end; 2.鼠标在

formborderstyle设为none之后怎么移动窗体?

bool formMove = false;//窗体是否移动        Point formPoint=new Point();//记录窗体的位置        int x;        int y;        private void Form1_MouseDown(object sender, MouseEventArgs e)        {            if (e.Button == MouseButtons.Left)            {          

当winform窗体的Bordestyle设置为None时,鼠标可以拖动窗体的办法

1 2015-07-11 16:05:35 2 bool formMove = false;//窗体是否移动 3 Point formPoint;//记录窗体的位置 4 private void Form1_MouseDown(object sender, MouseEventArgs e) 5 { 6 formPoint = new Point(); 7 int xOffset; 8 int yOffset; 9 if (e.Button == MouseButtons.Left) 10 {

delphi无边框可拖动窗体

unit UFrmModless; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFrmModeless = class(TForm) lblInfo: TLabel; btnClose: TButton; procedure FormClose(Sender: TObject; var Action: TClos

[转万一] 不使用标题栏拖动窗体

http://www.cnblogs.com/del/archive/2008/04/30/1178226.html 方法一.二.三效果图: 方法四效果图: 方法一: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs; type   TForm1 = class(TForm)     procedure FormMous

C#窗体控件拖动

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms; namespace 窗体控件移动{public partial class Form1

FireMonkey下的异形窗体拖动(句柄转换)

DelphiXE2 Firemoney FMX 的窗体不只是为windows的, 所以很多功能都没有了. 最常见的就是拖拽了 先看 VCL时代 一个经典拖动代码 [delphi] view plain copy ReleaseCapture(); SendMessage(Handle , WM_SYSCOMMAND,SC_MOVE+HTCAPTION, 0); 这段代码就是用来拖动异形窗体的, 可是到了 FMX下  好像不能用了? 其实还是可以使用的. 因为 FMX 的句柄不是 VCL 的窗体句