发信人: redfox (Z掉了几乎所有的版...), 信区: BorlandDev
标  题: Delphi编程 -- 2.19 全部窗体可使用鼠标点中移动
发信站: 哈工大紫丁香 (2000年09月01日13:41:50 星期五), 站内信件

怎样将窗体设成全部窗体可使用鼠标点中移动 

最简单的办法就是"欺骗"系统,让他认为点中的是窗体的标题行

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 it's }
                                { 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


 

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.227.107]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.316毫秒