How to show or hide the mouse lazarus / 39-Graphics ---------------------------------------------------------------------- witenite · 2016-08-16 09:09 Hi, I recently converted a program I have written using Delphi into Lazarus. My program has the following command in its code: ShowCursor(False);  // Hide cursor (Mouse) when we hover anywhere over the form This however cannot compile (Lazarus does not know what showcursor is). Basically this is a method for hiding the mouse whenever the mouse is over my form (I don't want to see the mouse cursor, and this works perfectly in Delphi). I have looked online for help, but the best I could find was a very old reference here: http://forum.lazarus.freepascal.org/index.php?topic=11655.0 Apparently showcursor used to work many years ago, but no longer does (or at least that is the best interpretation I can get from the forums. Am I missing a USE file or link, or does Lazarus have some other means of hiding the cursor? ---------------------------------------------------------------------- balazsszekely · 2016-08-16 09:22 I suppose you're under windows. If yes, just add JwaWindows to the uses clauses and you're good to go. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses JwaWindows; procedure TForm1.FormMouseEnter(Sender: TObject);begin  ShowCursor(False);end; procedure TForm1.FormMouseLeave(Sender: TObject);begin  ShowCursor(True);end; ---------------------------------------------------------------------- rvk · 2016-08-16 09:39 Quote from: GetMem on August 16, 2016, 11:22:48 amI suppose you're under windows. If yes, just add JwaWindows to the uses clauses and you're good to go. Uh... doesn't the Windows-unit have the same ShowCursor() defined?  (at least trunk does) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses Windows; ---------------------------------------------------------------------- balazsszekely · 2016-08-16 09:46 Quote@rvk Uh... doesn't the Windows-unit have the same ShowCursor() defined?Yes it does, but I like jwaWindows better, it's seem to me that it has a more complete api declarations. ---------------------------------------------------------------------- Zath · 2016-08-16 12:31 Quote from: GetMem on August 16, 2016, 11:46:53 amQuote@rvk Uh... doesn't the Windows-unit have the same ShowCursor() defined?Yes it does, but I like jwaWindows better, it's seem to me that it has a more complete api declarations.  So does this mean there are duplicate options within the default Lazarus installation ? ---------------------------------------------------------------------- balazsszekely · 2016-08-16 14:37 Quote@Zath So does this mean there are duplicate options within the default Lazarus installation ?Although are some overlapping api declarations, I wouldn't call it "duplicate". The windows unit is similar to delphi's windows unit, jwaWindows on the other hand is the port of the JEDI API library & security code library. ---------------------------------------------------------------------- RWC · 2016-08-16 14:58 How about: Form1.Cursor := crNone; //in LCL/controls.pp? ---------------------------------------------------------------------- JuhaManninen · 2016-08-16 15:29 Quote from: RWC on August 16, 2016, 04:58:26 pmHow about: Form1.Cursor := crNone; //in LCL/controls.pp? Yes, that is the cross-platform solution. Please remember that Lazarus is a cross-platform system and lots of effort was made to implement it. The Windows unit or similar should not be used, unless you are really creating a Windows specific program! ---------------------------------------------------------------------- balazsszekely · 2016-08-16 16:40 Ok, but the OP explicitly asked about ShowCursor api. ---------------------------------------------------------------------- witenite · 2016-08-17 09:49 Quote from: GetMem on August 16, 2016, 11:22:48 amI suppose you're under windows. If yes, just add JwaWindows to the uses clauses and you're good to go. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses JwaWindows; procedure TForm1.FormMouseEnter(Sender: TObject);begin  ShowCursor(False);end; procedure TForm1.FormMouseLeave(Sender: TObject);begin  ShowCursor(True);end; ---------------------------------------------------------------------- witenite · 2016-08-17 09:51 Quote from: GetMem on August 16, 2016, 11:22:48 amI suppose you're under windows. If yes, just add JwaWindows to the uses clauses and you're good to go. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses JwaWindows; procedure TForm1.FormMouseEnter(Sender: TObject);begin  ShowCursor(False);end; procedure TForm1.FormMouseLeave(Sender: TObject);begin  ShowCursor(True);end; Actually I'm using Lazarus on my home computer, which is Linux (Ubuntu) based. The Delphi package I use at work though, which is Windows based, hence the reason for using Showcursor. ---------------------------------------------------------------------- witenite · 2016-08-17 09:54 Quote from: RWC on August 16, 2016, 04:58:26 pmHow about: Form1.Cursor := crNone; //in LCL/controls.pp? Thanks! based on what I have read down below, this is a cross platform option, which will work quite nicely for me, as I am not using Windows at home, but instead run Ubuntu Linux. Thanks for all your help (and to the other people providing useful comments here too). ---------------------------------------------------------------------- Sergei · 2017-11-17 13:16 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Screen.Cursor := crNone ---------------------------------------------------------------------- rvk · 2017-11-17 13:22 Quote from: Sergei on November 17, 2017, 02:16:49 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Screen.Cursor := crNoneNote that Screen.Cursor := crNone doesn't completely eliminate the mouse-pointer. When you hover over a border of an edit, the mouse-pointer is visible again (and invisible again if you move off the border). ShowCursor(False) does not have that problem (but might be a Windows- only solution).