Recent

Author Topic: [UN-Solvable] Set the OS global cursor  (Read 636 times)

What I can do

  • Full Member
  • ***
  • Posts: 193
[UN-Solvable] Set the OS global cursor
« on: September 30, 2024, 03:20:58 pm »
OS:Windows 10 @64
FPC: Lazarus 3.4
Project: set the global screen cursor for the OS

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons,
  3.   Grids, FileUtil,Windows;

Adding windows to users caused other problems
the CopyFile procedure from FileUtils now no longer works correct but remark the uses Windows and everything is back to normal.

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons,
  3.   Grids, FileUtil{,Windows};
It appears to me that some sort of conflict exist between FileUtils->CopyFile and something in the Windows->SetSystemCursor(hcur,IDC_HAND)
Anyone have a suggestion or work around?
« Last Edit: October 06, 2024, 07:39:05 pm by What I can do »

wp

  • Hero Member
  • *****
  • Posts: 13401
Re: Set the OS global cursor
« Reply #1 on: September 30, 2024, 04:33:47 pm »
When you add the Windows unit to the uses clause put this to the front. Because it overrides many other types and functions when it is at the end.

Code: Pascal  [Select][+][-]
  1.     uses
  2.       Windows,
  3.       Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons,
  4.       Grids, FileUtil;
« Last Edit: September 30, 2024, 05:07:46 pm by wp »

What I can do

  • Full Member
  • ***
  • Posts: 193
Re: Set the OS global cursor
« Reply #2 on: October 01, 2024, 12:17:08 pm »
Thanks for the reply WP,
made those changes and no more errors but still no cursor change yet.
Fixed the uses clause
Code: Pascal  [Select][+][-]
  1. uses
  2.   Windows,Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons,
  3.   Grids, FileUtil;

Set may global variables
Code: Pascal  [Select][+][-]
  1. var
  2.   Form1: TForm1;
  3.   aPath:rawbyteString;
  4.   aCursor: TCURSOR;

did a test at TForm1.OnActivate
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormActivate(Sender: TObject);
  2. begin
  3.   SetSystemCursor(aCursor,OCR_HAND);

but still just a normal mouse pointer
I'm doing something wrong?
« Last Edit: October 01, 2024, 12:21:09 pm by What I can do »

 

TinyPortal © 2005-2018