Recent

Author Topic: SendMessage with Linux  (Read 3181 times)

Iniw

  • Newbie
  • Posts: 3
SendMessage with Linux
« on: July 21, 2021, 04:01:17 pm »
Hello,

with lazarus-2.0.12-fpc-3.2.0-win64, I can move a Form by clicking on its background [and on its TControl]
Code: Pascal  [Select][+][-]
  1. if Msg = LM_MOUSEMOVE then
  2.     begin
  3.       ReleaseCapture();
  4.       SendMessage(Self.Handle, LM_NCLButtonDown, HTCaption, 0);
  5.     end;
The same code in Linux has no effect [even if no compilation error appears].
Is SenMessage inoperative on Linux or am I doing it wrong ?

Best regards. IW


MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: SendMessage with Linux
« Reply #1 on: July 21, 2021, 06:20:17 pm »
The documentation suggests to me that it's not intended to work on any OS other than Windows: are you absolutely certain that those message numbers are portable?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Iniw

  • Newbie
  • Posts: 3
Re: SendMessage with Linux
« Reply #2 on: July 21, 2021, 06:36:42 pm »
Hello,
i suspected it doesn't work with linux or mac os.  But I had not found the documentation specifying it..
So I'll use the classic onMouseDown and co in a less elegant way.
Best regards. IW

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: SendMessage with Linux
« Reply #3 on: July 21, 2021, 07:07:03 pm »
I think on Linux the LM_NCLMouseButtonDown message is not interpreted  by window managers in the same way as on Windows.
For cross-platform use you have to do some variation on this sort of thing:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ApplicationProperties1UserInput(Sender: TObject; Msg: cardinal);
  2. var
  3.   pt: TPoint;
  4. begin
  5.   case Msg of
  6.     LM_LBUTTONDOWN: begin
  7.                       if not bPotentiallyMoving then
  8.                         bPotentiallyMoving := True;
  9.                       Cursor := crDrag;
  10.                     end;
  11.     LM_LBUTTONUP: begin
  12.                     bPotentiallyMoving := False;
  13.                     Cursor := crDefault;
  14.                   end;
  15.     LM_MOUSEMOVE: if bPotentiallyMoving then
  16.                     begin
  17.                       pt := ScreenToClient(Mouse.CursorPos);
  18.                       Left := ClientOrigin.X + pt.X;
  19.                       Top := ClientOrigin.Y + pt.Y;
  20.                     end;
  21.   end;
  22. end;

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: SendMessage with Linux
« Reply #4 on: July 21, 2021, 07:41:44 pm »
Hello,
i suspected it doesn't work with linux or mac os.  But I had not found the documentation specifying it..
So I'll use the classic onMouseDown and co in a less elegant way.
Best regards. IW

Out of curiosity: you've said it doesn't work but is that code successfully executed (i.e. if you put a debugger on that SendMessage())?

The documentation is phrased as though it's intended to be used if you're recompiling something which works on Delphi on the same platform. I am by no means an LCL expert, and responded primarily to make sure your question remained visible in the "Recent" list... grepping the sources it looks as though LM_NCLBUTTONDOWN is defined but literally never used.

OTOH LM_MOUSEMOVE appears in the code for all the widget sets.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018