我是这样写的,把整部分都设为Caption:
procedure WMNCHitTest(var M: TWMNCHitTest);
begin
  inherited;
  if M.Result = HTCLIENT   then
     M.Result := htCaption;
end;
但如果我再添加一个关闭按钮的话,关闭按钮就不管事啦。好像是可以把控件的某一部分设为caption,但具体代码怎么写不知道,请问怎么写啊?

解决方案 »

  1.   

    你这样当然不行拉
    TWMNCHitTest 有参数表示X,Y的,你判断那个点是否在 关闭按钮的客户区内,如果不在再设置 M.Result := htCaption; 
      

  2.   


    procedure WMNCHitTest(var M: TWMNCHitTest); 
    var
      P: Tpoint;
    begin 
      inherited; 
      P := Point(N.xpos, M.Ypos);
      P := ScreenToClient(P);
      if PtInRect(ClientRect, P) and not(PtInRect(Close.BoundRect P) )
        M.Result := htCaption; 
    end; 在网吧写的,写错了莫怪,大概就是这么个意思 
      

  3.   

    见此帖:http://topic.csdn.net/t/20030107/11/1334265.html
    在程序运行时如何实现拖动、调整控件的大小