Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom cursor in window non-client area using Delphi

I have custom Delphi VCL control that intercepts WM_NCHITTEST message and returns HTCAPTION to make control movable on its parent window.

That part works fine, but returning HTCAPTION also resets my custom cursor to Windows default one when hovering over that control. Is there any way I can use HTCAPTION and still show my custom cursor?

Note: I know how to implement control movement without using HTCAPTION and solve cursor issue that way

like image 340
Dalija Prasnikar Avatar asked Nov 24 '25 07:11

Dalija Prasnikar


1 Answers

Use a WM_SETCURSOR message handler:

procedure TCustomVCLControl.WMSetCursor(var Message: TWMSetCursor);
begin
  SetCursor(Screen.Cursors[cr..]);
  Message.Result := 1;
end;
like image 169
Sertac Akyuz Avatar answered Nov 26 '25 17:11

Sertac Akyuz