1
votes

I noticed that the message WM_NCHitTest isn't sent to a form when the cursor is inside the caption bar (not on the border).

I tried to intercept it using either

procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;

or

procedure WndProc(var Message: TMessage); override;

According to MSDN I was expecting to receive it for any point, with no blind spots.

Did I miss something or this is the intended behaviour?

I'm using Delphi 2010 on Windows 7, with Aero on.

3
Yes, that's supposed to work. Post real repro code.Hans Passant

3 Answers

4
votes

Yes -- that's expected. Unless you disable the DWM, you won't get WM_NCHITTEST messages when the cursor is in the title bar. Basically, when the DWM is on, the title bar "belongs" to the DWM, not your application.

If you really need those messages, you can disable the DWM -- but keep in mind that when/if you do this, it does not just disable it for your application. If you disable it, it's disabled for the whole system (until it's re-enabled again, of course).

0
votes

You can always use the WM_NCMOUSEMOVE message and test for its HitTest property:

procedure WMNCMouseMove(var Message: TWMNCMouseMove); message WM_NCMOUSEMOVE;  

[...]

procedure TForm11.WMNCMouseMove(var Message: TWMNCMouseMove);
begin
  with Message do
    if HitTest = HTCAPTION then
      Caption := Format('%d:%d',[XCursor,YCursor]);
end;