我有个窗体对它进行了无标题窗体的拖动处理之后,就发现这个无标题窗体怎么也关不掉,鼠标也没办法击活其他的窗体,包括主窗体,请问怎么解决这样的问题?代码如下
procedure TDbForm.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);const SC_DRAGMOVE:Longint=$F012;
begin
  if button=mbleft then
  begin
  ReleaseCapture;
  SendMessage(Handle,WM_SYSCOMMAND,SC_DRAGMOVE,0);
  end;
end;procedure TDbForm.FormCreate(Sender: TObject);
begin
 DbForm.BorderStyle:=bsNone;end;

解决方案 »

  1.   

    unit DbUnit;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;type
      TDbForm = class(TForm)
        Image1: TImage;
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      DbForm: TDbForm;implementationuses mainUnit;{$R *.dfm}procedure TDbForm.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);const SC_DRAGMOVE:Longint=$F012;
    begin
    //  if button=mbright then
    //  dbform.Hide;
      if button=mbleft then
      begin
      ReleaseCapture;
      SendMessage(Handle,WM_SYSCOMMAND,SC_DRAGMOVE,0);
      end;
    end;procedure TDbForm.FormCreate(Sender: TObject);
    begin
     DbForm.BorderStyle:=bsNone;
    end;end./*****************************************************/
    以上是全部代码了,这个窗口的显示是在其他窗口SHOW出来的以下是代码
    procedure TadddbForm.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);begin
       if fDragging then begin
        image1.Canvas.DrawFocusRect(fRect);    fDragging:=false;  DBFORM.Image1.Width:= frect.BottomRight.X-frect.TopLeft.X;
      DBFORM.Image1.Height:=frect.BottomRight.Y-frect.TopLeft.Y;
      DBFORM.Image1.Canvas.CopyMode:=cmSrcCopy;
      DBFORM.Image1.canvas.copyrect(rect(0,0,frect.BottomRight.X-frect.TopLeft.X,frect.BottomRight.Y-frect.TopLeft.Y),image1.Canvas,frect);
      DBFORM.Width:= DBFORM.Image1.Width;
      DBFORM.Height:=DBFORM.Image1.Height;
      adddbform.Hide;
      dbform.Show;
      end;end;
      

  2.   

    procedure TDbForm.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    DbForm.Hide; //
    close;       //这2句不起作用 这里是我刚加的2句
    end;
      

  3.   

    我没看出你这个无标题窗口哪里执行close了?
      

  4.   

    The ReleaseCapture function releases the mouse capture from a window in the current thread 
    and restores normal mouse input processing. A window that has captured the mouse receives 
    all mouse input, regardless of the position of the cursor, except when a mouse button is clicked 
    while the cursor hot spot is in the window of another thread. 使用ReleaseCapture后,MouseUP事件是捕捉不到了的。