在将Panel设成DragMode=dmAutomatic,DragKind=dkDock后,可将其拖出,浮在窗口上面.如何让可拖动的Panel在一开始就显示出带关闭按钮的小控制条呢?我想利用那个小控制条来将Panel拖动.
    请高手指教一下!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;type
      TForm1 = class(TForm)
        Panel2: TPanel;
        Panel1: TPanel;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      panel1.ManualDock(panel2);
    end;end.
    //
    object Form1: TForm1
      Left = 192
      Top = 133
      Width = 696
      Height = 480
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Panel2: TPanel
        Left = 152
        Top = 88
        Width = 457
        Height = 297
        Caption = 'Panel2'
        DockSite = True
        TabOrder = 0
        object Panel1: TPanel
          Left = 40
          Top = 24
          Width = 185
          Height = 41
          Caption = 'Panel1'
          DragKind = dkDock
          DragMode = dmAutomatic
          TabOrder = 0
        end
      end
    end
      

  2.   

    没有测试过,你只管试试看。思路如下:
    exstyle=GetWindowLong(MyPanel.Handle, GWL_EXSTYLE);
    exstyle=exstyle or WS_EX_WINDOWEDGE or WS_EX_CAPTION or WS_EX_TOOLWINDOW;
    SetWindowLong(MyPanel.Handle, GWL_EXSTYLE, exstyle);具体的可以查看CreateWindowEx,SetWindowLong,GetWindowLong的Windows API帮助。
      

  3.   

    设置panel1.dragkind = drDrag即可
      

  4.   

    我也要实现这么个功能,包括toolbutton也可以浮动