首先声明
// 截获消息WM_NCHITTEST,窗体标题事件
procedure wmhittest(var msg: TMessage);message WM_NCHitTest;
然后
procedure TForm1.wmhittest(var msg: TMessage);
var
i: Integer;
begin
inherited; // 继承祖先类的方法
for i:=0 to ComponentCount-1 do begin // 遍历窗体所有控件
if msg.Result = htCaption then // 返回HTCAPTION表明鼠标在Windows的标题栏中
if (Components is TControl) then
TControl(Components).Visible := True; // 显示所有TControl类控件
if msg.Result <> htCaption then // 返回非HTCAPTION表明鼠标不在Windows的标题栏中
TControl(Components).Visible := False; // 隐藏所有TControl类控件
end;
end;