【例子介绍】实现无边框窗体拖放,并带检测鼠标位置
【相关图片】
【源码结构】procedure TForm1.WndProc(var Message: TMessage);
begin
inherited;
case (Message.Msg) of
WM_MOUSEMOVE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_MOUSEMOVE');
end;
WM_MOUSEHOVER:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_MOUSEHOVER');
end;
WM_MOUSELEAVE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_MOUSELEAVE');
end;
CM_MOUSEENTER:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'CM_MOUSEENTER');
end;
CM_MOUSELEAVE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'CM_MOUSELEAVE');
end;
WM_KILLFOCUS:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_KILLFOCUS');
end;
CM_HITTEST:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'CM_HITTEST');
end;
CM_SHOWINGCHANGED:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'CM_SHOWINGCHANGED');
end;
CM_SHOWHINTCHANGED:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'CM_SHOWHINTCHANGED');
end;
WM_SYSCOMMAND:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_SYSCOMMAND');
end;
WA_ACTIVE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WA_ACTIVE');
end;
WA_INACTIVE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WA_INACTIVE');
if MessageDlg('are you close?', mtConfirmation, [mbYes, mbNo], 0)= mrYes then
Close;
end;
WM_ACTIVATE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_ACTIVATE');
FFormReady := false;
end;
WM_MOUSEACTIVATE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_MOUSEACTIVATE');
end;
WM_SETFOCUS:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss', Now) 'WM_SETFOCUS');
end;
WM_NCACTIVATE:
begin
mm1.Lines.Append(FormatDateTime('hh:nn:ss ', Now) 'WM_NCACTIVATE');
if FFormReady then Exit;
Close;
end;
end;
end;
评论