程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 全部窗體可使用鼠標中移動

全部窗體可使用鼠標中移動

編輯:Delphi

最簡單的辦法就是"欺騙"系統,讓他認為點中的是窗體的標題行

unit Dragmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
inherited; { call the inherited message handler }
if M.Result = htClient then { is the click in the client area? }
M.Result := htCaption; { if so, make Windows think its }
{ on the caption bar.}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
end.
{ 下面是這個窗體的設置}
object Form1: TForm1
Left = 203
Top = 94
BorderIcons = []
BorderStyle = bsNone
ClientHeight = 273
ClientWidth = 427
Font.Color = clWindowText
Font.Height = -13
Font.Name = System
Font.Style = []
PixelsPerInch = 96
TextHeight = 16
object Button1: TButton
Left = 160
Top = 104
Width = 89
Height = 33
Caption = Close
TabOrder = 0
OnClick = Button1Click
end
end

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved